summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2008-02-13 14:23:09 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2008-02-13 14:23:09 +0000
commit5f45fb3ae986119b4360613901a1c033a2ee327e (patch)
tree08448fced019fe7676f255cd13c2ea228425876d
parent3db3e079afaaae281124ee9ff1b34df3fa197824 (diff)
downloadnixpkgs-5f45fb3ae986119b4360613901a1c033a2ee327e.tar
nixpkgs-5f45fb3ae986119b4360613901a1c033a2ee327e.tar.gz
nixpkgs-5f45fb3ae986119b4360613901a1c033a2ee327e.tar.bz2
nixpkgs-5f45fb3ae986119b4360613901a1c033a2ee327e.tar.lz
nixpkgs-5f45fb3ae986119b4360613901a1c033a2ee327e.tar.xz
nixpkgs-5f45fb3ae986119b4360613901a1c033a2ee327e.tar.zst
nixpkgs-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
-rw-r--r--pkgs/build-support/gcc-wrapper/builder.sh19
-rw-r--r--pkgs/development/libraries/glibc-2.7/builder.sh5
-rw-r--r--pkgs/development/libraries/glibc-2.7/default.nix2
-rw-r--r--pkgs/development/libraries/glibc-2.7/glibc-getcwd-param-MAX.patch14
-rw-r--r--pkgs/development/libraries/glibc-2.7/glibc-pwd.patch74
-rw-r--r--pkgs/stdenv/common-path.nix1
-rw-r--r--pkgs/stdenv/cygwin/prehook.sh2
-rw-r--r--pkgs/stdenv/generic/builder.sh25
-rw-r--r--pkgs/stdenv/generic/setup.sh70
-rw-r--r--pkgs/tools/text/replace/default.nix11
-rw-r--r--pkgs/top-level/all-packages.nix1
11 files changed, 66 insertions, 158 deletions
diff --git a/pkgs/build-support/gcc-wrapper/builder.sh b/pkgs/build-support/gcc-wrapper/builder.sh
index f9dbc0e784f..c263b3f330e 100644
--- a/pkgs/build-support/gcc-wrapper/builder.sh
+++ b/pkgs/build-support/gcc-wrapper/builder.sh
@@ -50,14 +50,17 @@ fi
 doSubstitute() {
     local src=$1
     local dst=$2
-    substitute "$src" "$dst" \
-        --subst-var "out" \
-        --subst-var "shell" \
-        --subst-var "gcc" \
-        --subst-var "gccProg" \
-        --subst-var "binutils" \
-        --subst-var "libc" \
-        --subst-var-by "ld" "$ldPath/ld"
+    # Can't use substitute() here, because replace may not have been
+    # built yet (in the bootstrap).
+    sed \
+        -e "s^@out@^$out^" \
+        -e "s^@shell@^$shell^" \
+        -e "s^@gcc@^$gcc^" \
+        -e "s^@gccProg@^$gccProg^" \
+        -e "s^@binutils@^$binutils^" \
+        -e "s^@libc@^$libc^" \
+        -e "s^@ld@^$ldPath/ld^" \
+        < "$src" > "$dst" 
 }
 
 
