diff options
Diffstat (limited to 'nixpkgs/pkgs/development/tools/misc/patchelf/setup-hook.sh')
-rw-r--r-- | nixpkgs/pkgs/development/tools/misc/patchelf/setup-hook.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/tools/misc/patchelf/setup-hook.sh b/nixpkgs/pkgs/development/tools/misc/patchelf/setup-hook.sh new file mode 100644 index 000000000000..bc1cddd4879c --- /dev/null +++ b/nixpkgs/pkgs/development/tools/misc/patchelf/setup-hook.sh @@ -0,0 +1,22 @@ +# 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 +} |