1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
#!/bin/sh -e
divert() {
prog="$1"
mv $prog $prog.real
cat > $prog <<EOF
#!/bin/sh
echo "Fake $prog called, doing nothing"
EOF
chmod 755 $prog
}
undivert() {
prog="$1"
mv $prog.real $prog
}
DEBIAN_FRONTEND=noninteractive
export DEBIAN_FRONTEND
if test -n "$debconf_preseed_file"; then
mkdir -p $TARGET/var/cache/debconf || true
for p in $WORKDIR $HOST ; do
[ ! -f "$p/$debconf_preseed_file" ] || \
(
cp $p/$debconf_preseed_file $TARGET/var/cache/debconf/config.dat ;
echo "Preseeding Debconf from $debconf_preseed_file";
)
done
# DEBCONF_DB_OVERRIDE="File{/tmp/config.dat}"
# export DEBCONF_DB_OVERRIDE
fi
if test -n "$exclude"; then
exclude=`echo $exclude | tr ' ' ,`
opts="--exclude=$exclude"
fi
if test -n "$include"; then
include=`echo $include | tr ' ' ,`
opts="$opts --include=$include"
fi
if test -n "$basedebs"; then
opts="$opts --unpack-tarball $basedebs"
fi
# DEBOOTSTRAP
echo "debootstrap $opts $dist $TARGET $mirror $script"
debootstrap $opts $dist $TARGET $mirror $script
# populate sources.list
if test -n "$sources"; then
echo "$sources" > $TARGET/etc/apt/sources.list
else
echo "deb $mirror $dist main" > $TARGET/etc/apt/sources.list
fi
# populate /etc/apt/preferences
if test -n "$preferences"; then
echo "$preferences" | sed -e 's/^\.$//' >> $TARGET/etc/apt/preferences
fi
# populate /etc/apt/apt.conf
if test -n "$apt_conf"; then
echo "$apt_conf" >> $TARGET/etc/apt/apt.conf
fi
rm -f $TARGET/var/lib/apt/lists/debootstrap.*
if test -z "$keepdebs"; then
rm -f $TARGET/var/cache/apt/archives/*.deb
fi
echo $purge | tr ' ' '\n' | xargs --no-run-if-empty -t \
chroot $TARGET dpkg --purge
echo $(hostname) > $TARGET/etc/hostname
if [ -f /etc/hosts ]; then
install -m 644 /etc/hosts $TARGET/etc/hosts
fi
# disable hwclock
echo "# Disable hwclock at startup/shutdown" >> $TARGET/etc/default/rcS
echo "HWCLOCKACCESS=no" >> $TARGET/etc/default/rcS
if test -n "$install"; then
apt_options="-y"
if test "$apt_force_yes" = "true"; then
apt_options="$apt_options --force-yes"
fi
divert $TARGET/sbin/start-stop-daemon
chroot $TARGET mount -t proc proc /proc
chroot $TARGET apt-get update
chroot $TARGET apt-get $apt_options install $install
chroot $TARGET apt-get clean
echo "Killing any processes running on the target fs:"
# kill any processes using the target fs
fuser -k -v -m $TARGET || true
chroot $TARGET umount /proc
undivert $TARGET/sbin/start-stop-daemon
fi
if [ "$netconfig" != "no" ]; then
. /tmp/rootstrap.netconf
cat <<EOF >> $TARGET/etc/network/interfaces
auto lo
iface lo inet loopback
auto $interface
EOF
if [ "$address" = "dhcp" ]; then
cat <<EOF >> $TARGET/etc/network/interfaces
iface $interface inet dhcp
EOF
else
cat <<EOF >> $TARGET/etc/network/interfaces
iface $interface inet static
address $address
netmask $netmask
up route add -net 0.0.0.0 dev $interface
EOF
fi
if [ -n "$gateway" ]; then
echo "up route add -net 0.0.0.0 gw $gateway" >> $TARGET/etc/network/interfaces
fi
if [ ! -e $TARGET/etc/resolv.conf ]; then
if [ -n "$domain" ]; then
cat <<EOF >> $TARGET/etc/resolv.conf
search $domain
EOF
fi
if [ -n "$nameserver" ]; then
cat <<EOF >> $TARGET/etc/resolv.conf
nameserver $nameserver
EOF
fi
fi
fi
|