+ eend 0
+}
+# }}}
+
+# execute all scripts in /etc/debootstrap/pre-scripts/ {{{
+execute_pre_scripts() {
+ # make sure we have $MNTPOINT available for our scripts
+ export MNTPOINT
+ if [ -d "$_opt_pre_scripts" ] || [ "$PRE_SCRIPTS" = 'yes' ] ; then
+ [ -d "$_opt_pre_scripts" ] && pre_scripts="$_opt_pre_scripts" || pre_scripts="$CONFFILES/pre-scripts/"
+ for script in ${pre_scripts}/* ; do
+ if [ -x "$script" ] ; then
+ einfo "Executing pre-script $script"
+ $script ; eend $?
+ fi
+ done
+ fi
+}
+# }}}
+
+# execute all scripts in /etc/debootstrap/scripts/ {{{
+execute_scripts() {
+ # make sure we have $MNTPOINT available for our scripts
+ export MNTPOINT
+ if [ -d "$_opt_scripts" ] || [ "$SCRIPTS" = 'yes' ] ; then
+ [ -d "$_opt_scripts" ] && scripts="$_opt_scripts" || scripts="$CONFFILES/scripts/"
+ for script in ${scripts}/* ; do
+ if [ -x "$script" ] ; then
+ einfo "Executing script $script"
+ $script ; eend $?
+ fi
+ done
+ fi
+}
+# }}}
+
+# execute chroot-script {{{
+chrootscript() {
+ if ! [ -r "$MNTPOINT/bin/chroot-script" ] ; then
+ mount_target
+ fi
+
+ if [ -x "$MNTPOINT/bin/chroot-script" ] ; then
+ einfo "Executing chroot-script now"
+ mount --bind /dev "$MNTPOINT"/dev
+ chroot "$MNTPOINT" /bin/chroot-script ; RC=$?
+ umount "$MNTPOINT"/dev
+ eend $RC
+ else
+ eerror "Fatal: $MNTPOINT/bin/chroot-script could not be found."
+ eend 1
+ fi
+}
+# }}}
+
+# install booloader grub {{{
+grub_install() {
+ if [ -z "$GRUB" ] ; then
+ echo "Notice: \$GRUB not defined, will not install grub therefore."
+ return 0
+ fi
+
+ if ! [ -x "$(which grub-install)" ] ; then
+ echo "Error: grub-install not available. (Error while installing grub package?)"
+ return 1
+ fi
+
+ if [ -n "$SELECTED_PARTITIONS" ] ; then # using sw-raid
+ for device in $SELECTED_PARTITIONS ; do
+ GRUB="${device%%[0-9]}"
+ einfo "Installing grub on ${GRUB}:"
+ grub-install --no-floppy --root-directory="$MNTPOINT" "$GRUB"
+ eend $?
+ done
+ else
+ einfo "Installing grub on ${GRUB}:"
+ grub-install --no-floppy --root-directory="$MNTPOINT" "$GRUB"
+ eend $?
+ fi
+}
+# }}}
+
+# unmount $MNTPOINT {{{
+umount_chroot() {
+
+ # display installation notes:
+ if [ -n "$INSTALL_NOTES" ] ; then
+ [ -r "${MNTPOINT}/${INSTALL_NOTES}" ] && cat "${MNTPOINT}/${INSTALL_NOTES}"
+ fi
+
+ 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 \
+ execute_pre_scripts chrootscript execute_scripts grub_install umount_chroot \
+ fscktool ; do
+ if stage "${i}" ; then
+ $i && ( stage "${i}" done && rm -f "${STAGES}/${i}" ) || bailout 2 "i"
+ fi
+done
+# }}}
+
+# finalize {{{
+einfo "Removing ${CHROOT_VARIABLES}" ; rm "$CHROOT_VARIABLES" ; eend $?
+einfo "Removing ${STAGES}" ; rmdir "$STAGES" ; eend $?
+
+# Remove temporary mountpoint again
+if echo "$MNTPOINT" | grep -q '/mnt/debootstrap\.' ; then
+ einfo "Removing directory ${MNTPOINT}" ; rmdir "$MNTPOINT" ; eend $?
+fi
+# }}}
+
+# end dialog of autoinstallation {{{
+if [ -n "$AUTOINSTALL" ] ; then
+ dialog --title "$PN" --msgbox \
+ "Finished execution of ${PN}. Enjoy your Debian system." 0 0
+else
+ einfo "Finished execution of ${PN}. Enjoy your Debian system." ; eend 0
+fi
+# }}}