lol

Don't try to apply patchelf to non-ELF binaries

+23 -13
+2 -6
pkgs/build-support/setup-hooks/separate-debug-info.sh
··· 13 13 # Find executables and dynamic libraries. 14 14 local i magic 15 15 while IFS= read -r -d $'\0' i; do 16 - # Skip non-ELF files. 17 - exec {fd}< "$i" 18 - read -n 4 -u $fd magic 19 - exec {fd}<&- 20 - if ! [[ "$magic" =~ ELF ]]; then continue; fi 16 + if ! isELF "$i"; then continue; fi 21 17 22 18 # Extract the Build ID. FIXME: there's probably a cleaner way. 23 19 local id="$(readelf -n "$i" | sed 's/.*Build ID: \([0-9a-f]*\).*/\1/; t; d')" ··· 34 30 35 31 # Also a create a symlink <original-name>.debug. 36 32 ln -sfn ".build-id/${id:0:2}/${id:2}.debug" "$dst/../$(basename "$i")" 37 - done < <(find "$prefix" -type f -a \( -perm /0100 -o -name "*.so" -o -name "*.so.*" \) -print0) 33 + done < <(find "$prefix" -type f -print0) 38 34 } 39 35 40 36 # - We might prefer to compress the debug info during link-time already,
+10 -7
pkgs/development/tools/misc/patchelf/setup-hook.sh
··· 5 5 fixupOutputHooks+=('if [ -z "$dontPatchELF" ]; then patchELF "$prefix"; fi') 6 6 7 7 patchELF() { 8 - header "patching ELF executables and libraries in $prefix" 9 - if [ -e "$prefix" ]; then 10 - find "$prefix" \( \ 11 - \( -type f -a -name "*.so*" \) -o \ 12 - \( -type f -a -perm -0100 \) \ 13 - \) -print -exec patchelf --shrink-rpath '{}' \; 14 - fi 8 + header "shrinking RPATHs of ELF executables and libraries in $prefix" 9 + 10 + local i 11 + while IFS= read -r -d $'\0' i; do 12 + if [[ "$i" =~ .build-id ]]; then continue; fi 13 + if ! isELF "$i"; then continue; fi 14 + echo "shrinking $i" 15 + patchelf --shrink-rpath "$i" || true 16 + done < <(find "$prefix" -type f -print0) 17 + 15 18 stopNest 16 19 }
+11
pkgs/stdenv/generic/setup.sh
··· 180 180 } 181 181 182 182 183 + # Return success if the specified file is an ELF object. 184 + isELF() { 185 + local fn="$1" 186 + local magic 187 + exec {fd}< "$fn" 188 + read -n 4 -u $fd magic 189 + exec {fd}<&- 190 + if [[ "$magic" =~ ELF ]]; then return 0; else return 1; fi 191 + } 192 + 193 + 183 194 ###################################################################### 184 195 # Initialisation. 185 196