···11-set -e
11+set -eu
22set -o pipefail
3344: ${outputs:=out}
···1313# code). The hooks for <hookName> are the shell function or variable
1414# <hookName>, and the values of the shell array ‘<hookName>Hooks’.
1515runHook() {
1616+ local oldOpts="$(shopt -po nounset)"
1717+ set -u # May be called from elsewhere, so do `set -u`.
1818+1619 local hookName="$1"
1720 shift
1818- local var="$hookName"
1919- if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi
2121+ local hooksSlice="${hookName%Hook}Hooks[@]"
20222121- local varRef="$var[@]"
2223 local hook
2323- for hook in "_callImplicitHook 0 $hookName" "${!varRef}"; do
2424+ # Hack around old bash being bad and thinking empty arrays are
2525+ # undefined.
2626+ for hook in "_callImplicitHook 0 $hookName" ${!hooksSlice+"${!hooksSlice}"}; do
2427 _eval "$hook" "$@"
2828+ set -u # To balance `_eval`
2529 done
3030+3131+ eval "${oldOpts}"
2632 return 0
2733}
2834···3036# Run all hooks with the specified name, until one succeeds (returns a
3137# zero exit code). If none succeed, return a non-zero exit code.
3238runOneHook() {
3939+ local oldOpts="$(shopt -po nounset)"
4040+ set -u # May be called from elsewhere, so do `set -u`.
4141+3342 local hookName="$1"
3443 shift
3535- local var="$hookName"
3636- if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi
4444+ local hooksSlice="${hookName%Hook}Hooks[@]"
37453838- local varRef="$var[@]"
3939- local hook
4040- for hook in "_callImplicitHook 1 $hookName" "${!varRef}"; do
4646+ local hook ret=1
4747+ # Hack around old bash like above
4848+ for hook in "_callImplicitHook 1 $hookName" ${!hooksSlice+"${!hooksSlice}"}; do
4149 if _eval "$hook" "$@"; then
4242- return 0
5050+ ret=0
5151+ break
4352 fi
5353+ set -u # To balance `_eval`
4454 done
4545- return 1
5555+5656+ eval "${oldOpts}"
5757+ return "$ret"
4658}
47594860···5264# environment variables) and from shell scripts (as functions). If you
5365# want to allow multiple hooks, use runHook instead.
5466_callImplicitHook() {
6767+ set -u
5568 local def="$1"
5669 local hookName="$2"
5770 case "$(type -t "$hookName")" in
5858- (function|alias|builtin) "$hookName";;
5959- (file) source "$hookName";;
7171+ (function|alias|builtin)
7272+ set +u
7373+ "$hookName";;
7474+ (file)
7575+ set +u
7676+ source "$hookName";;
6077 (keyword) :;;
6161- (*) if [ -z "${!hookName}" ]; then return "$def"; else eval "${!hookName}"; fi;;
7878+ (*) if [ -z "${!hookName:-}" ]; then
7979+ return "$def";
8080+ else
8181+ set +u
8282+ eval "${!hookName}"
8383+ fi;;
6284 esac
8585+ # `_eval` expects hook to need nounset disable and leave it
8686+ # disabled anyways, so Ok to to delegate. The alternative of a
8787+ # return trap is no good because it would affect nested returns.
6388}
648965906691# A function wrapper around ‘eval’ that ensures that ‘return’ inside
6767-# hooks exits the hook, not the caller.
9292+# hooks exits the hook, not the caller. Also will only pass args if
9393+# command can take them
6894_eval() {
6969- local code="$1"
7070- shift
7171- if [ "$(type -t "$code")" = function ]; then
7272- eval "$code \"\$@\""
9595+ if [ "$(type -t "$1")" = function ]; then
9696+ set +u
9797+ "$@" # including args
7398 else
7474- eval "$code"
9999+ set +u
100100+ eval "$1"
75101 fi
102102+ # `run*Hook` reenables `set -u`
76103}
7710478105···103130 exitCode="$?"
104131 set +e
105132106106- if [ -n "$showBuildStats" ]; then
133133+ if [ -n "${showBuildStats:-}" ]; then
107134 times > "$NIX_BUILD_TOP/.times"
108135 local -a times=($(cat "$NIX_BUILD_TOP/.times"))
109136 # Print the following statistics:
···114141 echo "build time elapsed: " "${times[@]}"
115142 fi
116143117117- if [ "$exitCode" != 0 ]; then
144144+ if (( "$exitCode" != 0 )); then
118145 runHook failureHook
119146120147 # If the builder had a non-zero exit code and
121148 # $succeedOnFailure is set, create the file
122149 # ‘$out/nix-support/failed’ to signal failure, and exit
123150 # normally. Otherwise, return the original exit code.
124124- if [ -n "$succeedOnFailure" ]; then
151151+ if [ -n "${succeedOnFailure:-}" ]; then
125152 echo "build failed with exit code $exitCode (ignored)"
126153 mkdir -p "$out/nix-support"
127154 printf "%s" "$exitCode" > "$out/nix-support/failed"
···147174 local varName="$2"
148175 local dir="$3"
149176 if [ -d "$dir" ]; then
150150- export "${varName}=${!varName}${!varName:+$delimiter}${dir}"
177177+ export "${varName}=${!varName:+${!varName}${delimiter}}${dir}"
151178 fi
152179}
153180···171198# The function is used in multiple-outputs.sh hook,
172199# so it is defined here but tried after the hook.
173200_addRpathPrefix() {
174174- if [ "$NIX_NO_SELF_RPATH" != 1 ]; then
201201+ if [ "${NIX_NO_SELF_RPATH:-0}" != 1 ]; then
175202 export NIX_LDFLAGS="-rpath $1/lib $NIX_LDFLAGS"
176176- if [ -n "$NIX_LIB64_IN_SELF_RPATH" ]; then
203203+ if [ -n "${NIX_LIB64_IN_SELF_RPATH:-}" ]; then
177204 export NIX_LDFLAGS="-rpath $1/lib64 $NIX_LDFLAGS"
178205 fi
179179- if [ -n "$NIX_LIB32_IN_SELF_RPATH" ]; then
206206+ if [ -n "${NIX_LIB32_IN_SELF_RPATH:-}" ]; then
180207 export NIX_LDFLAGS="-rpath $1/lib32 $NIX_LDFLAGS"
181208 fi
182209 fi
···242269 addToSearchPath PATH "$i/bin"
243270done
244271245245-if [ "$NIX_DEBUG" = 1 ]; then
272272+if [ "${NIX_DEBUG:-}" = 1 ]; then
246273 echo "initial path: $PATH"
247274fi
248275249276250277# Check that the pre-hook initialised SHELL.
251251-if [ -z "$SHELL" ]; then echo "SHELL not set"; exit 1; fi
278278+if [ -z "${SHELL:-}" ]; then echo "SHELL not set"; exit 1; fi
252279BASH="$SHELL"
253280export CONFIG_SHELL="$SHELL"
254281···259286260287261288# Execute the pre-hook.
262262-if [ -z "$shell" ]; then export shell="$SHELL"; fi
289289+if [ -z "${shell:-}" ]; then export shell="$SHELL"; fi
263290runHook preHook
264291265292···279306 # nix-shell doesn't use impure bash. This should replace the O(n)
280307 # case with an O(1) hash map lookup, assuming bash is implemented
281308 # well :D.
282282- local varRef="$var[*]"
283283-284284- case "${!varRef}" in
309309+ local varSlice="$var[*]"
310310+ # ${..-} to hack around old bash empty array problem
311311+ case "${!varSlice-}" in
285312 *" $pkg "*) return 0 ;;
286313 esac
314314+ unset -v varSlice
287315288316 eval "$var"'+=("$pkg")'
289317···293321 fi
294322295323 if [ -f "$pkg" ]; then
324324+ local oldOpts="$(shopt -po nounset)"
325325+ set +u
296326 source "$pkg"
327327+ eval "$oldOpts"
297328 fi
298329299330 if [ -d "$pkg/bin" ]; then
···301332 fi
302333303334 if [ -f "$pkg/nix-support/setup-hook" ]; then
335335+ local oldOpts="$(shopt -po nounset)"
336336+ set +u
304337 source "$pkg/nix-support/setup-hook"
338338+ eval "$oldOpts"
305339 fi
306340307341 if [ -f "$pkg/nix-support/$propagatedBuildInputsFile" ]; then
···312346 fi
313347}
314348315315-if [ -z "$crossConfig" ]; then
349349+declare -a nativePkgs crossPkgs
350350+if [ -z "${crossConfig:-}" ]; then
316351 # Not cross-compiling - both buildInputs (and variants like propagatedBuildInputs)
317352 # are handled identically to nativeBuildInputs
318318- declare -a nativePkgs
319319- for i in $nativeBuildInputs $buildInputs \
320320- $defaultNativeBuildInputs $defaultBuildInputs \
321321- $propagatedNativeBuildInputs $propagatedBuildInputs; do
353353+ for i in ${nativeBuildInputs:-} ${buildInputs:-} \
354354+ ${defaultNativeBuildInputs:-} ${defaultBuildInputs:-} \
355355+ ${propagatedNativeBuildInputs:-} ${propagatedBuildInputs:-}; do
322356 findInputs "$i" nativePkgs propagated-native-build-inputs
323357 done
324358else
325325- declare -a crossPkgs
326326- for i in $buildInputs $defaultBuildInputs $propagatedBuildInputs; do
359359+ for i in ${buildInputs:-} ${defaultBuildInputs:-} ${propagatedBuildInputs:-}; do
327360 findInputs "$i" crossPkgs propagated-build-inputs
328361 done
329362330363 declare -a nativePkgs
331331- for i in $nativeBuildInputs $defaultNativeBuildInputs $propagatedNativeBuildInputs; do
364364+ for i in ${nativeBuildInputs:-} ${defaultNativeBuildInputs:-} ${propagatedNativeBuildInputs:-}; do
332365 findInputs "$i" nativePkgs propagated-native-build-inputs
333366 done
334367fi
···355388 runHook envHook "$pkg"
356389}
357390358358-for i in "${nativePkgs[@]}"; do
391391+# Old bash empty array hack
392392+for i in ${nativePkgs+"${nativePkgs[@]}"}; do
359393 _addToNativeEnv "$i"
360394done
361395···367401 runHook crossEnvHook "$pkg"
368402}
369403370370-for i in "${crossPkgs[@]}"; do
404404+# Old bash empty array hack
405405+for i in ${crossPkgs+"${crossPkgs[@]}"}; do
371406 _addToCrossEnv "$i"
372407done
373408···384419# Set the prefix. This is generally $out, but it can be overriden,
385420# for instance if we just want to perform a test build/install to a
386421# temporary location and write a build report to $out.
387387-if [ -z "$prefix" ]; then
422422+if [ -z "${prefix:-}" ]; then
388423 prefix="$out";
389424fi
390425391391-if [ "$useTempPrefix" = 1 ]; then
426426+if [ "${useTempPrefix:-}" = 1 ]; then
392427 prefix="$NIX_BUILD_TOP/tmp_prefix";
393428fi
394429395430396396-PATH=$_PATH${_PATH:+:}$PATH
397397-if [ "$NIX_DEBUG" = 1 ]; then
431431+PATH="${_PATH-}${_PATH:+${PATH:+:}}$PATH"
432432+if [ "${NIX_DEBUG:-}" = 1 ]; then
398433 echo "final path: $PATH"
399434fi
400435···423458# Prevent OpenSSL-based applications from using certificates in
424459# /etc/ssl.
425460# Leave it in shells for convenience.
426426-if [ -z "$SSL_CERT_FILE" ] && [ -z "$IN_NIX_SHELL" ]; then
461461+if [ -z "${SSL_CERT_FILE:-}" ] && [ -z "${IN_NIX_SHELL:-}" ]; then
427462 export SSL_CERT_FILE=/no-cert-file.crt
428463fi
429464···508543509544 # Select all environment variables that start with a lowercase character.
510545 for varName in $(env | sed -e $'s/^\([a-z][^= \t]*\)=.*/\\1/; t \n d'); do
511511- if [ "$NIX_DEBUG" = "1" ]; then
546546+ if [ "${NIX_DEBUG:-}" = "1" ]; then
512547 echo "@${varName}@ -> '${!varName}'"
513548 fi
514549 args+=("--subst-var" "$varName")
···535570# then go to the build directory and source in `env-vars' to reproduce
536571# the environment used for building.
537572dumpVars() {
538538- if [ "$noDumpEnvVars" != 1 ]; then
573573+ if [ "${noDumpEnvVars:-0}" != 1 ]; then
539574 export > "$NIX_BUILD_TOP/env-vars" || true
540575 fi
541576}
···600635unpackPhase() {
601636 runHook preUnpack
602637603603- if [ -z "$srcs" ]; then
604604- if [ -z "$src" ]; then
638638+ if [ -z "${srcs:-}" ]; then
639639+ if [ -z "${src:-}" ]; then
605640 # shellcheck disable=SC2016
606641 echo 'variable $src or $srcs should point to the source'
607642 exit 1
···626661 done
627662628663 # Find the source directory.
629629- if [ -n "$setSourceRoot" ]; then
664664+665665+ # set to empty if unset
666666+ : ${sourceRoot=}
667667+668668+ if [ -n "${setSourceRoot:-}" ]; then
630669 runOneHook setSourceRoot
631670 elif [ -z "$sourceRoot" ]; then
632632- sourceRoot=
633671 for i in *; do
634672 if [ -d "$i" ]; then
635673 case $dirsBefore in
···657695 # By default, add write permission to the sources. This is often
658696 # necessary when sources have been copied from other store
659697 # locations.
660660- if [ "$dontMakeSourcesWritable" != 1 ]; then
698698+ if [ "${dontMakeSourcesWritable:-0}" != 1 ]; then
661699 chmod -R u+w "$sourceRoot"
662700 fi
663701···668706patchPhase() {
669707 runHook prePatch
670708671671- for i in $patches; do
709709+ for i in ${patches:-}; do
672710 header "applying patch $i" 3
673711 local uncompress=cat
674712 case "$i" in
···702740configurePhase() {
703741 runHook preConfigure
704742743743+ # set to empty if unset
744744+ : ${configureScript=}
745745+ : ${configureFlags=}
746746+705747 if [[ -z "$configureScript" && -x ./configure ]]; then
706748 configureScript=./configure
707749 fi
708750709709- if [ -z "$dontFixLibtool" ]; then
751751+ if [ -z "${dontFixLibtool:-}" ]; then
710752 local i
711753 find . -iname "ltmain.sh" -print0 | while IFS='' read -r -d '' i; do
712754 echo "fixing libtool script $i"
···714756 done
715757 fi
716758717717- if [[ -z "$dontAddPrefix" && -n "$prefix" ]]; then
759759+ if [[ -z "${dontAddPrefix:-}" && -n "$prefix" ]]; then
718760 configureFlags="${prefixKey:---prefix=}$prefix $configureFlags"
719761 fi
720762721763 # Add --disable-dependency-tracking to speed up some builds.
722722- if [ -z "$dontAddDisableDepTrack" ]; then
764764+ if [ -z "${dontAddDisableDepTrack:-}" ]; then
723765 if [ -f "$configureScript" ] && grep -q dependency-tracking "$configureScript"; then
724766 configureFlags="--disable-dependency-tracking $configureFlags"
725767 fi
726768 fi
727769728770 # By default, disable static builds.
729729- if [ -z "$dontDisableStatic" ]; then
771771+ if [ -z "${dontDisableStatic:-}" ]; then
730772 if [ -f "$configureScript" ] && grep -q enable-static "$configureScript"; then
731773 configureFlags="--disable-static $configureFlags"
732774 fi
733775 fi
734776735777 if [ -n "$configureScript" ]; then
778778+ # Old bash empty array hack
736779 # shellcheck disable=SC2086
737737- local flagsArray=($configureFlags "${configureFlagsArray[@]}")
780780+ local flagsArray=(
781781+ $configureFlags ${configureFlagsArray+"${configureFlagsArray[@]}"}
782782+ )
738783 echoCmd 'configure flags' "${flagsArray[@]}"
739784 # shellcheck disable=SC2086
740785 $configureScript "${flagsArray[@]}"
···750795buildPhase() {
751796 runHook preBuild
752797753753- if [[ -z "$makeFlags" && ! ( -n "$makefile" || -e Makefile || -e makefile || -e GNUmakefile ) ]]; then
798798+ # set to empty if unset
799799+ : ${makeFlags=}
800800+801801+ if [[ -z "$makeFlags" && ! ( -n "${makefile:-}" || -e Makefile || -e makefile || -e GNUmakefile ) ]]; then
754802 echo "no Makefile, doing nothing"
755803 else
756804 # See https://github.com/NixOS/nixpkgs/pull/1354#issuecomment-31260409
757805 makeFlags="SHELL=$SHELL $makeFlags"
758806807807+ # Old bash empty array hack
759808 # shellcheck disable=SC2086
760760- local flagsArray=( \
761761- ${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} \
762762- $makeFlags "${makeFlagsArray[@]}" \
763763- $buildFlags "${buildFlagsArray[@]}")
809809+ local flagsArray=(
810810+ ${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}
811811+ $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
812812+ $buildFlags ${buildFlagsArray+"${buildFlagsArray[@]}"}
813813+ )
764814765815 echoCmd 'build flags' "${flagsArray[@]}"
766816 make ${makefile:+-f $makefile} "${flagsArray[@]}"
···774824checkPhase() {
775825 runHook preCheck
776826827827+ # Old bash empty array hack
777828 # shellcheck disable=SC2086
778778- local flagsArray=( \
779779- ${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} \
780780- $makeFlags "${makeFlagsArray[@]}" \
781781- ${checkFlags:-VERBOSE=y} "${checkFlagsArray[@]}" ${checkTarget:-check})
829829+ local flagsArray=(
830830+ ${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}
831831+ $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
832832+ ${checkFlags:-VERBOSE=y} ${checkFlagsArray+"${checkFlagsArray[@]}"}
833833+ ${checkTarget:-check}
834834+ )
782835783836 echoCmd 'check flags' "${flagsArray[@]}"
784837 make ${makefile:+-f $makefile} "${flagsArray[@]}"
···797850798851 installTargets="${installTargets:-install}"
799852853853+ # Old bash empty array hack
800854 # shellcheck disable=SC2086
801801- local flagsArray=( $installTargets \
802802- $makeFlags "${makeFlagsArray[@]}" \
803803- $installFlags "${installFlagsArray[@]}")
855855+ local flagsArray=(
856856+ $installTargets
857857+ $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
858858+ $installFlags ${installFlagsArray+"${installFlagsArray[@]}"}
859859+ )
804860805861 echoCmd 'install flags' "${flagsArray[@]}"
806862 make ${makefile:+-f $makefile} "${flagsArray[@]}"
···830886831887 # Propagate build inputs and setup hook into the development output.
832888833833- if [ -z "$crossConfig" ]; then
889889+ if [ -z "${crossConfig:-}" ]; then
834890 # Not cross-compiling - propagatedBuildInputs are handled identically to propagatedNativeBuildInputs
835891 local propagated="$propagatedNativeBuildInputs"
836836- if [ -n "$propagatedBuildInputs" ]; then
892892+ if [ -n "${propagatedBuildInputs:-}" ]; then
837893 propagated+="${propagated:+ }$propagatedBuildInputs"
838894 fi
839839- if [ -n "$propagated" ]; then
895895+ if [ -n "${propagated:-}" ]; then
840896 mkdir -p "${!outputDev}/nix-support"
841897 # shellcheck disable=SC2086
842898 printWords $propagated > "${!outputDev}/nix-support/propagated-native-build-inputs"
843899 fi
844900 else
845845- if [ -n "$propagatedBuildInputs" ]; then
901901+ if [ -n "${propagatedBuildInputs:-}" ]; then
846902 mkdir -p "${!outputDev}/nix-support"
847903 # shellcheck disable=SC2086
848904 printWords $propagatedBuildInputs > "${!outputDev}/nix-support/propagated-build-inputs"
849905 fi
850906851851- if [ -n "$propagatedNativeBuildInputs" ]; then
907907+ if [ -n "${propagatedNativeBuildInputs:-}" ]; then
852908 mkdir -p "${!outputDev}/nix-support"
853909 # shellcheck disable=SC2086
854910 printWords $propagatedNativeBuildInputs > "${!outputDev}/nix-support/propagated-native-build-inputs"
855911 fi
856912 fi
857913858858- if [ -n "$setupHook" ]; then
914914+ if [ -n "${setupHook:-}" ]; then
859915 mkdir -p "${!outputDev}/nix-support"
860916 substituteAll "$setupHook" "${!outputDev}/nix-support/setup-hook"
861917 fi
862918863919 # Propagate user-env packages into the output with binaries, TODO?
864920865865- if [ -n "$propagatedUserEnvPkgs" ]; then
921921+ if [ -n "${propagatedUserEnvPkgs:-}" ]; then
866922 mkdir -p "${!outputBin}/nix-support"
867923 # shellcheck disable=SC2086
868924 printWords $propagatedUserEnvPkgs > "${!outputBin}/nix-support/propagated-user-env-packages"
···875931installCheckPhase() {
876932 runHook preInstallCheck
877933934934+ # Old bash empty array hack
878935 # shellcheck disable=SC2086
879879- local flagsArray=( \
880880- ${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} \
881881- $makeFlags "${makeFlagsArray[@]}" \
882882- $installCheckFlags "${installCheckFlagsArray[@]}" ${installCheckTarget:-installcheck})
936936+ local flagsArray=(
937937+ ${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}
938938+ $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
939939+ $installCheckFlags ${installCheckFlagsArray+"${installCheckFlagsArray[@]}"}
940940+ ${installCheckTarget:-installcheck}
941941+ )
883942884943 echoCmd 'installcheck flags' "${flagsArray[@]}"
885944 make ${makefile:+-f $makefile} "${flagsArray[@]}"
···892951distPhase() {
893952 runHook preDist
894953954954+ # Old bash empty array hack
895955 # shellcheck disable=SC2086
896896- local flagsArray=($distFlags "${distFlagsArray[@]}" ${distTarget:-dist})
956956+ local flagsArray=(
957957+ $distFlags ${distFlagsArray+"${distFlagsArray[@]}"} ${distTarget:-dist}
958958+ )
897959898960 echo 'dist flags: %q' "${flagsArray[@]}"
899961 make ${makefile:+-f $makefile} "${flagsArray[@]}"
900962901901- if [ "$dontCopyDist" != 1 ]; then
963963+ if [ "${dontCopyDist:-0}" != 1 ]; then
902964 mkdir -p "$out/tarballs"
903965904966 # Note: don't quote $tarballs, since we explicitly permit
···928990929991930992genericBuild() {
931931- if [ -f "$buildCommandPath" ]; then
932932- . "$buildCommandPath"
993993+ if [ -f "${buildCommandPath:-}" ]; then
994994+ local oldOpts="$(shopt -po nounset)"
995995+ set +u
996996+ source "$buildCommandPath"
997997+ eval "$oldOpts"
933998 return
934999 fi
935935- if [ -n "$buildCommand" ]; then
10001000+ if [ -n "${buildCommand:-}" ]; then
10011001+ local oldOpts="$(shopt -po nounset)"
10021002+ set +u
9361003 eval "$buildCommand"
10041004+ eval "$oldOpts"
9371005 return
9381006 fi
9391007940940- if [ -z "$phases" ]; then
941941- phases="$prePhases unpackPhase patchPhase $preConfigurePhases \
942942- configurePhase $preBuildPhases buildPhase checkPhase \
943943- $preInstallPhases installPhase $preFixupPhases fixupPhase installCheckPhase \
944944- $preDistPhases distPhase $postPhases";
10081008+ if [ -z "${phases:-}" ]; then
10091009+ phases="${prePhases:-} unpackPhase patchPhase ${preConfigurePhases:-} \
10101010+ configurePhase ${preBuildPhases:-} buildPhase checkPhase \
10111011+ ${preInstallPhases:-} installPhase ${preFixupPhases:-} fixupPhase installCheckPhase \
10121012+ ${preDistPhases:-} distPhase ${postPhases:-}";
9451013 fi
94610149471015 for curPhase in $phases; do
948948- if [[ "$curPhase" = buildPhase && -n "$dontBuild" ]]; then continue; fi
949949- if [[ "$curPhase" = checkPhase && -z "$doCheck" ]]; then continue; fi
950950- if [[ "$curPhase" = installPhase && -n "$dontInstall" ]]; then continue; fi
951951- if [[ "$curPhase" = fixupPhase && -n "$dontFixup" ]]; then continue; fi
952952- if [[ "$curPhase" = installCheckPhase && -z "$doInstallCheck" ]]; then continue; fi
953953- if [[ "$curPhase" = distPhase && -z "$doDist" ]]; then continue; fi
10161016+ if [[ "$curPhase" = buildPhase && -n "${dontBuild:-}" ]]; then continue; fi
10171017+ if [[ "$curPhase" = checkPhase && -z "${doCheck:-}" ]]; then continue; fi
10181018+ if [[ "$curPhase" = installPhase && -n "${dontInstall:-}" ]]; then continue; fi
10191019+ if [[ "$curPhase" = fixupPhase && -n "${dontFixup:-}" ]]; then continue; fi
10201020+ if [[ "$curPhase" = installCheckPhase && -z "${doInstallCheck:-}" ]]; then continue; fi
10211021+ if [[ "$curPhase" = distPhase && -z "${doDist:-}" ]]; then continue; fi
9541022955955- if [[ -n "$tracePhases" ]]; then
10231023+ if [[ -n "${tracePhases:-}" ]]; then
9561024 echo
9571025 echo "@ phase-started $out $curPhase"
9581026 fi
···96210309631031 # Evaluate the variable named $curPhase if it exists, otherwise the
9641032 # function named $curPhase.
10331033+ local oldOpts="$(shopt -po nounset)"
10341034+ set +u
9651035 eval "${!curPhase:-$curPhase}"
10361036+ eval "$oldOpts"
96610379671038 if [ "$curPhase" = unpackPhase ]; then
9681039 cd "${sourceRoot:-.}"
9691040 fi
9701041971971- if [ -n "$tracePhases" ]; then
10421042+ if [ -n "${tracePhases:-}" ]; then
9721043 echo
9731044 echo "@ phase-succeeded $out $curPhase"
9741045 fi
···987105898810599891060dumpVars
10611061+10621062+# Disable nounset for nix-shell.
10631063+set +u