From: Adrian Freihofer <[email protected]> Any file modification on pseudo-tracked files must happen inside the pseudo fakeroot environment so the pseudo database stays in sync with the real filesystem. Stripping was done outside pseudo, which is conceptually wrong: tools that replace files (temp+rename) change inodes, and pseudo loses track of the new inodes, causing the deployment tar to embed incorrect ownership and permissions.
This probably went unnoticed because GNU strip modifies files in place without changing their inodes. llvm-strip replaces files via a temp file and rename, making the ownership corruption visible. The old code was manually prepending path to the parent process's PATH so strip_cmd could be found, then restoring it. The new code passes the strip script to exec_fakeroot_no_d, which already sets PATH = path in the subprocess's environment — so strip_cmd is findable there without touching the parent's PATH at all. Signed-off-by: Adrian Freihofer <[email protected]> --- scripts/lib/devtool/deploy.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/lib/devtool/deploy.py b/scripts/lib/devtool/deploy.py index 7866cfbaae..6a75538fb0 100644 --- a/scripts/lib/devtool/deploy.py +++ b/scripts/lib/devtool/deploy.py @@ -9,7 +9,9 @@ import logging import os import shutil +import shlex import subprocess +import sys import tempfile import bb.utils @@ -221,10 +223,21 @@ def deploy_no_d(srcdir, workdir, path, strip_cmd, libdir, base_libdir, max_proce 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 + # Strip under pseudo so that it records any inode replacements made by + # the strip tool before the deployment tar reads this directory. + strip_script = ( + 'import sys\n' + 'sys.path[:] = %r\n' + 'import oe.package\n' + 'oe.package.strip_execs(%r, %r, %r, %r, %r, %r)\n' + ) % (sys.path, args.recipename, recipe_outdir, strip_cmd, libdir, + base_libdir, max_process) + ret = exec_fakeroot_no_d( + fakerootcmd, fakerootenv, path, + '%s -c %s' % (shlex.quote(sys.executable), shlex.quote(strip_script)), + shell=True) + if ret != 0: + raise DevtoolError('Failed to strip files for deployment') filelist = [] inodes = set({}) -- 2.55.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#242730): https://lists.openembedded.org/g/openembedded-core/message/242730 Mute This Topic: https://lists.openembedded.org/mt/120592134/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
