Merge pull request #246164 from trofi/strip-no-symlinks

setup-hooks/strip: resolve/uniq symlinks before stripping
This commit is contained in:
Linus Heckemann 2023-07-31 11:02:20 +02:00 committed by GitHub
commit a3d2e71a6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,6 +68,11 @@ stripDirs() {
striperr="$(mktemp 'striperr.XXXXXX')"
# Do not strip lib/debug. This is a directory used by setup-hooks/separate-debug-info.sh.
find $paths -type f -a '!' -path "$prefix/lib/debug/*" -print0 |
# Make sure we process files under symlinks only once. Otherwise
# 'strip` can corrupt files when writes to them in parallel:
# https://github.com/NixOS/nixpkgs/issues/246147#issuecomment-1657072039
xargs -r -0 -n1 -- realpath -z | sort -u -z |
xargs -r -0 -n1 -P "$NIX_BUILD_CORES" -- $cmd $stripFlags 2>"$striperr" || exit_code=$?
# xargs exits with status code 123 if some but not all of the
# processes fail. We don't care if some of the files couldn't