]> piware.de Git - bin.git/blob - makechroot
makechroot: move apt stuff to the bottom, in case network fails
[bin.git] / makechroot
1 #!/bin/sh -e
2 DIST="$1"
3 DIR="$2"
4 MIRROR="$3"
5
6 debootstrap "$DIST" "$DIR" $MIRROR
7
8 # debian_chroot
9 echo $DIST > $DIR/etc/debian_chroot
10
11 # users
12 perl -naF: -e 'print if $F[2] >= 1000 and $F[2] < 2000' /etc/passwd >> $DIR/etc/passwd
13
14 # locale
15 chroot $DIR locale-gen $LANG
16
17 # bind mounts
18 if ! grep -q $DIR /etc/fstab; then
19     cat <<EOF >> /etc/fstab
20
21 # $DIST chroot
22 /home           $DIR/home none    bind    0 0
23 /proc           $DIR/proc none    bind    0 0
24 /sys            $DIR/sys  none    bind    0 0
25 /tmp            $DIR/tmp  none    bind    0 0
26 EOF
27     mount $DIR/home
28     mount $DIR/proc
29     mount $DIR/sys
30     mount $DIR/tmp
31 fi
32
33 # apt sources
34 cat <<EOF > $DIR/etc/apt/sources.list
35 deb     $MIRROR $DIST main restricted universe multiverse
36 deb-src $MIRROR $DIST main restricted universe multiverse
37 deb     $MIRROR $DIST-updates main restricted universe multiverse
38 deb-src $MIRROR $DIST-updates main restricted universe multiverse
39 deb     $MIRROR $DIST-proposed main restricted universe multiverse
40 deb-src $MIRROR $DIST-proposed main restricted universe multiverse
41 deb     $MIRROR $DIST-security main restricted universe multiverse
42 deb-src $MIRROR $DIST-security main restricted universe multiverse
43 EOF
44
45 chroot $DIR apt-get update
46
47 # common packages for development
48 chroot $DIR apt-get install -y build-essential devscripts fakeroot
49