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