about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2018-11-19 17:36:22 +0100
committeraszlig <aszlig@nix.build>2018-11-20 00:07:38 +0100
commite4fbb244ee313a3003144e8e148341c9e5c67295 (patch)
treeac6001e769e169a60c2b868bed93aa3f6c7d9d50 /pkgs/build-support
parentd03e4ffdbf9849f7e928c7a95be76aac69780c55 (diff)
downloadnixlib-e4fbb244ee313a3003144e8e148341c9e5c67295.tar
nixlib-e4fbb244ee313a3003144e8e148341c9e5c67295.tar.gz
nixlib-e4fbb244ee313a3003144e8e148341c9e5c67295.tar.bz2
nixlib-e4fbb244ee313a3003144e8e148341c9e5c67295.tar.lz
nixlib-e4fbb244ee313a3003144e8e148341c9e5c67295.tar.xz
nixlib-e4fbb244ee313a3003144e8e148341c9e5c67295.tar.zst
nixlib-e4fbb244ee313a3003144e8e148341c9e5c67295.zip
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>
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/setup-hooks/auto-patchelf.sh11
1 files changed, 8 insertions, 3 deletions
diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/setup-hooks/auto-patchelf.sh
index 59e9a933211f..62348d71ed05 100644
--- a/pkgs/build-support/setup-hooks/auto-patchelf.sh
+++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh
@@ -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
+')