about summary refs log tree commit diff
path: root/pkgs/stdenv
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-11-16 22:17:36 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-11-16 22:17:36 +0100
commita0f3faf34e6b2f024ef86d84ad80c124c33b941a (patch)
tree11eed0d9ee2e444dde60899e8d290ca722bab1c3 /pkgs/stdenv
parent389143d808be38fe4e0def83946c5ab2fd7c5376 (diff)
parentcef0bcefc6544513fec9dec49686932ef15f1734 (diff)
downloadnixlib-a0f3faf34e6b2f024ef86d84ad80c124c33b941a.tar
nixlib-a0f3faf34e6b2f024ef86d84ad80c124c33b941a.tar.gz
nixlib-a0f3faf34e6b2f024ef86d84ad80c124c33b941a.tar.bz2
nixlib-a0f3faf34e6b2f024ef86d84ad80c124c33b941a.tar.lz
nixlib-a0f3faf34e6b2f024ef86d84ad80c124c33b941a.tar.xz
nixlib-a0f3faf34e6b2f024ef86d84ad80c124c33b941a.tar.zst
nixlib-a0f3faf34e6b2f024ef86d84ad80c124c33b941a.zip
Merge remote-tracking branch 'origin/glibc-2.20' into staging
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/adapters.nix57
-rw-r--r--pkgs/stdenv/linux/bootstrap/i686.nix41
-rw-r--r--pkgs/stdenv/linux/bootstrap/x86_64.nix9
-rw-r--r--pkgs/stdenv/linux/default.nix11
-rw-r--r--pkgs/stdenv/linux/make-bootstrap-tools.nix169
-rw-r--r--pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh55
6 files changed, 98 insertions, 244 deletions
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix
index cf95a5edfadf..3917f63563aa 100644
--- a/pkgs/stdenv/adapters.nix
+++ b/pkgs/stdenv/adapters.nix
@@ -29,63 +29,6 @@ rec {
   overrideSetup = stdenv: setupScript: stdenv.override { inherit setupScript; };
 
 
-  # Return a modified stdenv that uses dietlibc to create small
-  # statically linked binaries.
-  useDietLibC = stdenv: stdenv //
-    { mkDerivation = args: stdenv.mkDerivation (args // {
-        NIX_CFLAGS_LINK = "-static";
-
-        # libcompat.a contains some commonly used functions.
-        NIX_LDFLAGS = "-lcompat";
-
-        # These are added *after* the command-line flags, so we'll
-        # always optimise for size.
-        NIX_CFLAGS_COMPILE =
-          args.NIX_CFLAGS_COMPILE or ""
-          + " -Os -s -D_BSD_SOURCE=1";
-
-        configureFlags =
-          args.configureFlags or ""
-          + " --disable-shared"; # brrr...
-
-        NIX_GCC = import ../build-support/gcc-wrapper {
-          inherit stdenv;
-          libc = pkgs.dietlibc;
-          inherit (stdenv.gcc) gcc binutils nativeTools nativePrefix;
-          nativeLibc = false;
-        };
-      });
-      isDietLibC = true;
-    };
-
-
-  # Return a modified stdenv that uses klibc to create small
-  # statically linked binaries.
-  useKlibc = stdenv: klibc: stdenv //
-    { mkDerivation = args: stdenv.mkDerivation (args // {
-        NIX_CFLAGS_LINK = "-static";
-
-        # These are added *after* the command-line flags, so we'll
-        # always optimise for size.
-        NIX_CFLAGS_COMPILE =
-          args.NIX_CFLAGS_COMPILE or "" + " -Os -s";
-
-        configureFlags =
-          args.configureFlags or "" + " --disable-shared"; # brrr...
-
-        NIX_GCC = pkgs.runCommand "klibc-wrapper" {} ''
-          mkdir -p $out/bin
-          ln -s ${klibc}/bin/klcc $out/bin/gcc
-          ln -s ${klibc}/bin/klcc $out/bin/cc
-          mkdir -p $out/nix-support
-          echo 'PATH=$PATH:${stdenv.gcc.binutils}/bin' > $out/nix-support/setup-hook
-        '';
-      });
-      isKlibc = true;
-      isStatic = true;
-    };
-
-
   # Return a modified stdenv that tries to build statically linked
   # binaries.
   makeStaticBinaries = stdenv: stdenv //
