support adding own sources.list entries
[grml-debootstrap.git] / grml-debootstrap
index 2a36d4e..d9d3202 100755 (executable)
@@ -4,7 +4,7 @@
 # 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: Die Jun 05 13:51:21 CEST 2007 [mika]
+# Latest change: Die Jun 05 14:23:38 CEST 2007 [mika]
 ################################################################################
 # http://www.debian.org/releases/stable/i386/index.html.en
 
@@ -96,7 +96,7 @@ while [ "$#" -gt "0" ] ; do
             ;;
         -i|--iso)
             shift
-           [ -n "$MIRROR" ] && unset MIRROR
+            [ -n "$MIRROR" ] && unset MIRROR
             ISO=$1
             ;;
         -h|--help)
@@ -169,6 +169,7 @@ case $ISO in
     ;;
 esac
 ISODIR=${ISO##file:}
+ISODIR=${ISODIR%%/}
 
 # provide variables to chroot system
 touch /etc/debootstrap/variables
@@ -385,10 +386,19 @@ grub_install() {
 
 # unmount $MNTPOINRT {{{
 umount_chroot() {
-  if [ -n "$PARTITION" ] ; then
-     einfo "Unmount $MNTPOINT"
-     umount $MNTPOINT
-     eend $?
+  if [ -n "$ISODIR" ] ; then
+     if grep -q "$ISODIR" /proc/mounts ; then
+        einfo "Unmount $MNTPOINT/$ISODIR"
+        umount "$MNTPOINT/$ISODIR"
+        eend $?
+     fi
+  fi
+  if grep -q "$MNTPOINT" /proc/mounts ; then
+     if [ -n "$PARTITION" ] ; then
+        einfo "Unmount $MNTPOINT"
+        umount $MNTPOINT
+        eend $?
+     fi
   fi
 }
 # }}}