2009-02-01 21:44:56 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
# Unpack the bootstrap tools tarball.
|
|
|
|
echo Unpacking the bootstrap tools...
|
|
|
|
$mkdir $out
|
2010-08-01 22:22:51 +01:00
|
|
|
$bzip2 -d < $tarball | (cd $out && $cpio -i)
|
2009-02-01 21:44:56 +00:00
|
|
|
|
|
|
|
# Set the ELF interpreter / RPATH in the bootstrap binaries.
|
|
|
|
echo Patching the bootstrap tools...
|
|
|
|
|
2010-08-01 23:00:14 +01:00
|
|
|
if test -f $out/lib/ld.so.?; then
|
|
|
|
# MIPS case
|
|
|
|
LD_BINARY=$out/lib/ld.so.?
|
|
|
|
else
|
|
|
|
# i686, x86_64 and armv5tel
|
|
|
|
LD_BINARY=$out/lib/ld-*so.?
|
|
|
|
fi
|
|
|
|
|
2009-02-01 21:44:56 +00:00
|
|
|
# On x86_64, ld-linux-x86-64.so.2 barfs on patchelf'ed programs. So
|
|
|
|
# use a copy of patchelf.
|
2010-08-01 23:00:14 +01:00
|
|
|
LD_LIBRARY_PATH=$out/lib $LD_BINARY $out/bin/cp $out/bin/patchelf .
|
2009-02-01 21:44:56 +00:00
|
|
|
|
|
|
|
for i in $out/bin/* $out/libexec/gcc/*/*/*; do
|
|
|
|
echo patching $i
|
|
|
|
if ! test -L $i; then
|
2010-08-01 23:00:14 +01:00
|
|
|
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
|
2009-11-08 00:32:12 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
for i in $out/lib/librt* ; do
|
|
|
|
echo patching $i
|
|
|
|
if ! test -L $i; then
|
2010-08-01 23:00:14 +01:00
|
|
|
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
|
2010-08-01 22:22:51 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2010-08-21 13:50:49 +01:00
|
|
|
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
|
2010-08-01 23:00:14 +01:00
|
|
|
echo trying to patch $i
|
2010-08-01 22:22:51 +01:00
|
|
|
if test -f $i -a ! -L $i; then
|
2010-08-01 23:00:14 +01:00
|
|
|
LD_LIBRARY_PATH=$out/lib $LD_BINARY \
|
2010-08-01 22:22:51 +01:00
|
|
|
$out/bin/patchelf --set-rpath $out/lib --force-rpath $i
|
2010-08-01 23:00:14 +01:00
|
|
|
LD_LIBRARY_PATH=$out/lib $LD_BINARY \
|
2010-08-01 22:22:51 +01:00
|
|
|
$out/bin/patchelf --set-rpath $out/lib --force-rpath $i
|
2009-02-01 21:44:56 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Fix the libc linker script.
|
|
|
|
export PATH=$out/bin
|
|
|
|
cat $out/lib/libc.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libc.so.tmp
|
|
|
|
mv $out/lib/libc.so.tmp $out/lib/libc.so
|
2009-11-08 00:32:12 +00:00
|
|
|
cat $out/lib/libpthread.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libpthread.so.tmp
|
|
|
|
mv $out/lib/libpthread.so.tmp $out/lib/libpthread.so
|
2009-02-01 21:44:56 +00:00
|
|
|
|
|
|
|
# Provide some additional symlinks.
|
|
|
|
ln -s bash $out/bin/sh
|
|
|
|
ln -s bzip2 $out/bin/bunzip2
|
2009-11-28 19:21:33 +00:00
|
|
|
|
|
|
|
# Mimic the gunzip script as in gzip installations
|
|
|
|
cat > $out/bin/gunzip <<EOF
|
|
|
|
#!$out/bin/sh
|
|
|
|
exec $out/bin/gzip -d "\$@"
|
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/gunzip
|
2009-02-01 21:44:56 +00:00
|
|
|
|
|
|
|
# fetchurl needs curl.
|
|
|
|
bzip2 -d < $curl > $out/bin/curl
|
|
|
|
chmod +x $out/bin/curl
|