@@ -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)
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 <jaipaul.cheernam@est.tech> --- scripts/install-buildtools | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)