2012-09-19 11:48:27 +02:00
|
|
|
{ stdenv, fetchurl, dpkg, gettext, gawk, perl, wget, coreutils, fakeroot }:
|
2009-10-08 02:54:31 +02:00
|
|
|
|
2010-07-28 13:55:54 +02:00
|
|
|
let
|
|
|
|
|
2012-09-19 11:48:27 +02:00
|
|
|
# USAGE like this: debootstrap sid /tmp/target-chroot-directory
|
|
|
|
|
|
|
|
# There is also cdebootstrap now. Is that easier to maintain?
|
|
|
|
|
|
|
|
makedev = stdenv.mkDerivation {
|
|
|
|
name = "makedev-for-debootstrap";
|
|
|
|
src = fetchurl {
|
2012-10-05 10:26:13 +02:00
|
|
|
url = mirror://debian/pool/main/m/makedev/makedev_2.3.1.orig.tar.gz;
|
2012-09-19 11:48:27 +02:00
|
|
|
sha256 = "1yhxlj2mhn1nqkx1f0sn0bl898nf28arxxa4lgp7hdrb5cpp36c5";
|
|
|
|
};
|
|
|
|
patches = [
|
|
|
|
(fetchurl {
|
|
|
|
url = "http://ftp.de.debian.org/debian/pool/main/m/makedev/makedev_2.3.1-89.diff.gz";
|
|
|
|
sha256 = "1zbifw2jkq6471fb67y893nq4lq009xbfbi57jbjwxnhqmrppcy9";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
# TODO install man
|
|
|
|
installPhase = ''
|
|
|
|
ensureDir $out/sbin
|
|
|
|
ls -l
|
|
|
|
t=$out/sbin/MAKEDEV
|
|
|
|
cp MAKEDEV $t
|
|
|
|
chmod +x $t
|
|
|
|
'';
|
2009-10-08 02:54:31 +02:00
|
|
|
};
|
2010-07-28 13:55:54 +02:00
|
|
|
|
2009-10-08 02:54:31 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2012-09-19 11:48:27 +02:00
|
|
|
|
|
|
|
name = "debootstrap-1.0.42";
|
2009-10-08 02:54:31 +02:00
|
|
|
|
|
|
|
src = fetchurl {
|
2012-09-19 11:48:27 +02:00
|
|
|
# git clone git://git.debian.org/d-i/debootstrap.git
|
|
|
|
# I'd like to use the source. However it's lacking the lanny script ? (still true?)
|
|
|
|
url = http://ftp.de.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.42.tar.gz;
|
|
|
|
sha256 = "0a5azl22wz1q92b2c91zlpz6krd7wqyi63yk87vyczp363ml0nz0";
|
2009-10-08 02:54:31 +02:00
|
|
|
};
|
2012-09-19 11:48:27 +02:00
|
|
|
|
2010-07-28 13:55:54 +02:00
|
|
|
buildInputs = [ dpkg gettext gawk perl ];
|
2009-10-08 02:54:31 +02:00
|
|
|
|
|
|
|
buildPhase = ":";
|
|
|
|
|
2012-09-19 11:48:27 +02:00
|
|
|
# If you have to update the patch for functions a vim regex like this
|
|
|
|
# can help you identify which lines are used to write scripts on TARGET and
|
|
|
|
# which should /bin/ paths should be replaced:
|
|
|
|
# \<echo\>\|\/bin\/\|^\s*\<cat\>\|EOF\|END
|
2009-10-08 02:54:31 +02:00
|
|
|
installPhase = ''
|
|
|
|
|
2012-09-19 11:48:27 +02:00
|
|
|
sed -i \
|
|
|
|
-e 's@/usr/bin/id@id@' \
|
|
|
|
-e 's@/usr/bin/dpkg@${dpkg}/bin/dpkg@' \
|
|
|
|
-e 's@/usr/bin/sha@${coreutils}/bin/sha@' \
|
|
|
|
-e 's@/bin/sha@${coreutils}/bin/sha@' \
|
|
|
|
debootstrap
|
|
|
|
|
|
|
|
|
|
|
|
for file in functions debootstrap; do
|
2009-10-08 02:54:31 +02:00
|
|
|
substituteInPlace "$file" \
|
|
|
|
--subst-var-by gunzip "$(type -p gunzip)" \
|
|
|
|
--subst-var-by bunzip "$(type -p bunzip)" \
|
|
|
|
--subst-var-by gettext "$(type -p gettext)" \
|
|
|
|
--subst-var-by dpkg "$(type -p dpkg)" \
|
|
|
|
--subst-var-by udpkg "$(type -p udpkg)" \
|
|
|
|
--subst-var-by id "$(type -p id)" \
|
|
|
|
--subst-var-by perl "$(type -p perl)" \
|
|
|
|
--subst-var-by uname "$(type -p uname)" \
|
|
|
|
--subst-var-by wget "${wget}/bin/wget"
|
|
|
|
done
|
|
|
|
|
2012-09-19 11:48:27 +02:00
|
|
|
|
2009-10-08 02:54:31 +02:00
|
|
|
sed -i \
|
2012-09-19 11:48:27 +02:00
|
|
|
-e 's@\<wget\>@${wget}/bin/wget@' \
|
|
|
|
functions
|
|
|
|
|
|
|
|
d=$out/share/debootstrap
|
|
|
|
ensureDir $out/{share/debootstrap,bin}
|
|
|
|
|
|
|
|
${fakeroot}/bin/fakeroot -- make devices.tar.gz MAKEDEV=${makedev}/sbin/MAKEDEV
|
|
|
|
|
|
|
|
cp -r . $d
|
|
|
|
|
|
|
|
cat >> $out/bin/debootstrap << EOF
|
2009-10-08 02:54:31 +02:00
|
|
|
#!/bin/sh
|
2012-09-19 11:48:27 +02:00
|
|
|
export DEBOOTSTRAP_DIR="''${DEBOOTSTRAP_DIR:-$d}"
|
|
|
|
# mount and other tools must be found in chroot. So add default debain paths!
|
|
|
|
# TODO only add paths which are required by the scripts!
|
|
|
|
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
exec $d/debootstrap "\$@"
|
2009-10-08 02:54:31 +02:00
|
|
|
EOF
|
2012-09-19 11:48:27 +02:00
|
|
|
chmod +x $out/bin/debootstrap
|
|
|
|
|
|
|
|
ensureDir $out/man/man8
|
|
|
|
mv debootstrap.8 $out/man/man8
|
2009-10-08 02:54:31 +02:00
|
|
|
'';
|
2012-09-19 11:48:27 +02:00
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit makedev;
|
|
|
|
};
|
2009-10-08 02:54:31 +02:00
|
|
|
|
|
|
|
meta = {
|
2010-07-28 13:55:54 +02:00
|
|
|
description = "Tool to create a Debian system in a chroot";
|
2009-10-08 02:54:31 +02:00
|
|
|
homepage = http://packages.debian.org/de/lenny/debootstrap; # http://code.erisian.com.au/Wiki/debootstrap
|
|
|
|
license = "GPL-2"; # gentoo says so.. ?
|
2010-07-28 13:55:54 +02:00
|
|
|
maintainers = [ stdenv.lib.maintainers.marcweber ];
|
|
|
|
platforms = stdenv.lib.platforms.linux;
|
2009-10-08 02:54:31 +02:00
|
|
|
};
|
|
|
|
}
|