From ef83c754f685262502a70063035d3e72f93ec2ed Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <eelco.dolstra@logicblox.com>
Date: Mon, 22 Jun 2009 14:28:07 +0000
Subject: [PATCH] * Updated the function that builds the bootstrap binaries. *
 Use patchelf 0.5 and use the --force-rpath flag.  This removes the   need for
 setting LD_LIBRARY_PATH and so should fix bootstrapping   Nixpkgs on
 non-NixOS platforms.

svn path=/nixpkgs/trunk/; revision=16022
---
 pkgs/stdenv/linux/make-bootstrap-tools.nix | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix
index 2b4c6b812db8..de8a25c6f64c 100644
--- a/pkgs/stdenv/linux/make-bootstrap-tools.nix
+++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix
@@ -6,14 +6,11 @@ rec {
 
 
   # We want coreutils without ACL support.
-  coreutils_ = coreutils.function (args: {
+  coreutils_ = coreutils.override (args: {
     aclSupport = false;
   });
 
 
-  gcc = gcc43;
-
-
   curlDiet = import ../../tools/networking/curl {
     inherit fetchurl;
     stdenv = useDietLibC stdenv;
@@ -55,6 +52,8 @@ rec {
         
         # 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.
@@ -74,7 +73,7 @@ rec {
         cp ${bzip2}/bin/bzip2 $out/bin
         cp -d ${gnumake}/bin/* $out/bin
         cp -d ${patch}/bin/* $out/bin
-        cp ${patchelf}/bin/* $out/bin
+        cp ${patchelf05}/bin/* $out/bin
         cp ${replace}/bin/* $out/bin
 
         cp -d ${gnugrep.pcre}/lib/libpcre*.so* $out/lib # needed by grep
@@ -90,6 +89,7 @@ rec {
         rm -f $out/lib/gcc/*/*/include*/linux
         rm -f $out/lib/gcc/*/*/include*/sound
         rm -rf $out/lib/gcc/*/*/include*/root
+        rm -f $out/lib/gcc/*/*/include-fixed/asm
         #rm -f $out/lib/gcc/*/*/*.a
         cp -rd ${gcc.gcc}/libexec/* $out/libexec
         mkdir $out/include
@@ -160,7 +160,7 @@ rec {
             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 $i
+                    $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.2 --set-rpath $out/lib --force-rpath $i
             fi
         done
 
@@ -180,8 +180,6 @@ rec {
     stdenv.mkDerivation {
       name = "test";
 
-      LD_LIBRARY_PATH = "${unpack}/lib";
-
       realBuilder = "${unpack}/bin/bash";
       
       buildCommand = ''