1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-05 12:02:47 +00:00
nixpkgs/pkgs/development/tools/misc/patchelf/setup-hook.sh
Guillaume Maudoux bfd522da63 setup-hooks: do not pass missing dirs to find (close #15405)
find fails when called with an inexistent search path.
That situation may arise when the output is created after by a postFixup hook.
vcunat amended the PR by clarifying one more `return` to `return 0`.
2016-05-22 12:08:01 +02:00

23 lines
637 B
Bash

# This setup hook calls patchelf to automatically remove unneeded
# directories from the RPATH of every library or executable in every
# output.
fixupOutputHooks+=('if [ -z "$dontPatchELF" ]; then patchELF "$prefix"; fi')
patchELF() {
local dir="$1"
[ -e "$dir" ] || return 0
header "shrinking RPATHs of ELF executables and libraries in $dir"
local i
while IFS= read -r -d $'\0' i; do
if [[ "$i" =~ .build-id ]]; then continue; fi
if ! isELF "$i"; then continue; fi
echo "shrinking $i"
patchelf --shrink-rpath "$i" || true
done < <(find "$dir" -type f -print0)
stopNest
}