Merge "Retry losetup -d for up to 10 seconds."
This commit is contained in:
commit
2536d3f28d
@ -112,7 +112,7 @@ mv $TMP_BUILD_DIR/mnt $TMP_BUILD_DIR/built
|
||||
_NEEDED_SIZE=$(sudo du --block-size=800 -x -s ${TMP_BUILD_DIR}/built | awk ' { print $1 } ')
|
||||
truncate -s${_NEEDED_SIZE}K $TMP_IMAGE_PATH
|
||||
LOOPDEV=$(sudo losetup --show -f $TMP_IMAGE_PATH)
|
||||
export EXTRA_UNMOUNT="sudo losetup -d $LOOPDEV"
|
||||
export EXTRA_UNMOUNT="detach_loopback $LOOPDEV"
|
||||
export IMAGE_BLOCK_DEVICE=$LOOPDEV
|
||||
eval_run_d block-device "IMAGE_BLOCK_DEVICE="
|
||||
OPTS=""
|
||||
|
@ -1,3 +1,4 @@
|
||||
# vim: syntax=sh ts=4 sts=4 sw=2:et
|
||||
# Copyright 2012 Hewlett-Packard Development Company, L.P.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
@ -159,3 +160,16 @@ function run_d() {
|
||||
check_break after-$1 bash
|
||||
}
|
||||
|
||||
function detach_loopback() {
|
||||
local loopdev=$1
|
||||
# loopback dev may be tied up a bit by udev events triggered by partition events
|
||||
for try in $(seq 10 -1 1) ; do
|
||||
if sudo losetup -d $loopdev ; then
|
||||
return 0
|
||||
fi
|
||||
echo $loopdev may be busy, sleeping up to $try more seconds...
|
||||
sleep 1
|
||||
done
|
||||
echo Gave up trying to detach $loopdev
|
||||
return 1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user