-eend 0
-
-einfo "Executing chroot-script now"
-chroot $MNTPOINT /bin/chroot-script
-eend $?
-
-# einfo "Removing chroot-script"
-# rm -f $MNTPOINT/bin/chroot-script
-# rm -rf $MNTPOINT/etc/debootstrap/
-# eend $?
-
-einfo "Unmount $MNTPOINT"
-umount $MNTPOINT
-eend $?
-
-if [ "$FSCK" = 'yes' ] ; then
- [ -n "$FSCKTOOL" ] || FSCKTOOL="fsck.${MKFS#mkfs.}"
- einfo "Checking filesystem on $TARGET using $FSCKTOOL"
- $FSCKTOOL $TARGET
- eend $?
-fi
+ eend 0
+}
+# }}}
+
+# execute chroot-script {{{
+chrootscript() {
+ einfo "Executing chroot-script now"
+ chroot "$MNTPOINT" /bin/chroot-script
+ eend $?
+}
+# }}}
+
+# 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}:"
+ grub-install --root-directory="$MNTPOINT" "(${GRUB})"
+ eend $?
+ fi
+}
+# }}}
+
+# unmount $MNTPOINRT {{{
+umount_chroot() {
+ if [ -n "$PARTITION" ] ; then
+ einfo "Unmount $MNTPOINT"
+ umount $MNTPOINT
+ eend $?
+ 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
+ fi
+done
+# }}}
+
+# stages {{{
+ echo done > $STAGES/grml-debootstrap
+# }}}