mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 17:03:01 +00:00
svn path=/nixpkgs/branches/stdenv-updates/; revision=13914
This commit is contained in:
parent
b36fdd3d13
commit
5f66ddd3c3
@ -1,64 +1,143 @@
|
||||
{system ? builtins.currentSystem}:
|
||||
|
||||
let
|
||||
with import ../../top-level/all-packages.nix {inherit system;};
|
||||
|
||||
pkgs = import ../../top-level/all-packages.nix {inherit system;};
|
||||
rec {
|
||||
|
||||
|
||||
# Have to do removeAttrs to prevent all-packages from copying
|
||||
# stdenv-linux's dependencies, rather than building new ones with
|
||||
# dietlibc.
|
||||
pkgsToRemove =
|
||||
[ "binutils" "gcc" "coreutils" "findutils" "diffutils" "gnused" "gnugrep"
|
||||
"gawk" "gnutar" "gzip" "bzip2" "gnumake" "bash" "patch" "patchelf"
|
||||
];
|
||||
# We want coreutils without ACL support.
|
||||
coreutils_ = coreutils.function (args: {
|
||||
aclSupport = false;
|
||||
});
|
||||
|
||||
pkgsDiet = import ../../top-level/all-packages.nix {
|
||||
bootStdenv = removeAttrs (pkgs.useDietLibC pkgs.stdenv) pkgsToRemove;
|
||||
};
|
||||
|
||||
pkgsStatic = import ../../top-level/all-packages.nix {
|
||||
bootStdenv = removeAttrs (pkgs.makeStaticBinaries pkgs.stdenv) pkgsToRemove;
|
||||
gcc = gcc43;
|
||||
|
||||
|
||||
curlDiet = import ../../tools/networking/curl {
|
||||
inherit fetchurl;
|
||||
stdenv = useDietLibC stdenv;
|
||||
zlibSupport = false;
|
||||
sslSupport = false;
|
||||
};
|
||||
|
||||
|
||||
generator = pkgs.stdenv.mkDerivation {
|
||||
name = "bootstrap-tools-generator";
|
||||
builder = ./make-bootstrap-tools.sh;
|
||||
|
||||
inherit (pkgsDiet)
|
||||
coreutils diffutils gnugrep
|
||||
gzip bzip2 gnumake bash patch binutils curl;
|
||||
|
||||
findutils = pkgsDiet.findutils4227; # 4.2.28 is broken
|
||||
|
||||
gnused = pkgsDiet.gnused412; # 4.1.5 gives "Memory exhausted" errors
|
||||
|
||||
# patchelf is C++, won't work with dietlibc.
|
||||
inherit (pkgsStatic) patchelf;
|
||||
|
||||
gnutar =
|
||||
# Tar seems to be broken on dietlibc on x86_64.
|
||||
if system != "x86_64-linux"
|
||||
then pkgsDiet.gnutar151 # 1.16 is broken
|
||||
else pkgsStatic.gnutar;
|
||||
|
||||
gawk =
|
||||
# Dietlibc only provides sufficient math functions (fmod, sin,
|
||||
# cos, etc.) on i686. On other platforms, use Glibc.
|
||||
if system == "i686-linux"
|
||||
then pkgsDiet.gawk
|
||||
else pkgsStatic.gawk;
|
||||
|
||||
gcc = import ../../development/compilers/gcc-4.2 {
|
||||
inherit (pkgs) fetchurl stdenv;
|
||||
noSysDirs = true;
|
||||
langCC = false;
|
||||
staticCompiler = true;
|
||||
profiledCompiler = true;
|
||||
bzip2Diet = import ../../tools/compression/bzip2 {
|
||||
inherit fetchurl;
|
||||
stdenv = useDietLibC stdenv;
|
||||
};
|
||||
|
||||
glibc = pkgs.glibc;
|
||||
|
||||
build =
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "build";
|
||||
|
||||
buildInputs = [nukeReferences cpio];
|
||||
|
||||
buildCommand = ''
|
||||
ensureDir $out/bin $out/lib $out/libexec
|
||||
|
||||
# Copy what we need of Glibc.
|
||||
cp -d ${glibc}/lib/ld-*.so* $out/lib
|
||||
cp -d ${glibc}/lib/libc*.so* $out/lib
|
||||
cp -d ${glibc}/lib/libc_nonshared.a $out/lib
|
||||
cp -d ${glibc}/lib/libm*.so* $out/lib
|
||||
cp -d ${glibc}/lib/libdl*.so* $out/lib
|
||||
cp -d ${glibc}/lib/librt*.so* $out/lib
|
||||
cp -d ${glibc}/lib/libpthread*.so* $out/lib
|
||||
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
|
||||
mv $out/include $out/include-glibc
|
||||
|
||||
# Copy coreutils, bash, etc.
|
||||
cp ${coreutils_}/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 ${gawk}/bin/gawk $out/bin
|
||||
cp -d ${gawk}/bin/awk $out/bin
|
||||
cp ${gnutar}/bin/tar $out/bin
|
||||
cp ${gzip}/bin/gzip $out/bin
|
||||
cp ${bzip2}/bin/bzip2 $out/bin
|
||||
cp -d ${gnumake}/bin/* $out/bin
|
||||
cp -d ${patch}/bin/* $out/bin
|
||||
cp ${patchelf}/bin/* $out/bin
|
||||
cp ${replace}/bin/* $out/bin
|
||||
|
||||
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
|
||||
cp -d ${gcc.gcc}/bin/g++ $out/bin
|
||||
cp -d ${gcc.gcc}/lib*/libgcc_s.so* $out/lib
|
||||
cp -d ${gcc.gcc}/lib*/libstdc++.so* $out/lib
|
||||
cp -rd ${gcc.gcc}/lib/gcc $out/lib
|
||||
chmod -R u+w $out/lib
|
||||
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/*/*/*.a
|
||||
cp -rd ${gcc.gcc}/libexec/* $out/libexec
|
||||
mkdir $out/include
|
||||
cp -rd ${gcc.gcc}/include/c++ $out/include
|
||||
chmod -R u+w $out/include
|
||||
rm -rf $out/include/c++/*/ext/pb_ds
|
||||
rm -rf $out/include/c++/*/ext/parallel
|
||||
|
||||
cp -d ${gmp}/lib/libgmp*.so* $out/lib
|
||||
cp -d ${mpfr}/lib/libmpfr*.so* $out/lib
|
||||
|
||||
# Copy binutils.
|
||||
for i in as ld ar ranlib nm strip readelf objdump; do
|
||||
cp ${binutils}/bin/$i $out/bin
|
||||
done
|
||||
|
||||
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
|
||||
chmod +w $i
|
||||
strip -s $i || true
|
||||
fi
|
||||
done
|
||||
|
||||
nuke-refs $out/bin/*
|
||||
nuke-refs $out/lib/*
|
||||
nuke-refs $out/libexec/gcc/*/*/*
|
||||
|
||||
mkdir $out/.pack
|
||||
mv $out/* $out/.pack
|
||||
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 ${klibc}/lib/klibc/bin.static/sh $out/in-nixpkgs
|
||||
cp ${klibc}/lib/klibc/bin.static/cpio $out/in-nixpkgs
|
||||
cp ${klibc}/lib/klibc/bin.static/mkdir $out/in-nixpkgs
|
||||
cp ${curlDiet}/bin/curl $out/in-nixpkgs
|
||||
cp ${bzip2Diet}/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
|
||||
''; # */
|
||||
|
||||
# The result should not contain any references (store paths) so
|
||||
# that we can safely copy them out of the store and to other
|
||||
@ -66,4 +145,83 @@ let
|
||||
allowedReferences = [];
|
||||
};
|
||||
|
||||
in generator
|
||||
|
||||
unpack =
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "unpack";
|
||||
|
||||
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)
|
||||
|
||||
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 $i
|
||||
fi
|
||||
done
|
||||
|
||||
# Fix the libc linker script.
|
||||
for i in $out/lib/libc.so; do
|
||||
cat $i | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $i.tmp
|
||||
mv $i.tmp $i
|
||||
done
|
||||
''; # " */
|
||||
|
||||
allowedReferences = ["out"];
|
||||
};
|
||||
|
||||
|
||||
test =
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "test";
|
||||
|
||||
LD_LIBRARY_PATH = "${unpack}/lib";
|
||||
|
||||
realBuilder = "${unpack}/bin/bash";
|
||||
|
||||
buildCommand = ''
|
||||
export PATH=${unpack}/bin
|
||||
ls -l
|
||||
mkdir $out
|
||||
mkdir $out/bin
|
||||
sed --version
|
||||
find --version
|
||||
diff --version
|
||||
patch --version
|
||||
make --version
|
||||
awk --version
|
||||
grep --version
|
||||
gcc --version
|
||||
|
||||
${build}/in-nixpkgs/sh -c 'echo Hello World'
|
||||
|
||||
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
|
||||
$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
|
||||
$CXX -v -o $out/bin/bar bar.cc
|
||||
$out/bin/bar
|
||||
|
||||
tar xvf ${hello.src}
|
||||
cd hello-*
|
||||
./configure --prefix=$out
|
||||
make
|
||||
make install
|
||||
''; # */
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,168 +0,0 @@
|
||||
source $stdenv/setup
|
||||
|
||||
ensureDir $out/in-nixpkgs
|
||||
ensureDir $out/on-server
|
||||
|
||||
# Everything we put in check-only is merely to allow Nix to check that
|
||||
# we aren't putting binaries with store path references in tarballs.
|
||||
ensureDir $out/check-only
|
||||
|
||||
|
||||
export PATH=$coreutils/bin:$PATH # !!! temporary hack
|
||||
|
||||
|
||||
nukeRefs() {
|
||||
# Dirty, disgusting, but it works ;-)
|
||||
fileName=$1
|
||||
cat $fileName | sed "s|/nix/store/[a-z0-9]*-|/nix/store/ffffffffffffffffffffffffffffffff-|g" > $fileName.tmp
|
||||
if test -x $fileName; then chmod +x $fileName.tmp; fi
|
||||
mv $fileName.tmp $fileName
|
||||
}
|
||||
|
||||
|
||||
# Create the tools that need to be in-tree, i.e., the ones that are
|
||||
# necessary for the absolute first stage of the bootstrap.
|
||||
cp $bash/bin/bash $out/in-nixpkgs
|
||||
nukeRefs $out/in-nixpkgs/bash
|
||||
cp $bzip2/bin/bzip2 $out/in-nixpkgs
|
||||
cp $coreutils/bin/cp $out/in-nixpkgs
|
||||
cp $gnutar/bin/tar $out/in-nixpkgs
|
||||
nukeRefs $out/in-nixpkgs/tar
|
||||
|
||||
if test "$system" = "powerpc-linux"; then
|
||||
nukeRefs $out/in-nixpkgs/cp
|
||||
fi
|
||||
|
||||
|
||||
# Create the tools tarball.
|
||||
mkdir tools
|
||||
mkdir tools/bin
|
||||
|
||||
cp $coreutils/bin/* tools/bin
|
||||
rm tools/bin/groups # has references
|
||||
rm tools/bin/printf # idem
|
||||
|
||||
cp $findutils/bin/find tools/bin
|
||||
cp $findutils/bin/xargs tools/bin
|
||||
cp $diffutils/bin/* tools/bin
|
||||
cp $gnused/bin/* tools/bin
|
||||
cp $gnugrep/bin/* tools/bin
|
||||
cp $gawk/bin/gawk tools/bin
|
||||
ln -s gawk tools/bin/awk
|
||||
cp $gnutar/bin/* tools/bin
|
||||
cp $gzip/bin/gzip tools/bin
|
||||
cp $bzip2/bin/bzip2 tools/bin
|
||||
cp $gnumake/bin/* tools/bin
|
||||
cp $patch/bin/* tools/bin
|
||||
cp $patchelf/bin/* tools/bin
|
||||
|
||||
nukeRefs tools/bin/diff
|
||||
nukeRefs tools/bin/sed
|
||||
nukeRefs tools/bin/gawk
|
||||
nukeRefs tools/bin/tar
|
||||
nukeRefs tools/bin/grep
|
||||
nukeRefs tools/bin/fgrep
|
||||
nukeRefs tools/bin/egrep
|
||||
nukeRefs tools/bin/patchelf
|
||||
nukeRefs tools/bin/make
|
||||
|
||||
|
||||
# Create the binutils tarball.
|
||||
mkdir binutils
|
||||
mkdir binutils/bin
|
||||
for i in as ld ar ranlib nm strip readelf objdump; do
|
||||
cp $binutils/bin/$i binutils/bin
|
||||
nukeRefs binutils/bin/$i
|
||||
done
|
||||
|
||||
|
||||
# Create the gcc tarball.
|
||||
mkdir gcc
|
||||
mkdir gcc/bin
|
||||
cp $gcc/bin/gcc gcc/bin
|
||||
cp $gcc/bin/cpp gcc/bin
|
||||
nukeRefs gcc/bin/gcc
|
||||
nukeRefs gcc/bin/cpp
|
||||
cp -prd $gcc/lib gcc
|
||||
cp -prd $gcc/libexec gcc
|
||||
chmod -R +w gcc
|
||||
nukeRefs gcc/libexec/gcc/*/*/cc1
|
||||
nukeRefs gcc/libexec/gcc/*/*/collect2
|
||||
if test -e gcc/lib/libgcc_s.so.1; then
|
||||
nukeRefs gcc/lib/libgcc_s.so.1
|
||||
fi
|
||||
if test -e $gcc/lib64; then
|
||||
cp -prd $gcc/lib64 gcc
|
||||
chmod -R +w gcc/lib64
|
||||
nukeRefs gcc/lib64/libgcc_s.so.1
|
||||
fi
|
||||
rm -f gcc/lib*/libmud* gcc/lib*/libiberty* gcc/lib*/libssp* gcc/lib*/libgomp*
|
||||
rm -rf gcc/lib/gcc/*/*/install-tools
|
||||
rm -rf gcc/lib/gcc/*/*/include/root
|
||||
rm -rf gcc/lib/gcc/*/*/include/linux
|
||||
if test "$system" = "powerpc-linux"; then
|
||||
nukeRefs gcc/lib/gcc/powerpc-unknown-linux-gnu/*/include/bits/mathdef.h
|
||||
fi
|
||||
# Dangling symlink "sound", probably produced by fixinclude.
|
||||
# Should investigate why it's there in the first place.
|
||||
rm -f gcc/lib/gcc/*/*/include/sound
|
||||
|
||||
|
||||
# Create the glibc tarball.
|
||||
mkdir glibc
|
||||
mkdir glibc/lib
|
||||
cp $glibc/lib/*.a glibc/lib
|
||||
rm -f glibc/lib/*_p.a
|
||||
nukeRefs glibc/lib/libc.a
|
||||
cp $glibc/lib/*.o glibc/lib
|
||||
cp -prd $glibc/include glibc
|
||||
chmod -R +w glibc
|
||||
rm glibc/include/linux
|
||||
cp -prd $(readlink $glibc/include/linux) glibc/include
|
||||
rm glibc/include/asm
|
||||
if test -L "$(readlink $glibc/include/asm)"; then
|
||||
ln -s $(readlink $(readlink $glibc/include/asm)) glibc/include/asm
|
||||
else
|
||||
cp -prd "$(readlink $glibc/include/asm)" glibc/include
|
||||
fi
|
||||
for i in glibc/include/asm-*; do
|
||||
target=$(readlink $i)
|
||||
rm $i
|
||||
cp -prd $target glibc/include
|
||||
done
|
||||
# Hopefully we won't need these.
|
||||
rm -f glibc/include/mtd glibc/include/rdma glibc/include/sound glibc/include/video
|
||||
|
||||
|
||||
# Strip executables even further.
|
||||
for i in $out/in-nixpkgs/* */bin/* gcc/libexec/gcc/*/*/*; do
|
||||
if test -x $i; then
|
||||
chmod +w $i
|
||||
strip -s $i || true
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# Pack, unpack everything.
|
||||
bzip2 < $curl/bin/curl > $out/in-nixpkgs/curl.bz2
|
||||
bzip2 $out/in-nixpkgs/tar
|
||||
chmod +x $out/in-nixpkgs/*.bz2
|
||||
|
||||
tar cfj $out/on-server/static-tools.tar.bz2 tools
|
||||
tar cfj $out/on-server/binutils.tar.bz2 binutils
|
||||
tar cfj $out/on-server/gcc.tar.bz2 gcc
|
||||
tar cfj $out/on-server/glibc.tar.bz2 glibc
|
||||
|
||||
for i in $out/on-server/*.tar.bz2; do
|
||||
(cd $out/check-only && tar xfj $i)
|
||||
done
|
||||
|
||||
for i in $out/in-nixpkgs/*.bz2; do
|
||||
(cd $out/check-only && bunzip2 < $i > $(basename $i .bz2))
|
||||
done
|
||||
|
||||
|
||||
# Check that everything is statically linked
|
||||
for i in $(find $out -type f -perm +111); do
|
||||
if ldd $i | grep -q "=>"; then echo "not statically linked: $i"; exit 1; fi
|
||||
done
|
@ -1,227 +0,0 @@
|
||||
{system ? builtins.currentSystem}:
|
||||
|
||||
with import ../../top-level/all-packages.nix {inherit system;};
|
||||
|
||||
rec {
|
||||
|
||||
|
||||
# We want coreutils without ACL support.
|
||||
coreutils_ = coreutils.function (args: {
|
||||
aclSupport = false;
|
||||
});
|
||||
|
||||
|
||||
gcc = gcc43;
|
||||
|
||||
|
||||
curlDiet = import ../../tools/networking/curl {
|
||||
inherit fetchurl;
|
||||
stdenv = useDietLibC stdenv;
|
||||
zlibSupport = false;
|
||||
sslSupport = false;
|
||||
};
|
||||
|
||||
|
||||
bzip2Diet = import ../../tools/compression/bzip2 {
|
||||
inherit fetchurl;
|
||||
stdenv = useDietLibC stdenv;
|
||||
};
|
||||
|
||||
|
||||
build =
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "build";
|
||||
|
||||
buildInputs = [nukeReferences cpio];
|
||||
|
||||
buildCommand = ''
|
||||
ensureDir $out/bin $out/lib $out/libexec
|
||||
|
||||
# Copy what we need of Glibc.
|
||||
cp -d ${glibc}/lib/ld-*.so* $out/lib
|
||||
cp -d ${glibc}/lib/libc*.so* $out/lib
|
||||
cp -d ${glibc}/lib/libc_nonshared.a $out/lib
|
||||
cp -d ${glibc}/lib/libm*.so* $out/lib
|
||||
cp -d ${glibc}/lib/libdl*.so* $out/lib
|
||||
cp -d ${glibc}/lib/librt*.so* $out/lib
|
||||
cp -d ${glibc}/lib/libpthread*.so* $out/lib
|
||||
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
|
||||
mv $out/include $out/include-glibc
|
||||
|
||||
# Copy coreutils, bash, etc.
|
||||
cp ${coreutils_}/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 ${gawk}/bin/gawk $out/bin
|
||||
cp -d ${gawk}/bin/awk $out/bin
|
||||
cp ${gnutar}/bin/tar $out/bin
|
||||
cp ${gzip}/bin/gzip $out/bin
|
||||
cp ${bzip2}/bin/bzip2 $out/bin
|
||||
cp -d ${gnumake}/bin/* $out/bin
|
||||
cp -d ${patch}/bin/* $out/bin
|
||||
cp ${patchelf}/bin/* $out/bin
|
||||
cp ${replace}/bin/* $out/bin
|
||||
|
||||
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
|
||||
cp -d ${gcc.gcc}/bin/g++ $out/bin
|
||||
cp -d ${gcc.gcc}/lib*/libgcc_s.so* $out/lib
|
||||
cp -d ${gcc.gcc}/lib*/libstdc++.so* $out/lib
|
||||
cp -rd ${gcc.gcc}/lib/gcc $out/lib
|
||||
chmod -R u+w $out/lib
|
||||
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/*/*/*.a
|
||||
cp -rd ${gcc.gcc}/libexec/* $out/libexec
|
||||
mkdir $out/include
|
||||
cp -rd ${gcc.gcc}/include/c++ $out/include
|
||||
chmod -R u+w $out/include
|
||||
rm -rf $out/include/c++/*/ext/pb_ds
|
||||
rm -rf $out/include/c++/*/ext/parallel
|
||||
|
||||
cp -d ${gmp}/lib/libgmp*.so* $out/lib
|
||||
cp -d ${mpfr}/lib/libmpfr*.so* $out/lib
|
||||
|
||||
# Copy binutils.
|
||||
for i in as ld ar ranlib nm strip readelf objdump; do
|
||||
cp ${binutils}/bin/$i $out/bin
|
||||
done
|
||||
|
||||
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
|
||||
chmod +w $i
|
||||
strip -s $i || true
|
||||
fi
|
||||
done
|
||||
|
||||
nuke-refs $out/bin/*
|
||||
nuke-refs $out/lib/*
|
||||
nuke-refs $out/libexec/gcc/*/*/*
|
||||
|
||||
mkdir $out/.pack
|
||||
mv $out/* $out/.pack
|
||||
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 ${klibc}/lib/klibc/bin.static/sh $out/in-nixpkgs
|
||||
cp ${klibc}/lib/klibc/bin.static/cpio $out/in-nixpkgs
|
||||
cp ${klibc}/lib/klibc/bin.static/mkdir $out/in-nixpkgs
|
||||
cp ${curlDiet}/bin/curl $out/in-nixpkgs
|
||||
cp ${bzip2Diet}/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
|
||||
''; # */
|
||||
|
||||
# The result should not contain any references (store paths) so
|
||||
# that we can safely copy them out of the store and to other
|
||||
# locations in the store.
|
||||
allowedReferences = [];
|
||||
};
|
||||
|
||||
|
||||
unpack =
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "unpack";
|
||||
|
||||
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)
|
||||
|
||||
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 $i
|
||||
fi
|
||||
done
|
||||
|
||||
# Fix the libc linker script.
|
||||
for i in $out/lib/libc.so; do
|
||||
cat $i | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $i.tmp
|
||||
mv $i.tmp $i
|
||||
done
|
||||
''; # " */
|
||||
|
||||
allowedReferences = ["out"];
|
||||
};
|
||||
|
||||
|
||||
test =
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "test";
|
||||
|
||||
LD_LIBRARY_PATH = "${unpack}/lib";
|
||||
|
||||
realBuilder = "${unpack}/bin/bash";
|
||||
|
||||
buildCommand = ''
|
||||
export PATH=${unpack}/bin
|
||||
ls -l
|
||||
mkdir $out
|
||||
mkdir $out/bin
|
||||
sed --version
|
||||
find --version
|
||||
diff --version
|
||||
patch --version
|
||||
make --version
|
||||
awk --version
|
||||
grep --version
|
||||
gcc --version
|
||||
|
||||
${build}/in-nixpkgs/sh -c 'echo Hello World'
|
||||
|
||||
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
|
||||
$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
|
||||
$CXX -v -o $out/bin/bar bar.cc
|
||||
$out/bin/bar
|
||||
|
||||
tar xvf ${hello.src}
|
||||
cd hello-*
|
||||
./configure --prefix=$out
|
||||
make
|
||||
make install
|
||||
''; # */
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user