From ccba9a85a1ad2e6aa405987195c1230e8a28c783 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Tue, 2 Dec 2014 16:02:48 +0100 Subject: [PATCH] Try unmounting [..]/dev harder Fixes #41 (GH-41, PR 50) --- grml-debootstrap | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/grml-debootstrap b/grml-debootstrap index ffcb6aa..7a71239 100755 --- a/grml-debootstrap +++ b/grml-debootstrap @@ -1338,6 +1338,26 @@ execute_scripts() { } # }}} +try_umount() { + local tries=$1 + local mountpoint="$2" + + for (( try=1; try<=tries; try++ )); do + if [[ ${try} -eq ${tries} ]]; then + # Last time, show errors this time + umount "${mountpoint}" && return 0 + else + # Not last time, hide errors until fatal + if umount "${mountpoint}" 2>/dev/null ; then + return 0 + else + sleep 1 + fi + fi + done + return 1 # Tried enough +} + # execute chroot-script {{{ chrootscript() { if ! [ -r "$MNTPOINT/bin/chroot-script" ] ; then @@ -1355,7 +1375,7 @@ chrootscript() { else chroot "$MNTPOINT" /bin/chroot-script ; RC=$? fi - umount "$MNTPOINT"/dev + try_umount 3 "$MNTPOINT"/dev eend $RC fi -- 2.1.4