summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-07-08 13:47:09 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-09 12:45:53 +0200
commit2def8e74990d89bd91b8943c00110027a1f5fafa (patch)
treedd6769810db26cae6d8f3d82288f437985c81e61
parente3875297fac671f20feb803306e7c55789ac749e (diff)
downloadnixpkgs-2def8e74990d89bd91b8943c00110027a1f5fafa.tar
nixpkgs-2def8e74990d89bd91b8943c00110027a1f5fafa.tar.gz
nixpkgs-2def8e74990d89bd91b8943c00110027a1f5fafa.tar.bz2
nixpkgs-2def8e74990d89bd91b8943c00110027a1f5fafa.tar.lz
nixpkgs-2def8e74990d89bd91b8943c00110027a1f5fafa.tar.xz
nixpkgs-2def8e74990d89bd91b8943c00110027a1f5fafa.tar.zst
nixpkgs-2def8e74990d89bd91b8943c00110027a1f5fafa.zip
Remove addHook
Just use bash arrays directly. I.e.

  addHook preConfigure myPreConfigure

is now

  preConfigureHooks+=(myPreConfigure)
-rw-r--r--pkgs/build-support/setup-hooks/compress-man-pages.sh2
-rw-r--r--pkgs/build-support/setup-hooks/patch-shebangs.sh2
-rw-r--r--pkgs/build-support/setup-hooks/strip.sh2
-rw-r--r--pkgs/development/tools/misc/patchelf/setup-hook.sh2
-rw-r--r--pkgs/stdenv/generic/setup.sh27
-rw-r--r--pkgs/tools/archivers/unzip/setup-hook.sh2
6 files changed, 14 insertions, 23 deletions
diff --git a/pkgs/build-support/setup-hooks/compress-man-pages.sh b/pkgs/build-support/setup-hooks/compress-man-pages.sh
index 74c565ebffc..1dd9788419b 100644
--- a/pkgs/build-support/setup-hooks/compress-man-pages.sh
+++ b/pkgs/build-support/setup-hooks/compress-man-pages.sh
@@ -1,4 +1,4 @@
-addHook fixupOutput 'if [ -z "$dontGzipMan" ]; then compressManPages "$prefix"; fi'
+fixupOutputHooks+=('if [ -z "$dontGzipMan" ]; then compressManPages "$prefix"; fi')
 
 compressManPages() {
     local dir="$1"
diff --git a/pkgs/build-support/setup-hooks/patch-shebangs.sh b/pkgs/build-support/setup-hooks/patch-shebangs.sh
index 6b42291358d..5a7f23b2d81 100644
--- a/pkgs/build-support/setup-hooks/patch-shebangs.sh
+++ b/pkgs/build-support/setup-hooks/patch-shebangs.sh
@@ -5,7 +5,7 @@
 # rewritten to /nix/store/<hash>/bin/python.  Interpreters that are
 # already in the store are left untouched.
 
-addHook fixupOutput 'if [ -z "$dontPatchShebangs" ]; then patchShebangs "$prefix"; fi'
+fixupOutputHooks+=('if [ -z "$dontPatchShebangs" ]; then patchShebangs "$prefix"; fi')
 
 patchShebangs() {
     local dir="$1"
diff --git a/pkgs/build-support/setup-hooks/strip.sh b/pkgs/build-support/setup-hooks/strip.sh
index 1815297cb6d..6860c9b9cb9 100644
--- a/pkgs/build-support/setup-hooks/strip.sh
+++ b/pkgs/build-support/setup-hooks/strip.sh
@@ -1,6 +1,6 @@
 # This setup hook strips libraries and executables in the fixup phase.
 
-addHook fixupOutput _doStrip
+fixupOutputHooks+=(_doStrip)
 
 _doStrip() {
     if [ -z "$dontStrip" ]; then
diff --git a/pkgs/development/tools/misc/patchelf/setup-hook.sh b/pkgs/development/tools/misc/patchelf/setup-hook.sh
index 6bc918a4610..b0d37b73e2b 100644
--- a/pkgs/development/tools/misc/patchelf/setup-hook.sh
+++ b/pkgs/development/tools/misc/patchelf/setup-hook.sh
@@ -2,7 +2,7 @@
 # directories from the RPATH of every library or executable in every
 # output.
 
-addHook fixupOutput 'if [ -z "$dontPatchELF" ]; then patchELF "$prefix"; fi'
+fixupOutputHooks+=('if [ -z "$dontPatchELF" ]; then patchELF "$prefix"; fi')
 
 patchELF() {
     header "patching ELF executables and libraries in $prefix"
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh
index 6ed94673ae7..cdebf6e4b27 100644
--- a/pkgs/stdenv/generic/setup.sh
+++ b/pkgs/stdenv/generic/setup.sh
@@ -7,24 +7,15 @@ set -e
 # Hook handling.
 
 
-# Add the specified shell code to the named hook, e.g. ‘addHook
-# preConfigure "rm ./foo; touch ./bar"’.
-addHook() {
-    local hookName="$1"
-    local hookCode="$2"
-    eval "_${hookName}_hooks+=(\"\$hookCode\")"
-}
-
-
 # Run all hooks with the specified name in the order in which they
 # were added, stopping if any fails (returns a non-zero exit
-# code). Hooks are added using ‘addHooks <hookName> <code>’, or
-# implicitly by defining a shell function or variable <hookName>. Note
-# that the latter takes precedence over hooks added via ‘addHooks’.
+# code). The hooks for <hookName> are the shell function or variable
+# <hookName>, and the values of the shell array ‘<hookName>Hooks’.
 runHook() {
     local hookName="$1"
-    local var="_${hookName}_hooks"
-    eval "local -a dummy=(\"\${_${hookName}_hooks[@]}\")"
+    local var="$hookName"
+    if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi
+    eval "local -a dummy=(\"\${$var[@]}\")"
     for hook in "_callImplicitHook 0 $hookName" "${dummy[@]}"; do
         if ! _eval "$hook"; then return 1; fi
     done
@@ -36,8 +27,9 @@ runHook() {
 # zero exit code). If none succeed, return a non-zero exit code.
 runOneHook() {
     local hookName="$1"
-    local var="_${hookName}_hooks"
-    eval "local -a dummy=(\"\${_${hookName}_hooks[@]}\")"
+    local var="$hookName"
+    if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi
+    eval "local -a dummy=(\"\${$var[@]}\")"
     for hook in "_callImplicitHook 1 $hookName" "${dummy[@]}"; do
         if _eval "$hook"; then
             return 0
@@ -465,7 +457,7 @@ stripHash() {
 }
 
 
-addHook unpackCmd _defaultUnpack
+unpackCmdHooks+=(_defaultUnpack)
 _defaultUnpack() {
     if [ -d "$curSrc" ]; then
 
@@ -856,7 +848,6 @@ genericBuild() {
 
 
 # Execute the post-hooks.
-for i in "${postHooks[@]}"; do $i; done
 runHook postHook
 
 
diff --git a/pkgs/tools/archivers/unzip/setup-hook.sh b/pkgs/tools/archivers/unzip/setup-hook.sh
index 47894ded023..4cad0fe7e91 100644
--- a/pkgs/tools/archivers/unzip/setup-hook.sh
+++ b/pkgs/tools/archivers/unzip/setup-hook.sh
@@ -1,4 +1,4 @@
-addHook unpackCmd _tryUnzip
+unpackCmdHooks+=(_tryUnzip)
 _tryUnzip() {
     if ! [[ "foo.zip" =~ \.zip$ ]]; then return 1; fi
     unzip -qq "$curSrc"