+# install booloader grub {{{
+grub_install() {
+ if [ -z "$GRUB" -o -z "$GROOT" ] ; then
+ echo "Notice: \$GRUB or \$GROOT not defined, will not install grub therefor."
+ else
+ einfo "Installing grub on ${GRUB}:"
+ [ -x /usr/sbin/grub-install ] && GRUBINSTALL=/usr/sbin/grub-install || GRUBINSTALL=/sbin/grub-install
+ $GRUBINSTALL --root-directory="$MNTPOINT" "(${GRUB})"
+ eend $?
+ fi
+}
+# }}}
+
+# unmount $MNTPOINRT {{{
+umount_chroot() {
+ 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
+}
+# }}}
+
+# execute filesystem check {{{
+fscktool() {
+ if [ "$FSCK" = 'yes' ] ; then
+ [ -n "$FSCKTOOL" ] || FSCKTOOL="fsck.${MKFS#mkfs.}"
+ einfo "Checking filesystem on $TARGET using $FSCKTOOL"
+ $FSCKTOOL $TARGET
+ eend $?
+ fi
+}
+# }}}
+
+# now execute all the functions {{{
+for i in mkfs tunefs mount_target debootstrap_system preparechroot \
+ chrootscript grub_install umount_chroot fscktool ; do
+ if stage $i ; then
+ $i && stage $i done || bailout 2 "i"
+ fi
+done
+# }}}
+
+# stages {{{
+ echo done > $STAGES/grml-debootstrap
+# }}}
+
+if [ -n "$AUTOINSTALL" ] ; then
+ dialog --title "$0" --msgbox \
+ "Finished execution of ${0}.
+Enjoy your Debian system." 6 60
+else
+ einfo "Finished execution of $0 - enjoy your Debian system." ; eend 0