[pacman-dev] [PATCH] libmakepkg: maintain file ownership while stripping
fakeroot can be flakey, as demonstrated by strip not maintaining file permissions under fakeroot with binutils-2.36.1 built against glibc-2.33. Instead of relying on fakeroot to be functional, ensure permissions are maintained across file stripping. Also set debug symbols to always have root:root ownership. Signed-off-by: Allan McRae <allan@archlinux.org> --- build-aux/edit-script.sh.in | 1 + meson.build | 4 ++++ scripts/libmakepkg/tidy/strip.sh.in | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/build-aux/edit-script.sh.in b/build-aux/edit-script.sh.in index 661c22d5..fa5ebcf2 100644 --- a/build-aux/edit-script.sh.in +++ b/build-aux/edit-script.sh.in @@ -19,6 +19,7 @@ mode=$3 -e "s|@TEMPLATE_DIR[@]|@TEMPLATE_DIR@|g" \ -e "s|@DEBUGSUFFIX[@]|@DEBUGSUFFIX@|g" \ -e "s|@INODECMD[@]|@INODECMD@|g" \ + -e "s|@STATCMD[@]|@STATCMD@|g" \ -e "s|@FILECMD[@]|@FILECMD@|g" \ "$input" >"$output" diff --git a/meson.build b/meson.build index ea9bd2f7..edf988e9 100644 --- a/meson.build +++ b/meson.build @@ -224,6 +224,7 @@ add_project_arguments('-include', 'config.h', language : 'c') filecmd = 'file' inodecmd = 'stat -c \'%i %n\'' +statcmd = 'stat -c' strip_binaries = '--strip-all' strip_shared = '--strip-unneeded' strip_static = '--strip-debug' @@ -238,11 +239,13 @@ endif os = host_machine.system() if os.startswith('darwin') inodecmd = '/usr/bin/stat -f \'%i %N\'' + statcmd = '/usr/bin/stat -c' strip_binaries = '' strip_shared = '-s' strip_static = '-s' elif os.contains('bsd') or os == 'dragonfly' inodecmd = 'stat -f \'%i %N\'' + statcmd = 'stat -c' endif chost = run_command(cc, '-dumpmachine').stdout().strip() @@ -269,6 +272,7 @@ substs.set('BUILDSCRIPT', BUILDSCRIPT) substs.set('TEMPLATE_DIR', get_option('makepkg-template-dir')) substs.set('DEBUGSUFFIX', get_option('debug-suffix')) substs.set('INODECMD', inodecmd) +substs.set('STATCMD', statcmd) substs.set('FILECMD', filecmd) substs.set('LIBMAKEPKGDIR', LIBMAKEPKGDIR) substs.set('STRIP_BINARIES', strip_binaries) diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in index 868b96f3..6676c012 100644 --- a/scripts/libmakepkg/tidy/strip.sh.in +++ b/scripts/libmakepkg/tidy/strip.sh.in @@ -66,10 +66,15 @@ strip_file() { fi done < <(source_files "$binary") + # save original file permissions + file_owner=$(@STATCMD@ '%u' "$binary") + file_group=$(@STATCMD@ '%g' "$binary") + # copy debug symbols to debug directory mkdir -p "$dbgdir/${binary%/*}" objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug" objcopy --add-gnu-debuglink="$dbgdir/${binary#/}.debug" "$binary" + chown root:root "$dbgdir/$binary.debug" # create any needed hardlinks while IFS= read -rd '' file ; do @@ -94,6 +99,7 @@ strip_file() { fi strip $@ "$binary" + chown $file_owner:$file_group "$binary" } -- 2.30.0
participants (1)
-
Allan McRae