autoPatchelfHook: Allow to prevent automatic run

If you want to only run autoPatchelf on a specific path and leave
everything else alone, we now have a $dontAutoPatchelf environment
variable, which causes the postFixup hook to not run at all.

The name "dontAutoPatchelf" probably is a bit weird in conjunction with
putting "autoPatchelfHook" in nativeBuildInputs, but unless someone
comes up with a better name I keep it that way because it's consistent
with all the other dontStrip, dontPatchShebangs, dontPatchELF and
whatnot.

A specific example where this is needed is when building the Android SDK
emulator, which contains a few ARM binaries in subdirectories that
should not be patched. If we were to run autoPatchelf on all outputs
unconditionally we'd run into errors because some ARM libraries couldn't
be found.

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

View file

@ -180,6 +180,11 @@ autoPatchelf() {
# So what we do here is basically run in postFixup and emulate the same
# behaviour as fixupOutputHooks because the setup hook for patchelf is run in
# fixupOutput and the postFixup hook runs later.
postFixupHooks+=(
'autoPatchelf $(for output in $outputs; do echo "${!output}"; done)'
)
postFixupHooks+=('
if [ -z "$dontAutoPatchelf" ]; then
autoPatchelf $(for output in $outputs; do
[ -e "${!output}" ] || continue
echo "${!output}"
done)
fi
')