The environment setup script installed by a buildtools tarball is named
environment-setup-<arch>-<sdk-name>-linux. The script previously hardcoded
"pokysdk" for this component, so any distro that ships buildtools under a
different SDK name gets a FileNotFoundError after an otherwise successful
install.

Use glob.glob() to discover the environment setup script by pattern
matching on environment-setup-<arch>-*-linux in the install directory.
Since a buildtools install should produce exactly one such script, error
out if zero or more than one match is found.

Signed-off-by: Jaipaul Cheernam <[email protected]>
---
 scripts/install-buildtools | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/scripts/install-buildtools b/scripts/install-buildtools
index b9c008a2ec..723edd793e 100755
--- a/scripts/install-buildtools
+++ b/scripts/install-buildtools
@@ -33,6 +33,7 @@
 #
 
 import argparse
+import glob
 import logging
 import os
 import platform
@@ -305,8 +306,17 @@ def main():
         # Setup the environment
         logger.info("Setting up the environment")
         regex = re.compile(r'^(?P<export>export 
)?(?P<env_var>[A-Z_]+)=(?P<env_val>.+)$')
-        with open("%s/environment-setup-%s-pokysdk-linux" %
-                  (install_dir, arch), 'rb') as f:
+        pattern = os.path.join(install_dir, "environment-setup-%s-*-linux" % 
arch)
+        matches = glob.glob(pattern)
+        if len(matches) == 0:
+            logger.error("No environment setup script matching %s" % pattern)
+            return 1
+        if len(matches) > 1:
+            logger.error("Multiple environment setup scripts found: %s"
+                         % " ".join(matches))
+            return 1
+        logger.debug("Using environment setup script: %s" % matches[0])
+        with open(matches[0], 'rb') as f:
             for line in f:
                 match = regex.search(line.decode('utf-8'))
                 logger.debug("export regex: %s" % match)
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#238888): 
https://lists.openembedded.org/g/openembedded-core/message/238888
Mute This Topic: https://lists.openembedded.org/mt/119831207/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to