diff --git a/pkgs/stdenv/linux/bootstrap/i686.nix b/pkgs/stdenv/linux/bootstrap/i686.nix
index 7b6b3ee80344..88bd984bab96 100644
--- a/pkgs/stdenv/linux/bootstrap/i686.nix
+++ b/pkgs/stdenv/linux/bootstrap/i686.nix
@@ -1,39 +1,12 @@
-let
-
-  fetch = { file, sha256 }: import <nix/fetchurl.nix> {
-    url = "http://tarballs.nixos.org/stdenv-linux/i686/r24519/${file}";
-    inherit sha256;
+{
+  busybox = import <nix/fetchurl.nix> {
+    url = http://tarballs.nixos.org/stdenv-linux/i686/73b75f6157db79fc899154a497823e82e409e76d/busybox;
+    sha256 = "159208615405938d9830634f15d38adf5a9c33643926845c44499dbe6dd62042";
     executable = true;
   };
 
-in {
-  sh = fetch {
-    file = "sh";
-    sha256 = "1l6sdhyqjlh4m5gj3pfpi8aisp1m012lpwxfcc4v1x8g429mflmy";
-  };
-
-  bzip2 = fetch {
-    file = "bzip2";
-    sha256 = "1p5nkrdn52jm6rsx8x3wwjpsh83f2qsjl1qckkgnkplwhj23zjp7";
-  };
-
-  mkdir = fetch {
-    file = "mkdir";
-    sha256 = "02ff7i9ph9ahiapsg2v9c3pwr7sl73sk4n7ic112ljkrgwkail33";
-  };
-
-  cpio = fetch {
-    file = "cpio";
-    sha256 = "046if3aqqramyhrn2yxrjf4bfkl8x1bcqxhvi7ml9nrv9smx8irg";
-  };
-
-  curl = fetch {
-    file = "curl.bz2";
-    sha256 = "1v0yfb4gcdyqpl2fxlxjh337r28c23iqm7vwck4p4643xd55di7q";
-  };
-
-  bootstrapTools = {
-    url = http://tarballs.nixos.org/stdenv-linux/i686/r24519/bootstrap-tools.cpio.bz2;
-    sha256 = "0imypaxy6piwbk8ff2y1nr7yk49pqmdgdbv6g8miq1zs5yfip6ij";
+  bootstrapTools = import <nix/fetchurl.nix> {
+    url = http://tarballs.nixos.org/stdenv-linux/i686/73b75f6157db79fc899154a497823e82e409e76d/bootstrap-tools.tar.xz;
+    sha256 = "68c430b84dbeac0bd1bea4cdd3159dce44a76445e07860caed1972b4608c42ca";
   };
 }
diff --git a/pkgs/stdenv/linux/bootstrap/x86_64.nix b/pkgs/stdenv/linux/bootstrap/x86_64.nix
index 71961e6961e6..96822f57e504 100644
--- a/pkgs/stdenv/linux/bootstrap/x86_64.nix
+++ b/pkgs/stdenv/linux/bootstrap/x86_64.nix
@@ -1,10 +1,9 @@
-# Use the static tools for i686-linux.  They work on x86_64-linux
-# machines as well.
+# Use busybox for i686-linux since it works on x86_64-linux as well.
 (import ./i686.nix) //
 
 {
-  bootstrapTools = {
-    url = http://tarballs.nixos.org/stdenv-linux/x86_64/r23302/bootstrap-tools.cpio.bz2;
-    sha256 = "0w89kqhx47yl0jifp2vffp073pyrqha5f312kp971smi4h41drna";
+  bootstrapTools = import <nix/fetchurl.nix> {
+    url = http://tarballs.nixos.org/stdenv-linux/x86_64/73b75f6157db79fc899154a497823e82e409e76d/bootstrap-tools.tar.xz;
+    sha256 = "e29d47a5dc9f1ff10c3fbaacbd03a3cca0c784299df09fcdd9e25797ec6414ad";
   };
 }
diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix
index 76849c2c61ab..cbbddc718969 100644
--- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -40,20 +40,15 @@ rec {
   bootstrapTools = derivation {
     name = "bootstrap-tools";
 
-    builder = bootstrapFiles.sh;
+    builder = bootstrapFiles.busybox;
 
     args =
       if system == "armv5tel-linux" || system == "armv6l-linux"
         || system == "armv7l-linux"
       then [ ./scripts/unpack-bootstrap-tools-arm.sh ]
-      else [ ./scripts/unpack-bootstrap-tools.sh ];
+      else [ "ash" "-e" ./scripts/unpack-bootstrap-tools.sh ];
 
-    # FIXME: get rid of curl.
-    inherit (bootstrapFiles) bzip2 mkdir curl cpio;
-
-    tarball = import <nix/fetchurl.nix> {
-      inherit (bootstrapFiles.bootstrapTools) url sha256;
-    };
+    tarball = bootstrapFiles.bootstrapTools;
 
     inherit system;
 
diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix
index 9116b2225690..e202f691fa8d 100644
--- a/pkgs/stdenv/linux/make-bootstrap-tools.nix
+++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix
@@ -1,4 +1,4 @@
-{system ? builtins.currentSystem}:
+{ system ? builtins.currentSystem }:
 
 with import ../../top-level/all-packages.nix {inherit system;};
 
@@ -6,84 +6,32 @@ rec {
 
 
   # We want coreutils without ACL support.
-  coreutils_ = coreutils.override (args: {
+  coreutilsMinimal = coreutils.override (args: {
     aclSupport = false;
   });
 
-  # bzip2 wants utime.h, a header 'legacy' in uclibc
-  uclibcForBzip2 = uclibc.override {
-    extraConfig = ''
-        UCLIBC_SUSV3_LEGACY y
-        UCLIBC_SUSV4_LEGACY y
-    '';
-  };
-
-  gccLinkStatic = wrapGCCWith (import ../../build-support/gcc-wrapper) uclibcForBzip2
-    stdenv.gcc.gcc;
-  stdenvLinkStatic = overrideGCC stdenv gccLinkStatic;
-
-  curlStatic = import ../../tools/networking/curl {
-    stdenv = stdenvLinkStatic;
-    inherit fetchurl;
+  curlMinimal = curl.override {
     zlibSupport = false;
     sslSupport = false;
-    linkStatic = true;
+    scpSupport = false;
   };
 
-
-  bzip2Static = import ../../tools/compression/bzip2 {
-    stdenv = stdenvLinkStatic;
-    inherit fetchurl;
-    linkStatic = true;
-  };
-
-  #gccNoShared = wrapGCC ( gcc.gcc.override { enableShared = false; } );
-
-  busyboxStaticSh = busybox.override {
+  busyboxMinimal = busybox.override {
+    useUclibc = true;
+    enableStatic = true;
+    enableMinimal = true;
     extraConfig = ''
-      CLEAR
-      CONFIG_STATIC y
-
       CONFIG_ASH y
-      CONFIG_BASH_COMPAT y
-      CONFIG_ASH_ALIAS y
-      CONFIG_ASH_GETOPTS y
-      CONFIG_ASH_CMDCMD y
-      CONFIG_ASH_JOB_CONTROL y
       CONFIG_ASH_BUILTIN_ECHO y
-      CONFIG_ASH_BUILTIN_PRINTF y
       CONFIG_ASH_BUILTIN_TEST y
-    '';
-  };
-
-  busyboxStaticLn = busybox.override {
-    extraConfig = ''
-      CLEAR
-      CONFIG_STATIC y
-      CONFIG_LN y
-    '';
-  };
-
-  busyboxStaticMkdir = busybox.override {
-    extraConfig = ''
-      CLEAR
-      CONFIG_STATIC y
+      CONFIG_ASH_OPTIMIZE_FOR_SIZE y
       CONFIG_MKDIR y
+      CONFIG_TAR y
+      CONFIG_UNXZ y
     '';
   };
 
-  busyboxStaticCpio = busybox.override {
-    extraConfig = ''
-      CLEAR
-      CONFIG_STATIC y
-      CONFIG_CPIO y
-      # (shlevy) Are these necessary?
-      CONFIG_FEATURE_CPIO_O y
-      CONFIG_FEATURE_CPIO_P y
-    '';
-  };
-
-  build = 
+  build =
 
     stdenv.mkDerivation {
       name = "build";
@@ -91,7 +39,7 @@ rec {
       buildInputs = [nukeReferences cpio];
 
       buildCommand = ''
-	set -x
+        set -x
         mkdir -p $out/bin $out/lib $out/libexec
 
         # Copy what we need of Glibc.
@@ -105,26 +53,26 @@ rec {
         cp -d ${glibc}/lib/libnsl*.so* $out/lib
         cp -d ${glibc}/lib/libutil*.so* $out/lib
         cp -d ${glibc}/lib/crt?.o $out/lib
-        
+
         cp -rL ${glibc}/include $out
         chmod -R u+w $out/include
-        
+
         # Hopefully we won't need these.
         rm -rf $out/include/mtd $out/include/rdma $out/include/sound $out/include/video
         find $out/include -name .install -exec rm {} \;
         find $out/include -name ..install.cmd -exec rm {} \;
         mv $out/include $out/include-glibc
-        
+
         # Copy coreutils, bash, etc.
-        cp ${coreutils_}/bin/* $out/bin
+        cp ${coreutilsMinimal}/bin/* $out/bin
         (cd $out/bin && rm vdir dir sha*sum pinky factor pathchk runcon shuf who whoami shred users)
-        
+
         cp ${bash}/bin/bash $out/bin
         cp ${findutils}/bin/find $out/bin
         cp ${findutils}/bin/xargs $out/bin
         cp -d ${diffutils}/bin/* $out/bin
         cp -d ${gnused}/bin/* $out/bin
-        cp -d ${gnugrep}/bin/* $out/bin
+        cp -d ${gnugrep}/bin/grep $out/bin
         cp ${gawk}/bin/gawk $out/bin
         cp -d ${gawk}/bin/awk $out/bin
         cp ${gnutar}/bin/tar $out/bin
@@ -133,9 +81,11 @@ rec {
         cp -d ${gnumake}/bin/* $out/bin
         cp -d ${patch}/bin/* $out/bin
         cp ${patchelf}/bin/* $out/bin
+        cp ${curlMinimal}/bin/curl $out/bin
+        cp -d ${curlMinimal}/lib/libcurl* $out/lib
 
         cp -d ${gnugrep.pcre}/lib/libpcre*.so* $out/lib # needed by grep
-        
+
         # Copy what we need of GCC.
         cp -d ${gcc.gcc}/bin/gcc $out/bin
         cp -d ${gcc.gcc}/bin/cpp $out/bin
@@ -151,6 +101,8 @@ rec {
         rm -rf $out/lib/gcc/*/*/plugin
         #rm -f $out/lib/gcc/*/*/*.a
         cp -rd ${gcc.gcc}/libexec/* $out/libexec
+        chmod -R u+w $out/libexec
+        rm -rf $out/libexec/gcc/*/*/plugin
         mkdir $out/include
         cp -rd ${gcc.gcc}/include/c++ $out/include
         chmod -R u+w $out/include
@@ -159,19 +111,18 @@ rec {
 
         cp -d ${gmpxx}/lib/libgmp*.so* $out/lib
         cp -d ${mpfr}/lib/libmpfr*.so* $out/lib
-        cp -d ${ppl}/lib/libppl*.so* $out/lib
-        cp -d ${cloogppl}/lib/libcloog*.so* $out/lib
         cp -d ${mpc}/lib/libmpc*.so* $out/lib
         cp -d ${zlib}/lib/libz.so* $out/lib
         cp -d ${libelf}/lib/libelf.so* $out/lib
-        
+
         # Copy binutils.
         for i in as ld ar ranlib nm strip readelf objdump; do
           cp ${binutils}/bin/$i $out/bin
         done
+        cp -d ${binutils}/lib/lib*.so* $out/lib
 
         chmod -R u+w $out
-        
+
         # Strip executables even further.
         for i in $out/bin/* $out/libexec/gcc/*/*/*; do
             if test -x $i -a ! -L $i; then
@@ -189,19 +140,10 @@ rec {
         mv $out/.pack $out/pack
 
         mkdir $out/on-server
-        (cd $out/pack && (find | cpio -o -H newc)) | bzip2 > $out/on-server/bootstrap-tools.cpio.bz2
-
-        mkdir $out/in-nixpkgs
-        cp ${busyboxStaticSh}/bin/busybox $out/in-nixpkgs/sh
-        cp ${busyboxStaticCpio}/bin/busybox $out/in-nixpkgs/cpio
-        cp ${busyboxStaticMkdir}/bin/busybox $out/in-nixpkgs/mkdir
-        cp ${busyboxStaticLn}/bin/busybox $out/in-nixpkgs/ln
-        cp ${curlStatic}/bin/curl $out/in-nixpkgs
-        cp ${bzip2Static}/bin/bzip2 $out/in-nixpkgs
-        chmod u+w $out/in-nixpkgs/*
-        strip $out/in-nixpkgs/*
-        nuke-refs $out/in-nixpkgs/*
-        bzip2 $out/in-nixpkgs/curl
+        tar cvfJ $out/on-server/bootstrap-tools.tar.xz -C $out/pack .
+        cp ${busyboxMinimal}/bin/busybox $out/on-server
+        chmod u+w $out/on-server/busybox
+        nuke-refs $out/on-server/busybox
       ''; # */
 
       # The result should not contain any references (store paths) so
@@ -210,22 +152,33 @@ rec {
       allowedReferences = [];
     };
 
-  
+
   unpack =
-    
-    stdenv.mkDerivation {
+
+    derivation {
       name = "unpack";
+      inherit system;
+      builder = "${build}/on-server/busybox";
+      args = [ "ash" "-e" "-c" "eval \"$buildCommand\"" ];
 
       buildCommand = ''
-        ${build}/in-nixpkgs/mkdir $out
-        ${build}/in-nixpkgs/bzip2 -d < ${build}/on-server/bootstrap-tools.cpio.bz2 | (cd $out && ${build}/in-nixpkgs/cpio -v -i)
+        export PATH=${build}/on-server:$out/bin
+
+        busybox mkdir $out
+        < ${build}/on-server/bootstrap-tools.tar.xz busybox unxz | busybox tar x -C $out
 
         for i in $out/bin/* $out/libexec/gcc/*/*/*; do
-            echo patching $i
-            if ! test -L $i; then
-                LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.2 \
-                    $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.2 --set-rpath $out/lib --force-rpath $i
-            fi
+            if [ -L "$i" ]; then continue; fi
+            if [ -z "''${i##*/liblto*}" ]; then continue; fi
+            echo patching "$i"
+            LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.2 \
+                $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.2 --set-rpath $out/lib --force-rpath "$i"
+        done
+
+        for i in $out/lib/libpcre*; do
+            if [ -L "$i" ]; then continue; fi
+            echo patching "$i"
+            $out/bin/patchelf --set-rpath $out/lib --force-rpath "$i"
         done
 
         # Fix the libc linker script.
@@ -241,11 +194,12 @@ rec {
 
   test =
 
-    stdenv.mkDerivation {
+    derivation {
       name = "test";
+      inherit system;
+      builder = "${build}/on-server/busybox";
+      args = [ "ash" "-e" "-c" "eval \"$buildCommand\"" ];
 
-      realBuilder = "${unpack}/bin/bash";
-      
       buildCommand = ''
         export PATH=${unpack}/bin
         ls -l
@@ -259,23 +213,22 @@ rec {
         awk --version
         grep --version
         gcc --version
-
-        ${build}/in-nixpkgs/sh -c 'echo Hello World'
+        curl --version
 
         ldlinux=$(echo ${unpack}/lib/ld-linux*.so.2)
 
         export CPP="cpp -idirafter ${unpack}/include-glibc -B${unpack}"
         export CC="gcc -idirafter ${unpack}/include-glibc -B${unpack} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${unpack}/lib"
         export CXX="g++ -idirafter ${unpack}/include-glibc -B${unpack} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${unpack}/lib"
-        
+
         echo '#include <stdio.h>' >> foo.c
         echo '#include <limits.h>' >> foo.c
-        echo 'int main() { printf("Hello World\n"); return 0; }' >> foo.c
+        echo 'int main() { printf("Hello World\\n"); return 0; }' >> foo.c
         $CC -o $out/bin/foo foo.c
         $out/bin/foo
 
         echo '#include <iostream>' >> bar.cc
-        echo 'int main() { std::cout << "Hello World\n"; }' >> bar.cc
+        echo 'int main() { std::cout << "Hello World\\n"; }' >> bar.cc
         $CXX -v -o $out/bin/bar bar.cc
         $out/bin/bar
 
@@ -286,5 +239,5 @@ rec {
         make install
       ''; # */
     };
-    
+
 }
diff --git a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh
index 422dc6dd5fef..52953c9b88da 100644
--- a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh
+++ b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh
@@ -1,9 +1,7 @@
-set -e
-
 # Unpack the bootstrap tools tarball.
 echo Unpacking the bootstrap tools...
-$mkdir $out
-$bzip2 -d < $tarball | (cd $out && $cpio -i)
+$builder mkdir $out
+< $tarball $builder unxz | $builder tar x -C $out
 
 # Set the ELF interpreter / RPATH in the bootstrap binaries.
 echo Patching the bootstrap tools...
@@ -21,32 +19,17 @@ fi
 LD_LIBRARY_PATH=$out/lib $LD_BINARY $out/bin/cp $out/bin/patchelf .
 
 for i in $out/bin/* $out/libexec/gcc/*/*/*; do
-    echo patching $i
-    if ! test -L $i; then
-         LD_LIBRARY_PATH=$out/lib $LD_BINARY \
-             $out/bin/patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath $i
-         LD_LIBRARY_PATH=$out/lib $LD_BINARY \
-             $out/bin/patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath $i
-    fi
-done
-for i in $out/lib/librt* ; do
-    echo patching $i
-    if ! test -L $i; then
-         LD_LIBRARY_PATH=$out/lib $LD_BINARY \
-             $out/bin/patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath $i
-         LD_LIBRARY_PATH=$out/lib $LD_BINARY \
-             $out/bin/patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath $i
-    fi
+    if [ -L "$i" ]; then continue; fi
+    if [ -z "${i##*/liblto*}" ]; then continue; fi
+    echo patching "$i"
+    LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.2 \
+        $out/bin/patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath "$i"
 done
 
-for i in $out/lib/libgmp* $out/lib/libppl* $out/lib/libcloog* $out/lib/libmpc* $out/lib/libpcre* $out/lib/libstdc++*.so.*[0-9]; do
-    echo trying to patch $i
-    if test -f $i -a ! -L $i; then
-         LD_LIBRARY_PATH=$out/lib $LD_BINARY \
-             $out/bin/patchelf --set-rpath $out/lib --force-rpath $i
-         LD_LIBRARY_PATH=$out/lib $LD_BINARY \
-             $out/bin/patchelf --set-rpath $out/lib --force-rpath $i
-    fi
+for i in $out/lib/libpcre*; do
+    if [ -L "$i" ]; then continue; fi
+    echo patching "$i"
+    $out/bin/patchelf --set-rpath $out/lib --force-rpath "$i"
 done
 
 # Fix the libc linker script.
@@ -60,13 +43,21 @@ mv $out/lib/libpthread.so.tmp $out/lib/libpthread.so
 ln -s bash $out/bin/sh
 ln -s bzip2 $out/bin/bunzip2
 
-# Mimic the gunzip script as in gzip installations
+# Provide a gunzip script.
 cat > $out/bin/gunzip <<EOF
 #!$out/bin/sh
 exec $out/bin/gzip -d "\$@"
 EOF
 chmod +x $out/bin/gunzip
 
-# fetchurl needs curl.
-bzip2 -d < $curl > $out/bin/curl
-chmod +x $out/bin/curl
+# Provide fgrep/egrep.
+echo "#! $out/bin/sh" > $out/bin/egrep
+echo "exec $out/bin/grep -E \"\$@\"" >> $out/bin/egrep
+echo "#! $out/bin/sh" > $out/bin/fgrep
+echo "exec $out/bin/grep -F \"\$@\"" >> $out/bin/fgrep
+
+# Provide xz (actually only xz -d will work).
+echo "#! $out/bin/sh" > $out/bin/xz
+echo "exec $builder unxz \"\$@\"" >> $out/bin/xz
+
+chmod +x $out/bin/egrep $out/bin/fgrep $out/bin/xz