diff --git a/pkgs/development/libraries/glibc-2.7/builder.sh b/pkgs/development/libraries/glibc-2.7/builder.sh
index 3e874ed891c..2418d0bf365 100644
--- a/pkgs/development/libraries/glibc-2.7/builder.sh
+++ b/pkgs/development/libraries/glibc-2.7/builder.sh
@@ -12,8 +12,9 @@ preConfigure=preConfigure
 preConfigure() {
 
     for i in configure io/ftwtest-sh; do
-        substituteInPlace "$i" \
-            --replace "@PWD@" "pwd"
+        # Can't use substituteInPlace here because replace hasn't been
+        # built yet in the bootstrap.
+        sed -i "$i" -e "s^/bin/pwd^$(type -tP pwd)^"
     done
 
     # In the glibc 2.6/2.7 tarballs C-translit.h is a little bit older
diff --git a/pkgs/development/libraries/glibc-2.7/default.nix b/pkgs/development/libraries/glibc-2.7/default.nix
index 8a5a84bd2c6..f33f95fda9f 100644
--- a/pkgs/development/libraries/glibc-2.7/default.nix
+++ b/pkgs/development/libraries/glibc-2.7/default.nix
@@ -12,8 +12,6 @@ stdenv.mkDerivation {
     sha256 = "06j5q20l11x8kcrl9bg15xgb1pw0w82pazikxf4zvq2fmhiaa922";
   };
 
-  patches = [ ./glibc-pwd.patch ./glibc-getcwd-param-MAX.patch ];
-
   inherit kernelHeaders installLocales;
 
   inherit (stdenv) is64bit;
diff --git a/pkgs/development/libraries/glibc-2.7/glibc-getcwd-param-MAX.patch b/pkgs/development/libraries/glibc-2.7/glibc-getcwd-param-MAX.patch
deleted file mode 100644
index 8543dbbf1d7..00000000000
--- a/pkgs/development/libraries/glibc-2.7/glibc-getcwd-param-MAX.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-2006-06-18  Mike Frysinger  <vapier@gentoo.org>
-
-	* sysdeps/unix/sysv/linux/getcwd.c: Include sys/param.h.
-
---- glibc-old/sysdeps/unix/sysv/linux/getcwd.c
-+++ glibc-new/sysdeps/unix/sysv/linux/getcwd.c
-@@ -24,6 +24,7 @@
- #include <limits.h>
- #include <stdlib.h>
- #include <unistd.h>
-+#include <sys/param.h>
- 
- #include <sysdep.h>
- #include <sys/syscall.h>
diff --git a/pkgs/development/libraries/glibc-2.7/glibc-pwd.patch b/pkgs/development/libraries/glibc-2.7/glibc-pwd.patch
deleted file mode 100644
index 07039718477..00000000000
--- a/pkgs/development/libraries/glibc-2.7/glibc-pwd.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-diff -ruN glibc-20050110/configure glibc-20050110.patched/configure
---- glibc-20050110/configure	2005-01-05 10:39:53.000000000 +0100
-+++ glibc-20050110.patched/configure	2005-01-18 13:33:01.000000000 +0100
-@@ -1393,7 +1393,7 @@
- ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
- 
- 
--if test "`cd $srcdir; /bin/pwd`" = "`/bin/pwd`"; then
-+if test "`cd $srcdir; @PWD@`" = "`@PWD@`"; then
-   { { echo "$as_me:$LINENO: error: you must configure in a separate build directory" >&5
- echo "$as_me: error: you must configure in a separate build directory" >&2;}
-    { (exit 1); exit 1; }; }
-diff -ruN glibc-20050110/io/ftwtest-sh glibc-20050110.patched/io/ftwtest-sh
---- glibc-20050110/io/ftwtest-sh	2004-02-09 21:12:23.000000000 +0100
-+++ glibc-20050110.patched/io/ftwtest-sh	2005-01-18 13:33:15.000000000 +0100
-@@ -120,7 +120,7 @@
-     sort > $testout
- 
- # perhaps $tmp involves some symlinks...
--tmpreal=`cd $tmp; /bin/pwd 2>/dev/null || /usr/bin/pwd`
-+tmpreal=`cd $tmp; @PWD@ 2>/dev/null || /usr/bin/pwd`
- 
- cat <<EOF | cmp $testout - || exit 1
- base = "$tmp/", file = "ftwtest.d", flag = FTW_D, cwd = $tmpreal, level = 0
-@@ -138,7 +138,7 @@
- EOF
- rm $testout
- 
--curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
-+curwd=`@PWD@ 2>/dev/null || /usr/bin/pwd`
- cd "$tmp"
- LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d |
-     sort > $testout
-@@ -160,7 +160,7 @@
- EOF
- rm $testout
- 
--curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
-+curwd=`@PWD@ 2>/dev/null || /usr/bin/pwd`
- cd "$tmp"
- LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d/. |
-     sort > $testout
-@@ -182,7 +182,7 @@
- EOF
- rm $testout
- 
--curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
-+curwd=`@PWD@ 2>/dev/null || /usr/bin/pwd`
- cd "$tmp"
- LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d/foo/lvl1/link@1 |
-     sort > $testout
-diff -ruN glibc-20050110/scripts/rellns-sh glibc-20050110.patched/scripts/rellns-sh
---- glibc-20050110/scripts/rellns-sh	1999-12-19 00:40:25.000000000 +0100
-+++ glibc-20050110.patched/scripts/rellns-sh	2005-01-18 13:35:53.245937423 +0100
-@@ -22,13 +22,13 @@
-   exit 1
- fi
- 
--if test -x /bin/pwd; then
--  pwd=/bin/pwd
--elif test -x /usr/bin/pwd; then
--  pwd=/usr/bin/pwd
--else
-+#if test -x /bin/pwd; then
-+#  pwd=/bin/pwd
-+#elif test -x /usr/bin/pwd; then
-+#  pwd=/usr/bin/pwd
-+#else
-   pwd='pwd'
--fi
-+#fi
- 
- # Make both paths absolute.
- if test -d $1; then
diff --git a/pkgs/stdenv/common-path.nix b/pkgs/stdenv/common-path.nix
index 0ad0d83255b..3b267a543c6 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 673640c0d4a..b2ada869b29 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 ee2dbb3d0f9..2a74f038dca 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 e91a9ce4dfd..aa76a6eb3b1 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
diff --git a/pkgs/tools/text/replace/default.nix b/pkgs/tools/text/replace/default.nix
index 3135204ef03..b9613ef2077 100644
--- a/pkgs/tools/text/replace/default.nix
+++ b/pkgs/tools/text/replace/default.nix
@@ -1,4 +1,5 @@
 {stdenv, fetchurl}:
+
 stdenv.mkDerivation {
   name = "replace-2.24";
 
@@ -7,14 +8,10 @@ stdenv.mkDerivation {
     sha256 = "1c2nkxx83vmlh1v3ib6r2xqh121gdb1rharwsimcb2h0xwc558dm";
   };
 
-  buildInputs = [];
-  makeFlags = " TREE=\$(out) ";
-
-  postInstall = "mv \$out/bin/replace \$out/bin/replace-literal";
+  makeFlags = "TREE=\$(out)";
 
   meta = {
-    description = "
-	Replace verbatim strings. Sed is not fit to do it. Replace is.
-";
+    homepage = http://replace.richardlloyd.org.uk/;
+    description = "A tool to replace verbatim strings";
   };
 }
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 82940ce7997..7064d11a725 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -321,6 +321,7 @@ rec {
   nukeReferences = import ../build-support/nuke-references/default.nix {
     inherit stdenv;
   };
+  
 
   ### TOOLS