at v206 63 lines 2.0 kB view raw
1# Unpack the bootstrap tools tarball. 2echo Unpacking the bootstrap tools... 3$builder mkdir $out 4< $tarball $builder unxz | $builder tar x -C $out 5 6# Set the ELF interpreter / RPATH in the bootstrap binaries. 7echo Patching the bootstrap tools... 8 9if test -f $out/lib/ld.so.?; then 10 # MIPS case 11 LD_BINARY=$out/lib/ld.so.? 12else 13 # i686, x86_64 and armv5tel 14 LD_BINARY=$out/lib/ld-*so.? 15fi 16 17# On x86_64, ld-linux-x86-64.so.2 barfs on patchelf'ed programs. So 18# use a copy of patchelf. 19LD_LIBRARY_PATH=$out/lib $LD_BINARY $out/bin/cp $out/bin/patchelf . 20 21for i in $out/bin/* $out/libexec/gcc/*/*/*; do 22 if [ -L "$i" ]; then continue; fi 23 if [ -z "${i##*/liblto*}" ]; then continue; fi 24 echo patching "$i" 25 LD_LIBRARY_PATH=$out/lib $LD_BINARY \ 26 $out/bin/patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath "$i" 27done 28 29for i in $out/lib/librt-*.so $out/lib/libpcre*; do 30 if [ -L "$i" ]; then continue; fi 31 echo patching "$i" 32 $out/bin/patchelf --set-rpath $out/lib --force-rpath "$i" 33done 34 35# Fix the libc linker script. 36export PATH=$out/bin 37cat $out/lib/libc.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libc.so.tmp 38mv $out/lib/libc.so.tmp $out/lib/libc.so 39cat $out/lib/libpthread.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libpthread.so.tmp 40mv $out/lib/libpthread.so.tmp $out/lib/libpthread.so 41 42# Provide some additional symlinks. 43ln -s bash $out/bin/sh 44ln -s bzip2 $out/bin/bunzip2 45 46# Provide a gunzip script. 47cat > $out/bin/gunzip <<EOF 48#!$out/bin/sh 49exec $out/bin/gzip -d "\$@" 50EOF 51chmod +x $out/bin/gunzip 52 53# Provide fgrep/egrep. 54echo "#! $out/bin/sh" > $out/bin/egrep 55echo "exec $out/bin/grep -E \"\$@\"" >> $out/bin/egrep 56echo "#! $out/bin/sh" > $out/bin/fgrep 57echo "exec $out/bin/grep -F \"\$@\"" >> $out/bin/fgrep 58 59# Provide xz (actually only xz -d will work). 60echo "#! $out/bin/sh" > $out/bin/xz 61echo "exec $builder unxz \"\$@\"" >> $out/bin/xz 62 63chmod +x $out/bin/egrep $out/bin/fgrep $out/bin/xz