ommit -i option of cp, send output of umount to /dev/null
[grml-debootstrap.git] / grml-debootstrap
index a22a021..f680fd1 100644 (file)
@@ -4,17 +4,19 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Fre Nov 03 00:54:39 CET 2006 [mika]
+# Latest change: Fre Nov 03 13:50:30 CET 2006 [mika]
 ################################################################################
 # http://www.debian.org/releases/stable/i386/apcs04.html.en
 
-set -eu # exit on any error
+set -e # exit on any error
 
 . /etc/grml/lsb-functions
 . /etc/grml/script-functions
 
 check4progs debootstrap || exit 1
 
+set -u # make sure we don't have empty variables
+
 if [ -r /etc/debootstrap/config ] ; then
    . /etc/debootstrap/config
 else
@@ -33,9 +35,13 @@ $MKFS $TARGET
 eend $?
 
 # now mount the new partition
-einfo "Mounting $TARGET to $MNTPOINT"
-mount -o rw,suid,dev $TARGET $MNTPOINT
-eend $?
+if grep -q $TARGET /proc/mounts ; then
+   eerror "$TARGEt already mounted, exiting."
+else
+  einfo "Mounting $TARGET to $MNTPOINT"
+  mount -o rw,suid,dev $TARGET $MNTPOINT
+  eend $?
+fi
 
 # get main packages from a debian-mirror
 einfo "Running $DEBOOTSTRAP for release $RELEASE using mirror $MIRROR"
@@ -45,10 +51,11 @@ eend $?
 einfo "Preparing chroot system"
   cp $CONFFILES/chroot-script $MNTPOINT/bin/chroot-script
   chmod 755 $MNTPOINT/bin/chroot-script
-  mkdir $MNTPOINT/etc/deboostrap/
+  mkdir $MNTPOINT/etc/debootstrap/
 
-  # make sure we have our config file for later use via chroot-script
+  # make sure we have our files for later use via chroot-script
   cp /etc/debootstrap/config $MNTPOINT/etc/debootstrap/
+  cp /etc/debootstrap/packages $MNTPOINT/etc/debootstrap/packages
 
   # copy any existing existing files to chroot
   [ -d /etc/debootstrap/boot  ] && cp -a /etc/debootstrap/boot/*  $MNTPOINT/boot/
@@ -56,7 +63,7 @@ einfo "Preparing chroot system"
   [ -d /etc/debootstrap/share ] && cp -a /etc/debootstrap/share/* $MNTPOINT/share/
   [ -d /etc/debootstrap/usr   ] && cp -a /etc/debootstrap/usr/*   $MNTPOINT/usr/
   [ -d /etc/debootstrap/var   ] && cp -a /etc/debootstrap/var/*   $MNTPOINT/var/
-eend $?
+eend 0
 
 einfo "Executing chroot-script now"
 chroot $MNTPOINT /bin/chroot-script