summary refs log tree commit diff
path: root/pkgs/development/tools
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-18 22:52:44 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-18 22:54:11 +0100
commitd71a4851e8a2ef52f6d806d65822290cdbae8804 (patch)
treee52597e69d0b90f7af724982bf47b4f6207948c4 /pkgs/development/tools
parentbf63de1613396a1a4d1f27fea73f125988d468a7 (diff)
downloadnixlib-d71a4851e8a2ef52f6d806d65822290cdbae8804.tar
nixlib-d71a4851e8a2ef52f6d806d65822290cdbae8804.tar.gz
nixlib-d71a4851e8a2ef52f6d806d65822290cdbae8804.tar.bz2
nixlib-d71a4851e8a2ef52f6d806d65822290cdbae8804.tar.lz
nixlib-d71a4851e8a2ef52f6d806d65822290cdbae8804.tar.xz
nixlib-d71a4851e8a2ef52f6d806d65822290cdbae8804.tar.zst
nixlib-d71a4851e8a2ef52f6d806d65822290cdbae8804.zip
Don't try to apply patchelf to non-ELF binaries
Diffstat (limited to 'pkgs/development/tools')
-rw-r--r--pkgs/development/tools/misc/patchelf/setup-hook.sh17
1 files changed, 10 insertions, 7 deletions
diff --git a/pkgs/development/tools/misc/patchelf/setup-hook.sh b/pkgs/development/tools/misc/patchelf/setup-hook.sh
index a76fbfbd509c..03b6f362a779 100644
--- a/pkgs/development/tools/misc/patchelf/setup-hook.sh
+++ b/pkgs/development/tools/misc/patchelf/setup-hook.sh
@@ -5,12 +5,15 @@
 fixupOutputHooks+=('if [ -z "$dontPatchELF" ]; then patchELF "$prefix"; fi')
 
 patchELF() {
-    header "patching ELF executables and libraries in $prefix"
-    if [ -e "$prefix" ]; then
-        find "$prefix" \( \
-            \( -type f -a -name "*.so*" \) -o \
-            \( -type f -a -perm -0100 \) \
-            \) -print -exec patchelf --shrink-rpath '{}' \;
-    fi
+    header "shrinking RPATHs of ELF executables and libraries in $prefix"
+
+    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 "$prefix" -type f -print0)
+
     stopNest
 }