1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-22 13:41:26 +00:00

autoPatchelfHook: do not patch statically linked files

Also speed up quite significantly due less forking.
This commit is contained in:
Jörg Thalheim 2018-09-23 14:45:32 +01:00
parent ef764eb0d8
commit 58a97dfb49
2 changed files with 8 additions and 20 deletions

View file

@ -7,21 +7,7 @@ gatherLibraries() {
addEnvHooks "$targetOffset" gatherLibraries
isExecutable() {
[ "$(file -b -N --mime-type "$1")" = application/x-executable ]
}
findElfs() {
find "$1" -type f -exec "$SHELL" -c '
while [ -n "$1" ]; do
mimeType="$(file -b -N --mime-type "$1")"
if [ "$mimeType" = application/x-executable \
-o "$mimeType" = application/x-pie-executable \
-o "$mimeType" = application/x-sharedlib ]; then
echo "$1"
fi
shift
done
' -- {} +
readelf -h "$1" | grep -q '^ *Type: *EXEC\>'
}
# We cache dependencies so that we don't need to search through all of them on
@ -167,9 +153,12 @@ autoPatchelf() {
# findDependency outside of this, the dependency cache needs to be rebuilt
# from scratch, so keep this in mind if you want to run findDependency
# outside of this function.
findElfs "$prefix" | while read -r elffile; do
autoPatchelfFile "$elffile"
done
while IFS= read -r -d $'\0' file; do
isELF "$file" || continue
# dynamically linked?
readelf -l "$file" | grep -q "^ *INTERP\\>" || continue
autoPatchelfFile "$file"
done < <(find "$prefix" -type f -print0)
}
# XXX: This should ultimately use fixupOutputHooks but we currently don't have

View file

@ -81,8 +81,7 @@ with pkgs;
{ deps = [ autoconf264 automake111x gettext libtool ]; }
../build-support/setup-hooks/autoreconf.sh;
autoPatchelfHook = makeSetupHook
{ name = "auto-patchelf-hook"; deps = [ file ]; }
autoPatchelfHook = makeSetupHook { name = "auto-patchelf-hook"; }
../build-support/setup-hooks/auto-patchelf.sh;
ensureNewerSourcesHook = { year }: makeSetupHook {}