projects
/
grml-debootstrap.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
0c7dbbc
)
Slightly improve bailout and cleanup functions to better catch errors
author
Michael Prokop
<mika@grml.org>
Mon, 30 Jan 2012 10:28:21 +0000
(11:28 +0100)
committer
Michael Prokop
<mika@grml.org>
Mon, 30 Jan 2012 10:28:21 +0000
(11:28 +0100)
grml-debootstrap
patch
|
blob
|
history
diff --git
a/grml-debootstrap
b/grml-debootstrap
index
ec63a82
..
1ab3dd7
100755
(executable)
--- a/
grml-debootstrap
+++ b/
grml-debootstrap
@@
-177,15
+177,17
@@
check4progs(){
# helper functions {{{
cleanup() {
# helper functions {{{
cleanup() {
- set -x
- einfo "Removing ${CHROOT_VARIABLES}" ; rm "$CHROOT_VARIABLES" ; eend $?
- einfo "Removing ${STAGES}" ; rmdir "$STAGES" ; eend $?
+ if [ -n "$CHROOT_VARIABLES" ] ; then
+ einfo "Removing ${CHROOT_VARIABLES}" ; rm "$CHROOT_VARIABLES" ; eend $?
+ fi
+
+ if [ -n "$STAGES" ] ; then
+ einfo "Removing ${STAGES}" ; rmdir "$STAGES" ; eend $?
+ fi
# Remove temporary mountpoint again
if echo "$MNTPOINT" | grep -q '/mnt/debootstrap\.' ; then
# Remove temporary mountpoint again
if echo "$MNTPOINT" | grep -q '/mnt/debootstrap\.' ; then
- einfo "Removing directory ${MNTPOINT}"
- rmdir "$MNTPOINT"
- eend $?
+ rmdir "$MNTPOINT" 2>/dev/null
fi
# make sure $TARGET is not mounted when exiting grml-debootstrap
fi
# make sure $TARGET is not mounted when exiting grml-debootstrap
@@
-204,7
+206,9
@@
cleanup() {
done
umount "$MNTPOINT"/dev >/dev/null 2>&1
done
umount "$MNTPOINT"/dev >/dev/null 2>&1
- [ -d "$MNTPOINT/$ISODIR" ] && umount "$MNTPOINT/$ISODIR" >/dev/null 2>&1
+ if [ -n "$ISODIR" ] ; then
+ [ -d "$MNTPOINT/$ISODIR" ] && umount "$MNTPOINT/$ISODIR" >/dev/null 2>&1
+ fi
if [ -n "$DIRECTORY" ] ; then
einfo "Not unmounting $MNTPOINT as you requested me to install into a directory of your own choice." ; eend 0
if [ -n "$DIRECTORY" ] ; then
einfo "Not unmounting $MNTPOINT as you requested me to install into a directory of your own choice." ; eend 0
@@
-240,7
+244,7
@@
bailout(){
cleanup
[ -n "$1" ] && EXIT="$1" || EXIT="1"
cleanup
[ -n "$1" ] && EXIT="$1" || EXIT="1"
- [ -n "$
3" ] && einfo "Notice: just remove $STAGES/$3
to reexecute the stage"
+ [ -n "$
2" ] && einfo "Notice: remove $STAGES/$2
to reexecute the stage"
exit "$EXIT"
}
exit "$EXIT"
}
@@
-1255,7
+1259,7
@@
for i in prepare_vm mkfs tunefs mount_target debootstrap_system \
preparechroot execute_pre_scripts chrootscript execute_scripts \
umount_chroot finalize_vm fscktool ; do
if stage "${i}" ; then
preparechroot execute_pre_scripts chrootscript execute_scripts \
umount_chroot finalize_vm fscktool ; do
if stage "${i}" ; then
- $i && ( stage "${i}" done && rm -f "${STAGES}/${i}" ) || bailout 2 "i"
+ $i && ( stage "${i}" done && rm -f "${STAGES}/${i}" ) || bailout 2 "
$
i"
fi
done
fi
done