Merge 'staging' into closure-size

- there were many easy merge conflicts
- cc-wrapper needed nontrivial changes

Many other problems might've been created by interaction of the branches,
but stdenv and a few other packages build fine now.
This commit is contained in:
Vladimír Čunát
2015-04-18 11:00:58 +02:00
6303 changed files with 375447 additions and 91361 deletions

View File

@@ -1,44 +1,12 @@
let
fetch = { file, sha256 }: import <nix/fetchurl.nix> {
url = "http://tarballs.nixos.org/stdenv-linux/armv5tel/r18744/${file}";
inherit sha256;
{
busybox = import <nix/fetchurl.nix> {
url = "http://vicerveza.homeunix.net/~viric/tmp/nix/busybox";
sha256 = "1vfadk3d2v0bsvmbaz1pvpn4g1vm7p751hkdxya1lkn5n1a9px5m";
executable = true;
};
in {
sh = fetch {
file = "sh";
sha256 = "1kv3gc8h209rjc5i0rzzc4pjxq23kzq25iff89in05c9vl20mn4n";
};
bzip2 = fetch {
file = "bzip2";
sha256 = "090jrj099wl33q0iq092iljilam39pv8acli59m2af0fa9z0d9f0";
};
mkdir = fetch {
file = "mkdir";
sha256 = "01s8myfvi559dsxvbanxw71vxzjv49k4gi1qh0ak6l0qx0xq602b";
};
cpio = fetch {
file = "cpio";
sha256 = "07snc8l0mn84w2xrvdmc5yfpmlbrvl2bar8wipbpvm43nzz2qbzs";
};
ln = fetch {
file = "ln";
sha256 = "0m9fz02bashpfgwfkxmrp4wa8a5r3il52bclvf6z36vsam0vx56d";
};
curl = fetch {
file = "curl.bz2";
sha256 = "19yqdjqi31zlnqn8ss2ml60iq2a1vrwfw6dmvjqp6qbxmh7yb8n8";
};
bootstrapTools = {
url = "http://tarballs.nixos.org/stdenv-linux/armv5tel/r18744/bootstrap-tools.cpio.bz2";
sha256 = "1rn4n5kilqmv62dfjfcscbsm0w329k3gyb2v9155fsi1sl2cfzcb";
bootstrapTools = import <nix/fetchurl.nix> {
url = "http://vicerveza.homeunix.net/~viric/tmp/nix/bootstrap-tools.tar.xz";
sha256 = "39df65053bab50bc2975060c4da177266e263f30c2afba231a97d23f4c471eb8";
};
}

View File

@@ -1,11 +1,12 @@
# Use the static tools for armv5tel-linux.
(import ./armv5tel.nix) //
{
bootstrapTools = {
# Built from make-bootstrap-tools-crosspi.nix
# nixpkgs rev eb0422e4c1263a65a9b2b954fe10a1e03d67db3e
url = http://viric.name/tmp/nix/pi/bootstrap-tools.cpio.bz2;
sha256 = "1zb27x5h54k51yrvn3sy4wb1qprx8iv2kfbgklxwc0mcxp9b7ccd";
busybox = import <nix/fetchurl.nix> {
url = https://dl.dropboxusercontent.com/s/4705ffxjrxxqnh2/busybox?dl=0;
sha256 = "032maafy4akcdgccpxdxrza29pkcpm81g8kh1hv8bj2rvssly3z2";
executable = true;
};
bootstrapTools = import <nix/fetchurl.nix> {
url = https://dl.dropboxusercontent.com/s/pen8ieymeqqdvqn/bootstrap-tools.tar.xz?dl=0;
sha256 = "0kjpjwi6qw82ca02ppsih3bnhc3y150q23k9d56xzscs0xf5d0dv";
};
}

View File

@@ -0,0 +1,12 @@
{
busybox = import <nix/fetchurl.nix> {
url = https://dl.dropboxusercontent.com/s/rowzme529tc5svq/busybox?dl=0;
sha256 = "18793riwv9r1bgz6zv03c84cd0v26gxsm8wd2c7gjrwwyfg46ls4";
executable = true;
};
bootstrapTools = import <nix/fetchurl.nix> {
url = https://dl.dropboxusercontent.com/s/3jr4s5449t7zjlj/bootstrap-tools.tar.xz?dl=0;
sha256 = "1qyp871dajz5mi3yaw9sndwh4yrh1jj184wjjwaf6dpr3jir4kyd";
};
}

View File

@@ -1,39 +1,12 @@
let
fetch = { file, sha256 }: import <nix/fetchurl.nix> {
url = "http://tarballs.nixos.org/stdenv-linux/i686/r24519/${file}";
inherit sha256;
{
busybox = import <nix/fetchurl.nix> {
url = http://tarballs.nixos.org/stdenv-linux/i686/8d66a51a872af1ab58edc68a2ebddcc79958b563/busybox;
sha256 = "9278001d11bb0359d0cc1b30bd5c9823f0b9c65db127d6dfcc1f6bbc000d15a0";
executable = true;
};
in {
sh = fetch {
file = "sh";
sha256 = "1l6sdhyqjlh4m5gj3pfpi8aisp1m012lpwxfcc4v1x8g429mflmy";
};
bzip2 = fetch {
file = "bzip2";
sha256 = "1p5nkrdn52jm6rsx8x3wwjpsh83f2qsjl1qckkgnkplwhj23zjp7";
};
mkdir = fetch {
file = "mkdir";
sha256 = "02ff7i9ph9ahiapsg2v9c3pwr7sl73sk4n7ic112ljkrgwkail33";
};
cpio = fetch {
file = "cpio";
sha256 = "046if3aqqramyhrn2yxrjf4bfkl8x1bcqxhvi7ml9nrv9smx8irg";
};
curl = fetch {
file = "curl.bz2";
sha256 = "1v0yfb4gcdyqpl2fxlxjh337r28c23iqm7vwck4p4643xd55di7q";
};
bootstrapTools = {
url = http://tarballs.nixos.org/stdenv-linux/i686/r24519/bootstrap-tools.cpio.bz2;
sha256 = "0imypaxy6piwbk8ff2y1nr7yk49pqmdgdbv6g8miq1zs5yfip6ij";
bootstrapTools = import <nix/fetchurl.nix> {
url = http://tarballs.nixos.org/stdenv-linux/i686/8d66a51a872af1ab58edc68a2ebddcc79958b563/bootstrap-tools.tar.xz;
sha256 = "6bc27ce9b08adcca0298f5fe80fe67f5bbb2dffdd1d8666fd44cb76ace198a25";
};
}

View File

@@ -1,10 +1,9 @@
# Use the static tools for i686-linux. They work on x86_64-linux
# machines as well.
# Use busybox for i686-linux since it works on x86_64-linux as well.
(import ./i686.nix) //
{
bootstrapTools = {
url = http://tarballs.nixos.org/stdenv-linux/x86_64/r23302/bootstrap-tools.cpio.bz2;
sha256 = "0w89kqhx47yl0jifp2vffp073pyrqha5f312kp971smi4h41drna";
bootstrapTools = import <nix/fetchurl.nix> {
url = http://tarballs.nixos.org/stdenv-linux/x86_64/8d66a51a872af1ab58edc68a2ebddcc79958b563/bootstrap-tools.tar.xz;
sha256 = "325230b74d3d98f62ddcb595543887d09cd8421745a4eda229d2a87a1f1ed336";
};
}

View File

@@ -7,16 +7,18 @@
# The function defaults are for easy testing.
{ system ? builtins.currentSystem
, allPackages ? import ../../top-level/all-packages.nix
, platform ? null, config ? {}, lib }:
, platform ? null, config ? {}, lib ? (import ../../../lib)
, customBootstrapFiles ? null }:
rec {
bootstrapFiles =
if system == "i686-linux" then import ./bootstrap/i686.nix
if customBootstrapFiles != null then customBootstrapFiles
else if system == "i686-linux" then import ./bootstrap/i686.nix
else if system == "x86_64-linux" then import ./bootstrap/x86_64.nix
else if system == "armv5tel-linux" then import ./bootstrap/armv5tel.nix
else if system == "armv6l-linux" then import ./bootstrap/armv6l.nix
else if system == "armv7l-linux" then import ./bootstrap/armv6l.nix
else if system == "armv7l-linux" then import ./bootstrap/armv7l.nix
else if system == "mips64el-linux" then import ./bootstrap/loongson2f.nix
else abort "unsupported platform for the pure Linux stdenv";
@@ -40,51 +42,34 @@ rec {
bootstrapTools = derivation {
name = "bootstrap-tools";
builder = bootstrapFiles.sh;
builder = bootstrapFiles.busybox;
args =
if system == "armv5tel-linux" || system == "armv6l-linux"
|| system == "armv7l-linux"
then [ ./scripts/unpack-bootstrap-tools-arm.sh ]
else [ ./scripts/unpack-bootstrap-tools.sh ];
args = if system == "armv5tel-linux" then
[ "ash" "-e" ./scripts/unpack-bootstrap-tools-arm.sh ]
else
[ "ash" "-e" ./scripts/unpack-bootstrap-tools.sh ];
# FIXME: get rid of curl.
inherit (bootstrapFiles) bzip2 mkdir curl cpio;
tarball = import <nix/fetchurl.nix> {
inherit (bootstrapFiles.bootstrapTools) url sha256;
};
tarball = bootstrapFiles.bootstrapTools;
inherit system;
# Needed by the GCC wrapper.
langC = true;
langCC = true;
isGNU = true;
};
# A helper function to call gcc-wrapper.
wrapGCC =
{ gcc, libc, binutils, coreutils, name }:
lib.makeOverridable (import ../../build-support/gcc-wrapper) {
nativeTools = false;
nativeLibc = false;
inherit gcc binutils coreutils libc name;
stdenv = stage0.stdenv;
};
# This function builds the various standard environments used during
# the bootstrap. In all stages, we build an stdenv and the package
# set that can be built with that stdenv.
stageFun =
{gcc, extraAttrs ? {}, overrides ? (pkgs: {}), extraPath ? []}:
{gccPlain, glibc, binutils, coreutils, name, overrides ? (pkgs: {}), extraBuildInputs ? []}:
let
thisStdenv = import ../generic {
inherit system config;
inherit system config extraBuildInputs;
name = "stdenv-linux-boot";
preHook =
''
@@ -94,15 +79,33 @@ rec {
${commonPreHook}
'';
shell = "${bootstrapTools}/bin/sh";
initialPath = [bootstrapTools] ++ extraPath;
initialPath = [bootstrapTools];
fetchurlBoot = import ../../build-support/fetchurl {
stdenv = stage0.stdenv;
curl = bootstrapTools;
};
inherit gcc;
# Having the proper 'platform' in all the stdenvs allows getting proper
# linuxHeaders for example.
extraAttrs = extraAttrs // { inherit platform; };
cc = if isNull gccPlain
then "/no-such-path"
else lib.makeOverridable (import ../../build-support/cc-wrapper) {
nativeTools = false;
nativeLibc = false;
cc = gccPlain;
libc = glibc;
inherit binutils coreutils;
name = name;
stdenv = stage0.stdenv;
};
extraAttrs = {
# Having the proper 'platform' in all the stdenvs allows getting proper
# linuxHeaders for example.
inherit platform;
# stdenv.glibc is used by GCC build to figure out the system-level
# /usr/include directory.
inherit glibc;
};
overrides = pkgs: (overrides pkgs) // { fetchurl = thisStdenv.fetchurlBoot; };
};
@@ -117,7 +120,11 @@ rec {
# Build a dummy stdenv with no GCC or working fetchurl. This is
# because we need a stdenv to build the GCC wrapper and fetchurl.
stage0 = stageFun {
gcc = "/no-such-path";
gccPlain = null;
glibc = null;
binutils = null;
coreutils = null;
name = null;
overrides = pkgs: {
# The Glibc include directory cannot have the same prefix as the
@@ -148,17 +155,23 @@ rec {
# simply re-export those packages in the middle stage(s) using the
# overrides attribute and the inherit syntax.
stage1 = stageFun {
gcc = wrapGCC {
gcc = bootstrapTools;
libc = stage0.pkgs.glibc;
binutils = bootstrapTools;
coreutils = bootstrapTools;
name = "bootstrap-gcc-wrapper";
};
gccPlain = bootstrapTools;
inherit (stage0.pkgs) glibc;
binutils = bootstrapTools;
coreutils = bootstrapTools;
name = "bootstrap-gcc-wrapper";
# Rebuild binutils to use from stage2 onwards.
overrides = pkgs: {
binutils = pkgs.binutils.override { gold = false; };
inherit (stage0.pkgs) glibc;
# A threaded perl build needs glibc/libpthread_nonshared.a,
# which is not included in bootstrapTools, so disable threading.
# This is not an issue for the final stdenv, because this perl
# won't be included in the final stdenv and won't be exported to
# top-level pkgs as an override either.
perl = pkgs.perl.override { enableThreading = false; };
};
};
@@ -166,13 +179,12 @@ rec {
# 2nd stdenv that contains our own rebuilt binutils and is used for
# compiling our own Glibc.
stage2 = stageFun {
gcc = wrapGCC {
gcc = bootstrapTools;
libc = stage1.pkgs.glibc;
binutils = stage1.pkgs.binutils;
coreutils = bootstrapTools;
name = "bootstrap-gcc-wrapper";
};
gccPlain = bootstrapTools;
inherit (stage1.pkgs) glibc;
binutils = stage1.pkgs.binutils;
coreutils = bootstrapTools;
name = "bootstrap-gcc-wrapper";
overrides = pkgs: {
inherit (stage1.pkgs) perl binutils paxctl;
# This also contains the full, dynamically linked, final Glibc.
@@ -184,46 +196,53 @@ rec {
# one uses the rebuilt Glibc from stage2. It still uses the recent
# binutils and rest of the bootstrap tools, including GCC.
stage3 = stageFun {
gcc = wrapGCC {
gcc = bootstrapTools;
libc = stage2.pkgs.glibc;
binutils = stage2.pkgs.binutils;
coreutils = bootstrapTools;
name = "bootstrap-gcc-wrapper";
};
gccPlain = bootstrapTools;
inherit (stage2.pkgs) glibc binutils;
coreutils = bootstrapTools;
name = "bootstrap-gcc-wrapper";
overrides = pkgs: {
inherit (stage2.pkgs) binutils glibc perl;
inherit (stage2.pkgs) binutils glibc perl patchelf linuxHeaders;
# Link GCC statically against GMP etc. This makes sense because
# these builds of the libraries are only used by GCC, so it
# reduces the size of the stdenv closure.
gmp = pkgs.gmp.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
mpfr = pkgs.mpfr.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
mpc = pkgs.mpc.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
libmpc = pkgs.libmpc.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
isl = pkgs.isl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
cloog = pkgs.cloog.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
ppl = pkgs.ppl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
gccPlain = pkgs.gcc.cc;
};
extraAttrs = {
glibc = stage2.pkgs.glibc; # Required by gcc47 build
};
extraPath = [ stage2.pkgs.patchelf stage2.pkgs.paxctl ];
extraBuildInputs = [ stage2.pkgs.patchelf stage2.pkgs.paxctl ];
};
# Construct a fourth stdenv that uses the new GCC. But coreutils is
# still from the bootstrap tools.
stage4 = stageFun {
gcc = wrapGCC {
gcc = stage3.pkgs.gcc.gcc;
libc = stage3.pkgs.glibc;
binutils = stage3.pkgs.binutils;
coreutils = bootstrapTools;
name = "";
};
extraPath = [ stage2.pkgs.patchelf stage3.pkgs.xz ];
inherit (stage3.pkgs) gccPlain glibc binutils;
coreutils = bootstrapTools;
name = "";
overrides = pkgs: {
inherit (stage3.pkgs) gettext gnum4 gmp perl glibc;
# Zlib has to be inherited and not rebuilt in this stage,
# because gcc (since JAR support) already depends on zlib, and
# then if we already have a zlib we want to use that for the
# other purposes (binutils and top-level pkgs) too.
inherit (stage3.pkgs) gettext gnum4 gmp perl glibc zlib linuxHeaders;
gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
nativeTools = false;
nativeLibc = false;
cc = stage4.stdenv.cc.cc;
libc = stage4.pkgs.glibc;
inherit (stage4.pkgs) binutils coreutils;
name = "";
stdenv = stage4.stdenv;
shell = stage4.pkgs.bash + "/bin/bash";
};
};
extraBuildInputs = [ stage3.pkgs.patchelf stage3.pkgs.xz ];
};
@@ -250,14 +269,9 @@ rec {
extraBuildInputs = [ stage4.pkgs.patchelf stage4.pkgs.paxctl ];
shell = stage4.pkgs.bash + "/bin/bash";
cc = stage4.pkgs.gcc;
gcc = (wrapGCC rec {
gcc = stage4.stdenv.gcc.gcc;
libc = stage4.pkgs.glibc;
inherit (stage4.pkgs) binutils coreutils;
name = "";
}).override { inherit shell; };
shell = cc.shell;
inherit (stage4.stdenv) fetchurlBoot;
@@ -267,13 +281,70 @@ rec {
shellPackage = stage4.pkgs.bash;
};
/* outputs TODO
allowedRequisites = with stage4.pkgs;
[ gzip bzip2 xz bash binutils coreutils diffutils findutils gawk
glibc gnumake gnused gnutar gnugrep gnupatch patchelf attr acl
paxctl zlib pcre linuxHeaders ed gcc gcc.cc libsigsegv
];
*/
overrides = pkgs: {
inherit gcc;
gcc = cc;
inherit (stage4.pkgs)
gzip bzip2 xz bash binutils coreutils diffutils findutils gawk
glibc gnumake gnused gnutar gnugrep gnupatch patchelf
attr acl paxctl;
attr acl paxctl zlib pcre;
};
};
testBootstrapTools = let
defaultPkgs = allPackages { inherit system platform; };
in derivation {
name = "test-bootstrap-tools";
inherit system;
builder = bootstrapFiles.busybox;
args = [ "ash" "-e" "-c" "eval \"$buildCommand\"" ];
buildCommand = ''
export PATH=${bootstrapTools}/bin
ls -l
mkdir $out
mkdir $out/bin
sed --version
find --version
diff --version
patch --version
make --version
awk --version
grep --version
gcc --version
curl --version
ldlinux=$(echo ${bootstrapTools}/lib/ld-linux*.so.?)
export CPP="cpp -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools}"
export CC="gcc -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${bootstrapTools}/lib"
export CXX="g++ -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${bootstrapTools}/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 ${defaultPkgs.hello.src}
cd hello-*
./configure --prefix=$out
make
make install
'';
};
}

View File

@@ -1,10 +1,26 @@
{system ? builtins.currentSystem}:
let buildFor = toolsArch: (
let
pkgsFun = import ../../top-level/all-packages.nix;
pkgsNoParams = pkgsFun {};
sheevaplugCrossSystem = {
crossSystem = rec {
config = "armv5tel-unknown-linux-gnueabi";
bigEndian = false;
arch = "arm";
float = "soft";
withTLS = true;
libc = "glibc";
platform = pkgsNoParams.platforms.sheevaplug;
openssl.system = "linux-generic32";
};
};
raspberrypiCrossSystem = {
crossSystem = {
crossSystem = rec {
config = "armv6l-unknown-linux-gnueabi";
bigEndian = false;
arch = "arm";
@@ -14,51 +30,34 @@ let
libc = "glibc";
platform = pkgsNoParams.platforms.raspberrypi;
openssl.system = "linux-generic32";
gcc = {
arch = "armv6";
fpu = "vfp";
float = "hard";
};
inherit (platform) gcc;
};
};
raspberrypiCrossSystemUclibc = {
crossSystem = {
config = "armv6l-unknown-linux-gnueabi";
beagleboneCrossSystem = {
crossSystem = rec {
config = "armv7l-unknown-linux-gnueabi";
bigEndian = false;
arch = "arm";
float = "hard";
fpu = "vfp";
fpu = "vfpv3-d16";
withTLS = true;
libc = "uclibc";
platform = pkgsNoParams.platforms.raspberrypi;
libc = "glibc";
platform = pkgsNoParams.platforms.beaglebone;
openssl.system = "linux-generic32";
gcc = {
arch = "armv6";
fpu = "vfp";
float = "hard";
};
uclibc.extraConfig = ''
ARCH_WANTS_BIG_ENDIAN n
ARCH_BIG_ENDIAN n
ARCH_WANTS_LITTLE_ENDIAN y
ARCH_LITTLE_ENDIAN y
'';
inherit (platform) gcc;
};
};
selectedCrossSystem =
if toolsArch == "armv5tel" then sheevaplugCrossSystem else
if toolsArch == "armv6l" then raspberrypiCrossSystem else
if toolsArch == "armv7l" then beagleboneCrossSystem else null;
pkgsuclibc = pkgsFun ({inherit system;} // raspberrypiCrossSystemUclibc);
pkgs = pkgsFun ({inherit system;} // raspberrypiCrossSystem);
pkgs = pkgsFun ({inherit system;} // selectedCrossSystem);
inherit (pkgs) stdenv nukeReferences cpio binutilsCross;
# We want coreutils without ACL support.
coreutils_base = pkgs.coreutils.override (args: {
aclSupport = false;
});
coreutils_ = coreutils_base.crossDrv;
glibc = pkgs.libcCross;
bash = pkgs.bash.crossDrv;
findutils = pkgs.findutils.crossDrv;
@@ -72,37 +71,49 @@ let
gnumake = pkgs.gnumake.crossDrv;
patch = pkgs.patch.crossDrv;
patchelf = pkgs.patchelf.crossDrv;
replace = pkgs.replace.crossDrv;
gcc = pkgs.gcc;
gmp = pkgs.gmp.crossDrv;
gcc = pkgs.gcc.cc.crossDrv;
gmpxx = pkgs.gmpxx.crossDrv;
mpfr = pkgs.mpfr.crossDrv;
ppl = pkgs.ppl.crossDrv;
cloogppl = pkgs.cloogppl.crossDrv;
cloog = pkgs.cloog.crossDrv;
zlib = pkgs.zlib.crossDrv;
isl = pkgs.isl.crossDrv;
mpc = pkgs.mpc.crossDrv;
libmpc = pkgs.libmpc.crossDrv;
binutils = pkgs.binutils.crossDrv;
klibc = pkgs.linuxPackages.klibc.crossDrv;
libelf = pkgs.libelf.crossDrv;
in
rec {
curlStatic = import <nixpkgs/pkgs/tools/networking/curl> {
stdenv = pkgsuclibc.stdenv;
inherit (pkgsuclibc) fetchurl;
# We want coreutils without ACL support.
coreutilsMinimal = (pkgs.coreutils.override (args: {
aclSupport = false;
})).crossDrv;
curlMinimal = (pkgs.curl.override {
zlibSupport = false;
sslSupport = false;
linkStatic = true;
};
bzip2Static = import <nixpkgs/pkgs/tools/compression/bzip2> {
stdenv = pkgsuclibc.stdenv;
inherit (pkgsuclibc) fetchurl;
linkStatic = true;
};
scpSupport = false;
}).crossDrv;
busyboxMinimal = (pkgs.busybox.override {
# TBD: uClibc is broken.
# useUclibc = true;
enableStatic = true;
enableMinimal = true;
extraConfig = ''
CONFIG_ASH y
CONFIG_ASH_BUILTIN_ECHO y
CONFIG_ASH_BUILTIN_TEST y
CONFIG_ASH_OPTIMIZE_FOR_SIZE y
CONFIG_MKDIR y
CONFIG_TAR y
CONFIG_UNXZ y
'';
}).crossDrv;
inherit pkgs;
build =
@@ -128,6 +139,8 @@ rec {
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/libnss*.so* $out/lib
cp -d ${glibc}/lib/libresolv*.so* $out/lib
cp -d ${glibc}/lib/crt?.o $out/lib
cp -rL ${glibc}/include $out
@@ -140,7 +153,7 @@ rec {
mv $out/include $out/include-glibc
# Copy coreutils, bash, etc.
cp ${coreutils_}/bin/* $out/bin
cp ${coreutilsMinimal}/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
@@ -148,7 +161,7 @@ rec {
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 -d ${gnugrep}/bin/grep $out/bin
cp ${gawk}/bin/gawk $out/bin
cp -d ${gawk}/bin/awk $out/bin
cp ${gnutar}/bin/tar $out/bin
@@ -157,17 +170,18 @@ rec {
cp -d ${gnumake}/bin/* $out/bin
cp -d ${patch}/bin/* $out/bin
cp ${patchelf}/bin/* $out/bin
cp ${replace}/bin/* $out/bin
cp ${curlMinimal}/bin/curl $out/bin
cp -d ${curlMinimal}/lib/libcurl* $out/lib
cp -d ${gnugrep.pcre.crossDrv}/lib/libpcre*.so* $out/lib # needed by grep
# Copy what we need of GCC.
cp -d ${gcc.gcc.crossDrv}/bin/gcc $out/bin
cp -d ${gcc.gcc.crossDrv}/bin/cpp $out/bin
cp -d ${gcc.gcc.crossDrv}/bin/g++ $out/bin
cp -d ${gcc.gcc.crossDrv}/lib*/libgcc_s.so* $out/lib
cp -d ${gcc.gcc.crossDrv}/lib*/libstdc++.so* $out/lib
cp -rd ${gcc.gcc.crossDrv}/lib/gcc $out/lib
cp -d ${gcc}/bin/gcc $out/bin
cp -d ${gcc}/bin/cpp $out/bin
cp -d ${gcc}/bin/g++ $out/bin
cp -d ${gcc}/lib*/libgcc_s.so* $out/lib
cp -d ${gcc}/lib*/libstdc++.so* $out/lib
cp -rd ${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
@@ -175,26 +189,31 @@ rec {
rm -f $out/lib/gcc/*/*/include-fixed/asm
rm -rf $out/lib/gcc/*/*/plugin
#rm -f $out/lib/gcc/*/*/*.a
cp -rd ${gcc.gcc.crossDrv}/libexec/* $out/libexec
cp -rd ${gcc}/libexec/* $out/libexec
chmod -R u+w $out/libexec
rm -rf $out/libexec/gcc/*/*/plugin
mkdir $out/include
cp -rd ${gcc.gcc.crossDrv}/include/c++ $out/include
cp -rd ${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 ${gmpxx}/lib/libgmp*.so* $out/lib
cp -d ${mpfr}/lib/libmpfr*.so* $out/lib
cp -d ${libmpc}/lib/libmpc*.so* $out/lib
cp -d ${zlib}/lib/libz.so* $out/lib
cp -d ${libelf}/lib/libelf.so* $out/lib
# TBD: Why are these needed for cross but not native tools?
cp -d ${cloogppl}/lib/libcloog*.so* $out/lib
cp -d ${cloog}/lib/libcloog*.so* $out/lib
cp -d ${ppl}/lib/libppl*.so* $out/lib
cp -d ${isl}/lib/libisl*.so* $out/lib
cp -d ${mpc}/lib/libmpc*.so* $out/lib
cp -d ${zlib}/lib/libz.so* $out/lib
# Copy binutils.
for i in as ld ar ranlib nm strip readelf objdump; do
cp ${binutils}/bin/$i $out/bin
done
cp -d ${binutils}/lib/lib*.so* $out/lib
chmod -R u+w $out
@@ -209,26 +228,16 @@ rec {
nuke-refs $out/bin/*
nuke-refs $out/lib/*
nuke-refs $out/libexec/gcc/*/*/*
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 ${klibc}/lib/klibc/bin.static/ln $out/in-nixpkgs
cp ${curlStatic.crossDrv}/bin/curl $out/in-nixpkgs
cp ${bzip2Static.crossDrv}/bin/bzip2 $out/in-nixpkgs
chmod u+w $out/in-nixpkgs/*
$crossConfig-strip $out/in-nixpkgs/*
nuke-refs $out/in-nixpkgs/*
bzip2 $out/in-nixpkgs/curl
tar cvfJ $out/on-server/bootstrap-tools.tar.xz -C $out/pack .
cp ${busyboxMinimal}/bin/busybox $out/on-server
chmod u+w $out/on-server/busybox
nuke-refs $out/on-server/busybox
''; # */
# The result should not contain any references (store paths) so
@@ -237,33 +246,10 @@ rec {
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 --force-rpath $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"];
};
}
); in {
armv5tel = buildFor "armv5tel";
armv6l = buildFor "armv6l";
armv7l = buildFor "armv7l";
}

View File

@@ -1,4 +1,4 @@
{system ? builtins.currentSystem}:
{ system ? builtins.currentSystem }:
with import ../../top-level/all-packages.nix {inherit system;};
@@ -6,84 +6,32 @@ rec {
# We want coreutils without ACL support.
coreutils_ = coreutils.override (args: {
coreutilsMinimal = coreutils.override (args: {
aclSupport = false;
});
# bzip2 wants utime.h, a header 'legacy' in uclibc
uclibcForBzip2 = uclibc.override {
extraConfig = ''
UCLIBC_SUSV3_LEGACY y
UCLIBC_SUSV4_LEGACY y
'';
};
gccLinkStatic = wrapGCCWith (import ../../build-support/gcc-wrapper) uclibcForBzip2
stdenv.gcc.gcc;
stdenvLinkStatic = overrideGCC stdenv gccLinkStatic;
curlStatic = import ../../tools/networking/curl {
stdenv = stdenvLinkStatic;
inherit fetchurl;
curlMinimal = curl.override {
zlibSupport = false;
sslSupport = false;
linkStatic = true;
scpSupport = false;
};
bzip2Static = import ../../tools/compression/bzip2 {
stdenv = stdenvLinkStatic;
inherit fetchurl;
linkStatic = true;
};
#gccNoShared = wrapGCC ( gcc.gcc.override { enableShared = false; } );
busyboxStaticSh = busybox.override {
busyboxMinimal = busybox.override {
useUclibc = true;
enableStatic = true;
enableMinimal = true;
extraConfig = ''
CLEAR
CONFIG_STATIC y
CONFIG_ASH y
CONFIG_BASH_COMPAT y
CONFIG_ASH_ALIAS y
CONFIG_ASH_GETOPTS y
CONFIG_ASH_CMDCMD y
CONFIG_ASH_JOB_CONTROL y
CONFIG_ASH_BUILTIN_ECHO y
CONFIG_ASH_BUILTIN_PRINTF y
CONFIG_ASH_BUILTIN_TEST y
'';
};
busyboxStaticLn = busybox.override {
extraConfig = ''
CLEAR
CONFIG_STATIC y
CONFIG_LN y
'';
};
busyboxStaticMkdir = busybox.override {
extraConfig = ''
CLEAR
CONFIG_STATIC y
CONFIG_ASH_OPTIMIZE_FOR_SIZE y
CONFIG_MKDIR y
CONFIG_TAR y
CONFIG_UNXZ y
'';
};
busyboxStaticCpio = busybox.override {
extraConfig = ''
CLEAR
CONFIG_STATIC y
CONFIG_CPIO y
# (shlevy) Are these necessary?
CONFIG_FEATURE_CPIO_O y
CONFIG_FEATURE_CPIO_P y
'';
};
build =
build =
stdenv.mkDerivation {
name = "build";
@@ -91,7 +39,7 @@ rec {
buildInputs = [nukeReferences cpio];
buildCommand = ''
set -x
set -x
mkdir -p $out/bin $out/lib $out/libexec
# Copy what we need of Glibc.
@@ -104,27 +52,29 @@ rec {
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/libnss*.so* $out/lib
cp -d ${glibc}/lib/libresolv*.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
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.
cp ${coreutils_}/bin/* $out/bin
cp ${coreutilsMinimal}/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 -d ${gnugrep}/bin/grep $out/bin
cp ${gawk}/bin/gawk $out/bin
cp -d ${gawk}/bin/awk $out/bin
cp ${gnutar}/bin/tar $out/bin
@@ -133,16 +83,18 @@ rec {
cp -d ${gnumake}/bin/* $out/bin
cp -d ${patch}/bin/* $out/bin
cp ${patchelf}/bin/* $out/bin
cp ${curlMinimal}/bin/curl $out/bin
cp -d ${curlMinimal}/lib/libcurl* $out/lib
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
cp -d ${gcc.cc}/bin/gcc $out/bin
cp -d ${gcc.cc}/bin/cpp $out/bin
cp -d ${gcc.cc}/bin/g++ $out/bin
cp -d ${gcc.cc}/lib*/libgcc_s.so* $out/lib
cp -d ${gcc.cc}/lib*/libstdc++.so* $out/lib
cp -rd ${gcc.cc}/lib/gcc $out/lib
chmod -R u+w $out/lib
rm -f $out/lib/gcc/*/*/include*/linux
rm -f $out/lib/gcc/*/*/include*/sound
@@ -150,28 +102,29 @@ rec {
rm -f $out/lib/gcc/*/*/include-fixed/asm
rm -rf $out/lib/gcc/*/*/plugin
#rm -f $out/lib/gcc/*/*/*.a
cp -rd ${gcc.gcc}/libexec/* $out/libexec
cp -rd ${gcc.cc}/libexec/* $out/libexec
chmod -R u+w $out/libexec
rm -rf $out/libexec/gcc/*/*/plugin
mkdir $out/include
cp -rd ${gcc.gcc}/include/c++ $out/include
cp -rd ${gcc.cc}/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 ${gmpxx}/lib/libgmp*.so* $out/lib
cp -d ${mpfr}/lib/libmpfr*.so* $out/lib
cp -d ${ppl}/lib/libppl*.so* $out/lib
cp -d ${cloogppl}/lib/libcloog*.so* $out/lib
cp -d ${mpc}/lib/libmpc*.so* $out/lib
cp -d ${libmpc}/lib/libmpc*.so* $out/lib
cp -d ${zlib}/lib/libz.so* $out/lib
cp -d ${libelf}/lib/libelf.so* $out/lib
# Copy binutils.
for i in as ld ar ranlib nm strip readelf objdump; do
cp ${binutils}/bin/$i $out/bin
done
cp -d ${binutils}/lib/lib*.so* $out/lib
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
@@ -189,19 +142,10 @@ rec {
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 ${busyboxStaticSh}/bin/busybox $out/in-nixpkgs/sh
cp ${busyboxStaticCpio}/bin/busybox $out/in-nixpkgs/cpio
cp ${busyboxStaticMkdir}/bin/busybox $out/in-nixpkgs/mkdir
cp ${busyboxStaticLn}/bin/busybox $out/in-nixpkgs/ln
cp ${curlStatic}/bin/curl $out/in-nixpkgs
cp ${bzip2Static}/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
tar cvfJ $out/on-server/bootstrap-tools.tar.xz -C $out/pack .
cp ${busyboxMinimal}/bin/busybox $out/on-server
chmod u+w $out/on-server/busybox
nuke-refs $out/on-server/busybox
''; # */
# The result should not contain any references (store paths) so
@@ -210,81 +154,12 @@ rec {
allowedReferences = [];
};
unpack =
test = ((import ./default.nix) {
inherit system;
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 --force-rpath $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"];
customBootstrapFiles = {
busybox = "${build}/on-server/busybox";
bootstrapTools = "${build}/on-server/bootstrap-tools.tar.xz";
};
test =
stdenv.mkDerivation {
name = "test";
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
''; # */
};
}).testBootstrapTools;
}

View File

@@ -2,8 +2,8 @@ set -e
# Unpack the bootstrap tools tarball.
echo Unpacking the bootstrap tools...
$mkdir $out
$bzip2 -d < $tarball | (cd $out && $cpio -V -i)
$builder mkdir $out
< $tarball $builder unxz | $builder tar x -C $out
# Set the ELF interpreter / RPATH in the bootstrap binaries.
echo Patching the bootstrap tools...
@@ -23,7 +23,7 @@ for i in $out/bin/* $out/libexec/gcc/*/*/* $out/lib/librt*; do
LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \
$out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i
done
for i in $out/lib/librt* $out/lib/libcloog* $out/lib/libppl* $out/lib/libgmp*; do
for i in $out/lib/librt* $out/lib/libcloog* $out/lib/libppl* $out/lib/libgmp* $out/lib/libpcre*; do
if ! test -f $i; then continue; fi
if test -L $i; then continue; fi
echo patching $i
@@ -44,13 +44,21 @@ mv $out/lib/libpthread.so.tmp $out/lib/libpthread.so
ln -s bash $out/bin/sh
ln -s bzip2 $out/bin/bunzip2
# Mimic the gunzip script as in gzip installations
# Provide a gunzip script
cat > $out/bin/gunzip <<EOF
#!$out/bin/sh
exec $out/bin/gzip -d "\$@"
EOF
chmod +x $out/bin/gunzip
# fetchurl needs curl.
bzip2 -d < $curl > $out/bin/curl
chmod +x $out/bin/curl
# Provide fgrep/egrep.
echo "#! $out/bin/sh" > $out/bin/egrep
echo "exec $out/bin/grep -E \"\$@\"" >> $out/bin/egrep
echo "#! $out/bin/sh" > $out/bin/fgrep
echo "exec $out/bin/grep -F \"\$@\"" >> $out/bin/fgrep
# Provide xz (actually only xz -d will work).
echo "#! $out/bin/sh" > $out/bin/xz
echo "exec $builder unxz \"\$@\"" >> $out/bin/xz
chmod +x $out/bin/egrep $out/bin/fgrep $out/bin/xz

View File

@@ -1,9 +1,7 @@
set -e
# Unpack the bootstrap tools tarball.
echo Unpacking the bootstrap tools...
$mkdir $out
$bzip2 -d < $tarball | (cd $out && $cpio -i)
$builder mkdir $out
< $tarball $builder unxz | $builder tar x -C $out
# Set the ELF interpreter / RPATH in the bootstrap binaries.
echo Patching the bootstrap tools...
@@ -21,32 +19,17 @@ fi
LD_LIBRARY_PATH=$out/lib $LD_BINARY $out/bin/cp $out/bin/patchelf .
for i in $out/bin/* $out/libexec/gcc/*/*/*; do
echo patching $i
if ! test -L $i; then
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
fi
done
for i in $out/lib/librt* ; do
echo patching $i
if ! test -L $i; then
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
fi
if [ -L "$i" ]; then continue; fi
if [ -z "${i##*/liblto*}" ]; then continue; fi
echo patching "$i"
LD_LIBRARY_PATH=$out/lib $LD_BINARY \
$out/bin/patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath "$i"
done
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
echo trying to patch $i
if test -f $i -a ! -L $i; then
LD_LIBRARY_PATH=$out/lib $LD_BINARY \
$out/bin/patchelf --set-rpath $out/lib --force-rpath $i
LD_LIBRARY_PATH=$out/lib $LD_BINARY \
$out/bin/patchelf --set-rpath $out/lib --force-rpath $i
fi
for i in $out/lib/librt-*.so $out/lib/libpcre*; do
if [ -L "$i" ]; then continue; fi
echo patching "$i"
$out/bin/patchelf --set-rpath $out/lib --force-rpath "$i"
done
# Fix the libc linker script.
@@ -60,13 +43,21 @@ mv $out/lib/libpthread.so.tmp $out/lib/libpthread.so
ln -s bash $out/bin/sh
ln -s bzip2 $out/bin/bunzip2
# Mimic the gunzip script as in gzip installations
# Provide a gunzip script.
cat > $out/bin/gunzip <<EOF
#!$out/bin/sh
exec $out/bin/gzip -d "\$@"
EOF
chmod +x $out/bin/gunzip
# fetchurl needs curl.
bzip2 -d < $curl > $out/bin/curl
chmod +x $out/bin/curl
# Provide fgrep/egrep.
echo "#! $out/bin/sh" > $out/bin/egrep
echo "exec $out/bin/grep -E \"\$@\"" >> $out/bin/egrep
echo "#! $out/bin/sh" > $out/bin/fgrep
echo "exec $out/bin/grep -F \"\$@\"" >> $out/bin/fgrep
# Provide xz (actually only xz -d will work).
echo "#! $out/bin/sh" > $out/bin/xz
echo "exec $builder unxz \"\$@\"" >> $out/bin/xz
chmod +x $out/bin/egrep $out/bin/fgrep $out/bin/xz