Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 20 lines 624 B view raw
1# This setup hook calls patchelf to automatically remove unneeded 2# directories from the RPATH of every library or executable in every 3# output. 4 5fixupOutputHooks+=('if [ -z "${dontPatchELF-}" ]; then patchELF "$prefix"; fi') 6 7patchELF() { 8 local dir="$1" 9 [ -e "$dir" ] || return 0 10 11 echo "shrinking RPATHs of ELF executables and libraries in $dir" 12 13 local i 14 while IFS= read -r -d $'\0' i; do 15 if [[ "$i" =~ .build-id ]]; then continue; fi 16 if ! isELF "$i"; then continue; fi 17 echo "shrinking $i" 18 patchelf --shrink-rpath "$i" || true 19 done < <(find "$dir" -type f -print0) 20}