From 6b9ccbaf78832521cddf38a318551ec0f0033716 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 18 Apr 2009 22:22:51 +0000 Subject: * setup.sh: turn on nullglob globally. * setup.sh: removed some obsolete features, specifically some that were only used by the old build farm. * addToSearchPath: removed some parameters that weren't used anywhere. svn path=/nixpkgs/branches/stdenv-updates/; revision=15136 --- pkgs/build-support/gcc-wrapper/setup-hook.sh | 6 +- .../interpreters/perl-5.10/setup-hook.sh | 2 +- .../interpreters/perl-5.8/setup-hook.sh | 2 +- .../interpreters/python/2.4/setup-hook.sh | 2 +- .../interpreters/python/2.5/setup-hook.sh | 2 +- .../tools/build-managers/cmake/setup-hook.sh | 6 +- pkgs/development/tools/misc/automake/setup-hook.sh | 2 +- .../development/tools/misc/pkgconfig/setup-hook.sh | 4 +- pkgs/stdenv/generic/setup.sh | 107 +++------------------ 9 files changed, 29 insertions(+), 104 deletions(-) diff --git a/pkgs/build-support/gcc-wrapper/setup-hook.sh b/pkgs/build-support/gcc-wrapper/setup-hook.sh index 60aad0fe4dc67..76167df3c31cf 100644 --- a/pkgs/build-support/gcc-wrapper/setup-hook.sh +++ b/pkgs/build-support/gcc-wrapper/setup-hook.sh @@ -17,13 +17,13 @@ envHooks=(${envHooks[@]} addCVars) # Note: these come *after* $out in the PATH (see setup.sh). if test -n "@gcc@"; then - PATH=$PATH:@gcc@/bin + addToSearchPath PATH @gcc@/bin fi if test -n "@binutils@"; then - PATH=$PATH:@binutils@/bin + addToSearchPath PATH @binutils@/bin fi if test -n "@libc@"; then - PATH=$PATH:@libc@/bin + addToSearchPath PATH @libc@/bin fi diff --git a/pkgs/development/interpreters/perl-5.10/setup-hook.sh b/pkgs/development/interpreters/perl-5.10/setup-hook.sh index 70ce2cf8b4631..d61ec82f4f080 100644 --- a/pkgs/development/interpreters/perl-5.10/setup-hook.sh +++ b/pkgs/development/interpreters/perl-5.10/setup-hook.sh @@ -1,5 +1,5 @@ addPerlLibPath () { - addToSearchPath PERL5LIB /lib/site_perl "" $1 + addToSearchPath PERL5LIB $1/lib/site_perl } envHooks=(${envHooks[@]} addPerlLibPath) diff --git a/pkgs/development/interpreters/perl-5.8/setup-hook.sh b/pkgs/development/interpreters/perl-5.8/setup-hook.sh index 70ce2cf8b4631..d61ec82f4f080 100644 --- a/pkgs/development/interpreters/perl-5.8/setup-hook.sh +++ b/pkgs/development/interpreters/perl-5.8/setup-hook.sh @@ -1,5 +1,5 @@ addPerlLibPath () { - addToSearchPath PERL5LIB /lib/site_perl "" $1 + addToSearchPath PERL5LIB $1/lib/site_perl } envHooks=(${envHooks[@]} addPerlLibPath) diff --git a/pkgs/development/interpreters/python/2.4/setup-hook.sh b/pkgs/development/interpreters/python/2.4/setup-hook.sh index 58b8d1cab760c..8334fbc21a845 100644 --- a/pkgs/development/interpreters/python/2.4/setup-hook.sh +++ b/pkgs/development/interpreters/python/2.4/setup-hook.sh @@ -1,5 +1,5 @@ addPythonPath() { - addToSearchPathWithCustomDelimiter : PYTHONPATH /lib/python2.4/site-packages "" $1 + addToSearchPathWithCustomDelimiter : PYTHONPATH $1/lib/python2.4/site-packages } toPythonPath() { diff --git a/pkgs/development/interpreters/python/2.5/setup-hook.sh b/pkgs/development/interpreters/python/2.5/setup-hook.sh index a11f8cbb484e8..ffcb862a3dec1 100644 --- a/pkgs/development/interpreters/python/2.5/setup-hook.sh +++ b/pkgs/development/interpreters/python/2.5/setup-hook.sh @@ -1,5 +1,5 @@ addPythonPath() { - addToSearchPathWithCustomDelimiter : PYTHONPATH /lib/python2.5/site-packages "" $1 + addToSearchPathWithCustomDelimiter : PYTHONPATH $1/lib/python2.5/site-packages } toPythonPath() { diff --git a/pkgs/development/tools/build-managers/cmake/setup-hook.sh b/pkgs/development/tools/build-managers/cmake/setup-hook.sh index c289272d2a783..6adc4420379f2 100755 --- a/pkgs/development/tools/build-managers/cmake/setup-hook.sh +++ b/pkgs/development/tools/build-managers/cmake/setup-hook.sh @@ -1,8 +1,8 @@ addCMakeParams() { - addToSearchPath CMAKE_INCLUDE_PATH /include "" $1 - addToSearchPath CMAKE_LIBRARY_PATH /lib "" $1 - addToSearchPath CMAKE_MODULE_PATH /share/cmake-@majorVersion@/Modules "" $1 + addToSearchPath CMAKE_INCLUDE_PATH $1/include + addToSearchPath CMAKE_LIBRARY_PATH $1/lib + addToSearchPath CMAKE_MODULE_PATH $1/share/cmake-@majorVersion@/Modules } fixCmakeFiles() diff --git a/pkgs/development/tools/misc/automake/setup-hook.sh b/pkgs/development/tools/misc/automake/setup-hook.sh index 2b12ae3aee08b..156e6ab67128a 100644 --- a/pkgs/development/tools/misc/automake/setup-hook.sh +++ b/pkgs/development/tools/misc/automake/setup-hook.sh @@ -1,5 +1,5 @@ addAclocals () { - addToSearchPathWithCustomDelimiter : ACLOCAL_PATH /share/aclocal "" $1 + addToSearchPathWithCustomDelimiter ACLOCAL_PATH $1/share/aclocal } envHooks=(${envHooks[@]} addAclocals) diff --git a/pkgs/development/tools/misc/pkgconfig/setup-hook.sh b/pkgs/development/tools/misc/pkgconfig/setup-hook.sh index ccb48c129e7c7..ea592b36d11e1 100644 --- a/pkgs/development/tools/misc/pkgconfig/setup-hook.sh +++ b/pkgs/development/tools/misc/pkgconfig/setup-hook.sh @@ -1,6 +1,6 @@ addPkgConfigPath () { - addToSearchPath PKG_CONFIG_PATH /lib/pkgconfig "" $1 - addToSearchPath PKG_CONFIG_PATH /share/pkgconfig "" $1 + addToSearchPath PKG_CONFIG_PATH $1/lib/pkgconfig + addToSearchPath PKG_CONFIG_PATH $1/share/pkgconfig } envHooks=(${envHooks[@]} addPkgConfigPath) diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 599f15f200efb..43fa69b224bdd 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -60,18 +60,14 @@ trap "exitHandler" EXIT addToSearchPathWithCustomDelimiter() { local delimiter=$1 local varName=$2 - local needDir=$3 - local addDir=${4:-$needDir} - local prefix=$5 - if [ -d $prefix$needDir ]; then - if [ -z ${!varName} ]; then - eval export ${varName}=${prefix}$addDir - else - eval export ${varName}=${!varName}${delimiter}${prefix}$addDir - fi + local dir=$3 + if [ -d "$dir" ]; then + eval export ${varName}=${!varName}${!varName:+$delimiter}${dir} fi } +PATH_DELIMITER=':' + addToSearchPath() { addToSearchPathWithCustomDelimiter "${PATH_DELIMITER}" "$@" } @@ -85,11 +81,17 @@ set -e test -z $NIX_GCC && NIX_GCC=@gcc@ +# Wildcard expansions that don't match should expand to an empty list. +# This ensures that, for instance, "for i in *; do ...; done" does the +# right thing. +shopt -s nullglob + + # Set up the initial path. PATH= for i in $NIX_GCC @initialPath@; do if test "$i" = /; then i=; fi - PATH=$PATH${PATH:+:}$i/bin + addToSearchPath PATH $i/bin done if test "$NIX_DEBUG" = "1"; then @@ -99,7 +101,6 @@ fi # Execute the pre-hook. export SHELL=@shell@ -PATH_DELIMITER=':' if test -z "$shell"; then export shell=@shell@ fi @@ -132,15 +133,8 @@ ensureDir() { } installBin() { - ensureDir $out/bin - 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 + ensureDir $out/bin + cp "$@" $out/bin } @@ -184,15 +178,11 @@ done addToEnv() { local pkg=$1 - if test "$ignoreFailedInputs" != "1" -a -e $1/nix-support/failed; then - echo "failed input $1" >&2 - exit 1 - fi - if test -d $1/bin; then - export _PATH=$_PATH${_PATH:+:}$1/bin + addToSearchPath _PATH $1/bin fi + # Run the package-specific hooks set by the setup-hook scripts. for i in "${envHooks[@]}"; do $i $pkg done @@ -219,17 +209,6 @@ if test -z "$NIX_STRIP_DEBUG"; then 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." - -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 # `date' will complain (e.g., `Tue Mar 9 10:01:47 Local time zone must # be set--see zic manual page 2004'). @@ -397,58 +376,6 @@ dumpVars() { } -# Redirect stdout/stderr to a named pipe connected to a `tee' process -# that writes the specified file (and also to our original stdout). -# The original stdout is saved in descriptor 3. -startLog() { - local logFile=${logNr}_$1 - logNr=$((logNr + 1)) - if test "$logPhases" = 1; then - ensureDir $logDir - - exec 3>&1 - - if test "$dontLogThroughTee" != 1; then - # This required named pipes (fifos). - logFifo=$NIX_BUILD_TOP/log_fifo - test -p $logFifo || mkfifo $logFifo - startLogWrite "$logDir/$logFile" "$logFifo" - exec > $logFifo 2>&1 - else - exec > $logDir/$logFile 2>&1 - fi - fi -} - -# Factored into a separate function so that it can be overriden. -startLogWrite() { - tee "$1" < "$2" & - logWriterPid=$! -} - - -if test -z "$logDir"; then - logDir=$out/log -fi - -logNr=0 - -# Restore the original stdout/stderr. -stopLog() { - if test "$logPhases" = 1; then - exec >&3 2>&1 - - # Wait until the tee process has died. Otherwise output from - # different phases may be mixed up. - if test -n "$logWriterPid"; then - wait $logWriterPid - logWriterPid= - rm $logFifo - fi - fi -} - - # Utility function: return the base name of the given path, with the # prefix `HASH-' removed, if present. stripHash() { @@ -823,7 +750,6 @@ genericBuild() { if test "$curPhase" = distPhase -a -z "$doDist"; then continue; fi showPhaseHeader "$curPhase" - startLog "$curPhase" dumpVars # Evaluate the variable named $curPhase if it exists, otherwise the @@ -834,7 +760,6 @@ genericBuild() { cd "${sourceRoot:-.}" fi - stopLog stopNest done -- cgit 1.4.1