common: make safe_umount retry a few times

on Fedora 18 on Gnome 3.0 something is making the first attempt at
unmounting return busy. Unfortunatly, the return code is 32 everytime
so we have to parse the output of umount :( :( :(

Change-Id: I7f94bf6c2059c7e7cb4fb173d9ffbabd59f2b24f
This commit is contained in:
Brandon Philips 2013-02-01 15:11:13 -08:00
parent c1fd42203b
commit 11472e5166
3 changed files with 32 additions and 6 deletions

View File

@ -66,10 +66,10 @@ if [[ ${PKGS/kernel/} != ${PKGS} ]]; then
sudo dd if="./rootfs/boot/vmlinuz" of=part_2 bs=512 count=8192 conv=notrunc
fi
sudo umount rootfs/usr/local
sudo umount rootfs/var
sudo umount rootfs
sudo umount stateful_part
safe_umount rootfs/usr/local
safe_umount rootfs/var
safe_umount rootfs
safe_umount stateful_part
./pack_partitions.sh ${IMAGE}
cd -

View File

@ -64,7 +64,7 @@ run_partition_script() {
sudo mount -o loop "${root_fs_img}" "${root_fs_dir}"
. "${root_fs_dir}/${PARTITION_SCRIPT_PATH}"
write_partition_table "${outdev}" "${pmbr_img}"
sudo umount "${root_fs_dir}"
safe_umount "${root_fs_dir}"
}
get_fs_block_size() {

View File

@ -705,7 +705,33 @@ safe_umount_tree() {
# Run umount as root.
safe_umount() {
$([[ ${UID:-$(id -u)} != 0 ]] && echo sudo) umount "$@"
local ret=0
local out=""
set +e
for i in $(seq 1 4); do
out=`$([[ ${UID:-$(id -u)} != 0 ]] && echo sudo) umount "$@" 2>&1`
ret=$?
if [[ $ret -eq 0 ]]; then
set -e
return 0
fi
# Mount is not found
if [[ `expr index "${out}" "not found"` -ne "0" ]]; then
set -e
return 0
fi
# Mount is not mounted.
if [[ `expr index "${out}" "not mounted"` -ne "0" ]]; then
set -e
return 0
fi
sleep 1
# Mount is actually busy.
if [[ `expr index "${out}" "busy"` -ne "0" ]]; then
continue
fi
done
return $ret
}
get_git_id() {