3
0
Fork 0
forked from mirrors/nixpkgs

I don't like cluttering up scripts using many ifs.. Do you like an assertEnvExists function ? I think we might want to use it more than twice in the future.

svn path=/nixpkgs/trunk/; revision=9224
This commit is contained in:
Marc Weber 2007-08-31 03:58:40 +00:00
parent b3d955ae2e
commit c383f04b8f

View file

@ -1,4 +1,5 @@
set -e
set -x
test -z $NIX_GCC && NIX_GCC=@gcc@
@ -53,6 +54,13 @@ installBin() {
cp "$@" $out/bin
}
assertEnvExists(){
if test -z "${!1}"; then
msg=${2:-error: assertion failed: env var $1 is required}
echo $msg >&2; exit 1
fi
}
# Called when some build action fails. If $succeedOnFailure is set,
# create the file `$out/nix-support/failed' to signal failure, and
# exit normally. Otherwise, exit with failure.
@ -145,20 +153,15 @@ if test -z "$NIX_STRIP_DEBUG"; then
fi
# Do we know where the store is? This is required for purity checking.
if test -z "$NIX_STORE"; then
echo "Error: you have an old version of Nix that does not set the" \
"NIX_STORE variable. Please upgrade." >&2
exit 1
fi
assertEnvExists NIX_STORE \
"Error: you have an old version of Nix that does not set the
NIX_STORE variable. This is required for purity checking.
Please upgrade."
# We also need to know the root of the build directory for purity checking.
if test -z "$NIX_BUILD_TOP"; then
echo "Error: you have an old version of Nix that does not set the" \
"NIX_BUILD_TOP variable. Please upgrade." >&2
exit 1
fi
assertEnvExists NIX_BUILD_TOP \
"Error: you have an old version of Nix that does not set the
NIX_BUILD_TOP variable. This is required for purity checking.
Please upgrade."
# Set the TZ (timezone) environment variable, otherwise commands like