autoPatchelfHook: Make easier to run autoPatchelf

The autoPatchelf main function which is run against all of the outputs
was pretty much tailored towards this specific setup-hook and was
relying on $prefix to be set globally.

So if you wanted to run autoPatchelf manually - let's say during
buildPhase - you would have needed to run it like this:

  prefix=/some/directory autoPatchelf

This is now more intuitive and all you need to do is run the following:

  autoPatchelf /some/directory

Signed-off-by: aszlig <aszlig@nix.build>
This commit is contained in:
aszlig 2018-11-19 17:18:27 +01:00
parent 3ae0407d3c
commit d03e4ffdbf
No known key found for this signature in database
GPG key ID: 684089CE67EBB691

View file

@ -153,7 +153,7 @@ autoPatchelf() {
# Add all shared objects of the current output path to the start of
# cachedDependencies so that it's choosen first in findDependency.
cachedDependencies+=(
$(find "$prefix" \! -type d \( -name '*.so' -o -name '*.so.*' \))
$(find "$@" \! -type d \( -name '*.so' -o -name '*.so.*' \))
)
local elffile
@ -169,7 +169,7 @@ autoPatchelf() {
LANG=C readelf -l "$file" | grep -q "^ *INTERP\\>" || continue
fi
autoPatchelfFile "$file"
done < <(find "$prefix" -type f -print0)
done < <(find "$@" -type f -print0)
}
# XXX: This should ultimately use fixupOutputHooks but we currently don't have
@ -181,5 +181,5 @@ autoPatchelf() {
# behaviour as fixupOutputHooks because the setup hook for patchelf is run in
# fixupOutput and the postFixup hook runs later.
postFixupHooks+=(
'for output in $outputs; do prefix="${!output}" autoPatchelf; done'
'autoPatchelf $(for output in $outputs; do echo "${!output}"; done)'
)