diff mbox series

runqemu-extract-sdk: fix PATH loss in pseudo_native_environment()

Message ID 20260910205527.192893-1-adrian.freihofer@siemens.com
State New
Headers show
Series runqemu-extract-sdk: fix PATH loss in pseudo_native_environment() | expand

Commit Message

AdrianF Sept. 10, 2026, 8:55 p.m. UTC
From: Adrian Freihofer <adrian.freihofer@siemens.com>

pseudo_native_environment() built a fresh dict with only
OECORE_NATIVE_SYSROOT and PSEUDO instead of the caller's environment.
extract_sdk_rootfs() passes it straight to subprocess.run(env=...),
which replaces the child's environment wholesale, so PATH (and
everything else) was lost and tar fell back to the tar form the host.
This regression was introduced in commit 78c176df1 (the Python refactor).

Symptom: "tar: unrecognized option '--zstd'" on hosts where the
default-PATH tar doesn't support it (e.g. RHEL8's tar 1.30).

Fix by starting from a copy of os.environ, matching how
devtool/ide_sdk.py's extract_nfs_rootfs() already builds its own
environment.

Also derive the "Accepted types" error message in _tar_options() from
tar_extract_options's keys instead of a separately hardcoded list.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 scripts/lib/pseudo_rootfs_utils.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/scripts/lib/pseudo_rootfs_utils.py b/scripts/lib/pseudo_rootfs_utils.py
index 89d082f672..12431e2080 100644
--- a/scripts/lib/pseudo_rootfs_utils.py
+++ b/scripts/lib/pseudo_rootfs_utils.py
@@ -37,7 +37,8 @@  def pseudo_native_environment():
     if not native_sysroot or not os.path.exists(native_sysroot):
         raise PseudoRootfsError("%s doesn't exist" % native_sysroot)
 
-    environment = {'OECORE_NATIVE_SYSROOT': native_sysroot}
+    environment = dict(os.environ)
+    environment['OECORE_NATIVE_SYSROOT'] = native_sysroot
     environment['PSEUDO'] = os.path.join(native_sysroot, 'usr', 'bin', 'pseudo')
     return environment
 
@@ -55,7 +56,7 @@  def _tar_options(rootfs_tarball):
             return ['--numeric-owner', *option.split()]
     raise PseudoRootfsError(
         'Unable to determine sdk tarball format\n'
-        'Accepted types: .tar / .tar.gz / .tar.bz2 / .tar.xz / .tar.zst')
+        'Accepted types: %s' % ' / '.join(tar_extract_options))
 
 
 def pseudo_state_dir(rootfs_dir):