diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2008-02-13 14:23:09 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2008-02-13 14:23:09 +0000 |
commit | 5f45fb3ae986119b4360613901a1c033a2ee327e (patch) | |
tree | 08448fced019fe7676f255cd13c2ea228425876d /pkgs/stdenv | |
parent | 3db3e079afaaae281124ee9ff1b34df3fa197824 (diff) | |
download | nixlib-5f45fb3ae986119b4360613901a1c033a2ee327e.tar nixlib-5f45fb3ae986119b4360613901a1c033a2ee327e.tar.gz nixlib-5f45fb3ae986119b4360613901a1c033a2ee327e.tar.bz2 nixlib-5f45fb3ae986119b4360613901a1c033a2ee327e.tar.lz nixlib-5f45fb3ae986119b4360613901a1c033a2ee327e.tar.xz nixlib-5f45fb3ae986119b4360613901a1c033a2ee327e.tar.zst nixlib-5f45fb3ae986119b4360613901a1c033a2ee327e.zip |
* substitute() in stdenv: use the replace program instead of awful
sed hackery. * Some indentation fixes in setup.sh. svn path=/nixpkgs/branches/stdenv-updates/; revision=10658
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r-- | pkgs/stdenv/common-path.nix | 1 | ||||
-rw-r--r-- | pkgs/stdenv/cygwin/prehook.sh | 2 | ||||
-rw-r--r-- | pkgs/stdenv/generic/builder.sh | 25 | ||||
-rw-r--r-- | pkgs/stdenv/generic/setup.sh | 70 |
4 files changed, 47 insertions, 51 deletions
diff --git a/pkgs/stdenv/common-path.nix b/pkgs/stdenv/common-path.nix index 0ad0d83255be..3b267a543c66 100644 --- a/pkgs/stdenv/common-path.nix +++ b/pkgs/stdenv/common-path.nix @@ -11,4 +11,5 @@ pkgs.gnumake pkgs.bash pkgs.patch + pkgs.replace ] diff --git a/pkgs/stdenv/cygwin/prehook.sh b/pkgs/stdenv/cygwin/prehook.sh index 673640c0d4a2..b2ada869b290 100644 --- a/pkgs/stdenv/cygwin/prehook.sh +++ b/pkgs/stdenv/cygwin/prehook.sh @@ -3,3 +3,5 @@ export NIX_ENFORCE_PURITY= if test -z "$cygwinConfigureEnableShared"; then export configureFlags="$configureFlags --disable-shared" fi + +PATH_DELIMITER=';' diff --git a/pkgs/stdenv/generic/builder.sh b/pkgs/stdenv/generic/builder.sh index ee2dbb3d0f9e..2a74f038dca0 100644 --- a/pkgs/stdenv/generic/builder.sh +++ b/pkgs/stdenv/generic/builder.sh @@ -8,14 +8,17 @@ source $stdenv/setup mkdir $out -substitute "$setup" "$out/setup" \ - --subst-var preHook \ - --subst-var postHook \ - --subst-var initialPath \ - --subst-var gcc \ - --subst-var shell \ - --subst-var-by param1 "$p1" \ - --subst-var-by param2 "$p2" \ - --subst-var-by param3 "$p3" \ - --subst-var-by param4 "$p4" \ - --subst-var-by param5 "$p5" +# Can't use substitute() here, because replace may not have been +# built yet (in the bootstrap). +sed \ + -e "s^@preHook@^$preHook^" \ + -e "s^@postHook@^$postHook^" \ + -e "s^@initialPath@^$initialPath^" \ + -e "s^@gcc@^$gcc^" \ + -e "s^@shell@^$shell^" \ + -e "s^@param1@^$p1^" \ + -e "s^@param2@^$p2^" \ + -e "s^@param3@^$p3^" \ + -e "s^@param4@^$p4^" \ + -e "s^@param5@^$p5^" \ + < "$setup" > "$out/setup" diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index e91a9ce4dfd8..aa76a6eb3b10 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -2,11 +2,9 @@ set -e test -z $NIX_GCC && NIX_GCC=@gcc@ -if [ -z ${system##*cygwin*} ]; then - PATH_DELIMITER=';' -else - PATH_DELIMITER=':' -fi + +# Helper functions that might be useful in setup hooks. + addToSearchPathWithCustomDelimiter() { local delimiter=$1 @@ -28,6 +26,7 @@ addToSearchPath() addToSearchPathWithCustomDelimiter "${PATH_DELIMITER}" "$@" } + # Set up the initial path. PATH= for i in $NIX_GCC @initialPath@; do @@ -41,6 +40,7 @@ fi # Execute the pre-hook. export SHELL=@shell@ +PATH_DELIMITER=':' if test -z "$shell"; then export shell=@shell@ fi @@ -234,27 +234,17 @@ stripDirs() { fi } + ###################################################################### # Textual substitution functions. -# Some disgusting hackery to escape replacements in Sed substitutions. -# We should really have a tool that replaces literal values by other -# literal values, without any need for escaping. -escapeSed() { - local s="$1" - # The `tr' hack is to escape newlines. Sed handles newlines very - # badly, so we just replace newlines with the magic character 0xff - # (377 octal). So don't use that character in replacements :-P - echo -n "$1" | tr '\012' '\377' | sed -e 's^\\^\\\\^g' -e 's^\xff^\\n^g' -e 's/\^/\\^/g' -e 's/&/\\&/g' -} - - substitute() { local input="$1" local output="$2" local -a params=("$@") + local -a args=() local sedScript=$NIX_BUILD_TOP/.sedargs rm -f $sedScript @@ -284,12 +274,14 @@ substitute() { n=$((n + 2)) fi - replacement="$(escapeSed "$replacement")" - - echo "s^$pattern^$replacement^g" >> $sedScript + if test ${#args[@]} != 0; then + args[${#args[@]}]="-a" + fi + args[${#args[@]}]="$pattern" + args[${#args[@]}]="$replacement" done - sed -f $sedScript < "$input" > "$output".tmp + replace -e -s "${args[@]}" < "$input" > "$output".tmp if test -x "$output"; then chmod +x "$output".tmp fi @@ -537,7 +529,7 @@ unpackW() { unpackPhase() { - sourceRoot=. # don't change to user dir homeless shelter if custom unpackSource does'nt set sourceRoot + sourceRoot=. # don't change to user dir homeless shelter if custom unpackSource doesn't set sourceRoot header "unpacking sources" startLog "unpack" unpackW @@ -751,28 +743,26 @@ fixupW() { eval "$preFixup" - forceShare=${forceShare:=man doc info} - if test -n "$forceShare"; then - for d in $forceShare; do - if test -d "$prefix/$d"; then - if test -d "$prefix/share/$d"; then - echo "Both $d/ and share/$d/ exists!" - else + # Put man/doc/info under $out/share. + forceShare=${forceShare:=man doc info} + if test -n "$forceShare"; then + for d in $forceShare; do + if test -d "$prefix/$d"; then + if test -d "$prefix/share/$d"; then + echo "Both $d/ and share/$d/ exists!" + else echo Fixing location of $d/ subdirectory - ensureDir $prefix/share + ensureDir $prefix/share if test -w $prefix/share; then - mv -v $prefix/$d $prefix/share - ln -sv share/$d $prefix + mv -v $prefix/$d $prefix/share + ln -sv share/$d $prefix fi - fi - else - echo "No $d/ subdirectory, skipping." - fi - done; - fi - + fi + fi + done; + fi -# TODO : strip _only_ ELF executables, and return || fail here... + # TODO: strip _only_ ELF executables, and return || fail here... if test -z "$dontStrip"; then echo "Stripping debuging symbols from files in" stripDirs "${stripDebugList:-lib}" -S |