summary refs log tree commit diff
path: root/pkgs/stdenv/generic/setup.sh
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2015-10-03 13:33:13 +0200
committerVladimír Čunát <vcunat@gmail.com>2015-10-03 13:33:37 +0200
commit5227fb1dd53fcb5918b9342dff4868f4ad68427e (patch)
treed6cd521e3f67944031216a27f740f28f22b73b41 /pkgs/stdenv/generic/setup.sh
parentd6dd3b8bd1eaeeb21dfdb5051cd4732c748ce5d7 (diff)
parent33373d939a19f465228ddede6d38ce9032b5916b (diff)
downloadnixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar
nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar.gz
nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar.bz2
nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar.lz
nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar.xz
nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar.zst
nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.zip
Merge commit staging+systemd into closure-size
Many non-conflict problems weren't (fully) resolved in this commit yet.
Diffstat (limited to 'pkgs/stdenv/generic/setup.sh')
-rw-r--r--pkgs/stdenv/generic/setup.sh80
1 files changed, 44 insertions, 36 deletions
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh
index 1011c4c53480..87e18db90a4b 100644
--- a/pkgs/stdenv/generic/setup.sh
+++ b/pkgs/stdenv/generic/setup.sh
@@ -19,7 +19,7 @@ runHook() {
     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
+        _eval "$hook" "$@"
     done
     return 0
 }
@@ -73,6 +73,35 @@ _eval() {
 
 
 ######################################################################
+# Logging.
+
+nestingLevel=0
+
+startNest() {
+    nestingLevel=$(($nestingLevel + 1))
+    echo -en "\033[$1p"
+}
+
+stopNest() {
+    nestingLevel=$(($nestingLevel - 1))
+    echo -en "\033[q"
+}
+
+header() {
+    startNest "$2"
+    echo "$1"
+}
+
+# Make sure that even when we exit abnormally, the original nesting
+# level is properly restored.
+closeNest() {
+    while [ $nestingLevel -gt 0 ]; do
+        stopNest
+    done
+}
+
+
+######################################################################
 # Error handling.
 
 exitHandler() {
@@ -97,7 +126,7 @@ exitHandler() {
 
         # If the builder had a non-zero exit code and
         # $succeedOnFailure is set, create the file
-        # `$out/nix-support/failed' to signal failure, and exit
+        # ‘$out/nix-support/failed’ to signal failure, and exit
         # normally.  Otherwise, return the original exit code.
         if [ -n "$succeedOnFailure" ]; then
             echo "build failed with exit code $exitCode (ignored)"
@@ -202,7 +231,7 @@ runHook addInputsHook
 
 # Recursively find all build inputs.
 findInputs() {
-    local pkg=$1
+    local pkg="$1"
     local var=$2
     local propagatedBuildInputsFile=$3
 
@@ -214,17 +243,22 @@ findInputs() {
 
     eval $var="'${!var} $pkg '"
 
-    if [ -f $pkg ]; then
-        source $pkg
+    if ! [ -e "$pkg" ]; then
+        echo "build input $pkg does not exist" >&2
+        exit 1
+    fi
+
+    if [ -f "$pkg" ]; then
+        source "$pkg"
     fi
 
-    if [ -f $pkg/nix-support/setup-hook ]; then
-        source $pkg/nix-support/setup-hook
+    if [ -f "$pkg/nix-support/setup-hook" ]; then
+        source "$pkg/nix-support/setup-hook"
     fi
 
-    if [ -f $pkg/nix-support/$propagatedBuildInputsFile ]; then
-        for i in $(cat $pkg/nix-support/$propagatedBuildInputsFile); do
-            findInputs $i $var $propagatedBuildInputsFile
+    if [ -f "$pkg/nix-support/$propagatedBuildInputsFile" ]; then
+        for i in $(cat "$pkg/nix-support/$propagatedBuildInputsFile"); do
+            findInputs "$i" $var $propagatedBuildInputsFile
         done
     fi
 }
@@ -409,32 +443,6 @@ substituteAllInPlace() {
 # What follows is the generic builder.
 
 
-nestingLevel=0
-
-startNest() {
-    nestingLevel=$(($nestingLevel + 1))
-    echo -en "\033[$1p"
-}
-
-stopNest() {
-    nestingLevel=$(($nestingLevel - 1))
-    echo -en "\033[q"
-}
-
-header() {
-    startNest "$2"
-    echo "$1"
-}
-
-# Make sure that even when we exit abnormally, the original nesting
-# level is properly restored.
-closeNest() {
-    while [ $nestingLevel -gt 0 ]; do
-        stopNest
-    done
-}
-
-
 # This function is useful for debugging broken Nix builds.  It dumps
 # all environment variables to a file `env-vars' in the build
 # directory.  If the build fails and the `-K' option is used, you can