From: Sebastian Pipping Date: Tue, 2 Dec 2014 15:02:48 +0000 (+0100) Subject: Try unmounting [..]/dev harder X-Git-Tag: v0.69~12 X-Git-Url: https://git.grml.org/?p=grml-debootstrap.git;a=commitdiff_plain;h=ccba9a85a1ad2e6aa405987195c1230e8a28c783;ds=sidebyside Try unmounting [..]/dev harder Fixes #41 (GH-41, PR 50) --- 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