Skip to contentSkip to conversation

meta/classes-recipe/toolchain-scripts.bbclass: eliminate bash-ism

PATCH New Alexander Kanavin 1 participant 2 messages Oct 7, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 meta/classes-recipe/toolchain-scripts.bbclass: eliminate bash-ism

From: Alexander Kanavin <[email protected]>

Sourcing a script with arguments is a non-standard bash extension and doesn't work with other shells (e.g. dash, which is used on Debian and derivatives). This used to work by coincidence when running against integrated poky repo without having to separately specify where bitbake is, but no longer does.

Using set is a POSIX standard.

---
 meta/classes-recipe/toolchain-scripts.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes-recipe/toolchain-scripts.bbclass +1 -1
index ec040b5ebbe..8c062ef0e74 100644
@@ -92,7 +92,7 @@ toolchain_create_tree_env_script () {
 	touch $script
 	echo 'standalone_sysroot_target="${STAGING_DIR}/${MACHINE}"' >> $script
 	echo 'standalone_sysroot_native="${STAGING_DIR}/${BUILD_ARCH}"' >> $script
-	echo "orig=`pwd`; cd ${COREBASE}; . ./oe-init-build-env ${TOPDIR} $bitbakedir; cd \$orig" >> $script
+	echo "orig=`pwd`; cd ${COREBASE}; set ${TOPDIR} $bitbakedir; . ./oe-init-build-env; cd \$orig" >> $script
 	echo 'export PATH=$standalone_sysroot_native/${bindir_native}:$standalone_sysroot_native/${bindir_native}/${TARGET_SYS}:$PATH' >> $script
 	echo 'export PKG_CONFIG_SYSROOT_DIR=$standalone_sysroot_target' >> $script
 	echo 'export PKG_CONFIG_PATH=$standalone_sysroot_target'"$libdir"'/pkgconfig:$standalone_sysroot_target'"$prefix"'/share/pkgconfig' >> $script
Signature · 1 line
2.39.5
#1 lore raw

PATCH 2/2 selftest/meta_ide: source the environment first, then change to the sources directory

From: Alexander Kanavin <[email protected]>

This too used to work by coincidence: sourcing the environment quietly failed without changing to the build directory, but now that it works properly, things should be done in correct order.

---
 meta/lib/oeqa/selftest/cases/meta_ide.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oeqa/selftest/cases/meta_ide.py +1 -1
index c3a7df4cdf5..1a114737975 100644
@@ -37,7 +37,7 @@ class MetaIDE(OESelftestTestCase):
 
     def test_meta_ide_can_compile_c_program(self):
         runCmd('cp %s/test.c %s' % (self.tc.files_dir, self.tmpdir_metaideQA))
-        runCmd("cd %s; . %s; $CC test.c -lm" % (self.tmpdir_metaideQA, self.environment_script_path))
+        runCmd(". %s; cd %s; $CC test.c -lm" % (self.environment_script_path, self.tmpdir_metaideQA))
         compiled_file = '%s/a.out' % self.tmpdir_metaideQA
         self.assertExists(compiled_file)
 
Signature · 1 line
2.39.5