Skip to contentSkip to conversation

Fixes for PATH usage in devtool

PATCH New Paul Barker 1 participant 3 messages Jan 6

lore
Share & tools
lore
#0 lore raw

cover Fixes for PATH usage in devtool

These patches follow up the fix for the devtool selftest which has already been sent [1].

[1]: https://msgid.link/[email protected]/

---
Paul Barker (2):
devtool: deploy: Run pseudo with correct PATH
devtool: deploy: Reset PATH after strip_execs

 scripts/lib/devtool/__init__.py | 3 ++-
 scripts/lib/devtool/deploy.py   | 9 ++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

---
base-commit: 0ed4776533145c901611d7f4f942490e33481335
change-id: 20260106-devtool-path-8a4f5b57e894

Best regards,

Signature · 1 line
Paul Barker
#1 lore raw

PATCH 1/2 devtool: deploy: Run pseudo with correct PATH

When running FAKEROOTCMD (i.e. pseudo), we need to use the same PATH as we would use if we were running inside bitbake instead of the host environment's PATH. This ensures that we don't pick up any host executables that may have problems with pseudo (such as the uutils implementations of common system utilities used in Ubuntu 25.10).

---
 scripts/lib/devtool/__init__.py | 3 ++-
 scripts/lib/devtool/deploy.py   | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)
scripts/lib/devtool/__init__.py +2 -1
index 969d6dc13ab1..7c8de5540c1c 100644
@@ -74,12 +74,13 @@ def exec_watch(cmd, **options):
 
     return buf, None
 
-def exec_fakeroot_no_d(fakerootcmd, fakerootenv, cmd, **kwargs):
+def exec_fakeroot_no_d(fakerootcmd, fakerootenv, path, cmd, **kwargs):
     if not os.path.exists(fakerootcmd):
         logger.error('pseudo executable %s could not be found - have you run a build yet? pseudo-native should install this and if you have run any build then that should have been built')
         return 2
     # Set up the appropriate environment
     newenv = dict(os.environ)
+    newenv['PATH'] = path
     for varvalue in fakerootenv.split():
         if '=' in varvalue:
             splitval = varvalue.split('=', 1)
scripts/lib/devtool/deploy.py +3 -3
index a98b33c5718a..2bf693d165a0 100644
@@ -186,8 +186,8 @@ def deploy_no_d(srcdir, workdir, path, strip_cmd, libdir, base_libdir, max_proce
         srcdir = recipe_outdir
         recipe_outdir = os.path.join(workdir, 'devtool-deploy-target-stripped')
         if os.path.isdir(recipe_outdir):
-            exec_fakeroot_no_d(fakerootcmd, fakerootenv, "rm -rf %s" % recipe_outdir, shell=True)
-        exec_fakeroot_no_d(fakerootcmd, fakerootenv, "cp -af %s %s" % (os.path.join(srcdir, '.'), recipe_outdir), shell=True)
+            exec_fakeroot_no_d(fakerootcmd, fakerootenv, path, "rm -rf %s" % recipe_outdir, shell=True)
+        exec_fakeroot_no_d(fakerootcmd, fakerootenv, path, "cp -af %s %s" % (os.path.join(srcdir, '.'), recipe_outdir), shell=True)
         os.environ['PATH'] = ':'.join([os.environ['PATH'], path or ''])
         oe.package.strip_execs(args.recipename, recipe_outdir, strip_cmd, libdir, base_libdir, max_process)
 
@@ -266,7 +266,7 @@ def deploy_no_d(srcdir, workdir, path, strip_cmd, libdir, base_libdir, max_proce
         shutil.rmtree(tmpdir)
 
     # Now run the script
-    ret = exec_fakeroot_no_d(fakerootcmd, fakerootenv, 'tar cf - . | %s  %s %s %s \'sh %s %s %s %s\'' % (ssh_sshexec, ssh_port, extraoptions, args.target, tmpscript, args.recipename, destdir, tmpfilelist), cwd=recipe_outdir, shell=True)
+    ret = exec_fakeroot_no_d(fakerootcmd, fakerootenv, path, 'tar cf - . | %s  %s %s %s \'sh %s %s %s %s\'' % (ssh_sshexec, ssh_port, extraoptions, args.target, tmpscript, args.recipename, destdir, tmpfilelist), cwd=recipe_outdir, shell=True)
     if ret != 0:
         raise DevtoolError('Deploy failed - rerun with -s to get a complete '
                         'error message')
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/2 devtool: deploy: Reset PATH after strip_execs

In reply to Paul Barker

We need to modify os.environ so that strip_execs() finds the correct binaries to run. We shouldn't leave this modification in place for the rest of the program execution though.

---
 scripts/lib/devtool/deploy.py | 3 +++
 1 file changed, 3 insertions(+)
scripts/lib/devtool/deploy.py +3 -0
index 2bf693d165a0..270e9104b25b 100644
@@ -188,8 +188,11 @@ def deploy_no_d(srcdir, workdir, path, strip_cmd, libdir, base_libdir, max_proce
         if os.path.isdir(recipe_outdir):
             exec_fakeroot_no_d(fakerootcmd, fakerootenv, path, "rm -rf %s" % recipe_outdir, shell=True)
         exec_fakeroot_no_d(fakerootcmd, fakerootenv, path, "cp -af %s %s" % (os.path.join(srcdir, '.'), recipe_outdir), shell=True)
+
+        oldpath = os.environ['PATH']
         os.environ['PATH'] = ':'.join([os.environ['PATH'], path or ''])
         oe.package.strip_execs(args.recipename, recipe_outdir, strip_cmd, libdir, base_libdir, max_process)
+        os.environ['PATH'] = oldpath
 
     filelist = []
     inodes = set({})
Signature · 1 line
2.43.0