]> piware.de Git - bin.git/blobdiff - makechroot
postinst-setup: bump postgresql version
[bin.git] / makechroot
index ea959c3fc25b6f661569c1ff7f5773b916e696ea..b255b7b525f093f3cd5d1ccc8cba80c98d7612c0 100755 (executable)
@@ -3,9 +3,48 @@ DIST="$1"
 DIR="$2"
 MIRROR="$3"
 
-debootstrap "$DIST" "$DIR" $MIRROR
+[ "$DIST" ] && [ "$DIR" ] && [ "$MIRROR" ] || {
+    echo "Usage: $0 <dist> <directory> <mirror>" >&2
+    exit 1
+}
+
+mkdir -p "$DIR"
+debootstrap "$DIST" "$DIR" "$MIRROR"
+chroot $DIR apt-get install locales
+
+# debian_chroot
+echo $DIST > $DIR/etc/debian_chroot
+
+# hosts
+echo "127.0.0.1 localhost.localdomain localhost" > $DIR/etc/hosts
+
+# users
+perl -naF: -e 'print if $F[2] >= 1000 and $F[2] < 2000' /etc/passwd >> $DIR/etc/passwd
+
+# locale
+chroot $DIR locale-gen $LANG
+
+# bind mounts
+if ! grep -q $DIR /etc/fstab; then
+    cat <<EOF >> /etc/fstab
+
+# $DIST chroot
+/home/martin    $DIR/home/martin none    bind   0 0
+/proc           $DIR/proc        none    bind   0 0
+/sys            $DIR/sys         none    bind   0 0
+/tmp            $DIR/tmp         none    bind   0 0
+EOF
+    mount $DIR/home
+    mount $DIR/proc
+    mount $DIR/sys
+    mount $DIR/tmp
+fi
 
 # apt sources
+if [ "$MIRROR" != "${MIRROR%file://}" ]; then
+    MIRROR=http://archive.ubuntu.com/ubuntu
+fi
+
 cat <<EOF > $DIR/etc/apt/sources.list
 deb     $MIRROR $DIST main restricted universe multiverse
 deb-src $MIRROR $DIST main restricted universe multiverse
@@ -20,13 +59,5 @@ EOF
 chroot $DIR apt-get update
 
 # common packages for development
-chroot $DIR apt-get install -y build-essential devscripts fakeroot
-
-# debian_chroot
-echo $DIST > $DIR/etc/debian_chroot
+chroot $DIR apt-get install -y build-essential fakeroot
 
-# users
-perl -naF: -e 'print if $F[2] >= 1000 and $F[2] < 2000' /etc/passwd >> $DIR/etc/passwd
-
-# locale
-chroot $DIR locale-gen $LANG