summaryrefslogtreecommitdiff
path: root/scripts/common
diff options
context:
space:
mode:
authorTom Dewey <146750643+tdewey-rpi@users.noreply.github.com>2024-05-15 15:50:40 +0100
committerGitHub <noreply@github.com>2024-05-15 15:50:40 +0100
commitfb48183f0d49df3d069f0086263d829efa899c70 (patch)
treef590a578a04985b4035bf7dc02a1f63519fc8b84 /scripts/common
parentd790fed832188d41c1fb5d8506d833d053e4a81c (diff)
Expand trap cleanup function (#773)
* build.sh: Unmount intermediates on trap Iterate through image files which might be in use and detach them Avoid silent failures - let the user know whether the build failed * common: update unmount_image Use udevadm settle instead of sleep if possible Use losetup's -j option to find the loop device associated with a give image file * build.sh: update clean-up trap term --------- Co-authored-by: Serge Schneider <serge@raspberrypi.com>
Diffstat (limited to 'scripts/common')
-rw-r--r--scripts/common9
1 files changed, 6 insertions, 3 deletions
diff --git a/scripts/common b/scripts/common
index c305ee2..702576f 100644
--- a/scripts/common
+++ b/scripts/common
@@ -58,9 +58,12 @@ unmount(){
export -f unmount
unmount_image(){
- sync
- sleep 1
- LOOP_DEVICE=$(losetup --list | grep "$1" | cut -f1 -d' ')
+ if command -v udevadm >/dev/null 2>&1; then
+ udevadm settle 10
+ else
+ sleep 1
+ fi
+ LOOP_DEVICE=$(losetup -n -O NAME -j "$1")
if [ -n "$LOOP_DEVICE" ]; then
for part in "$LOOP_DEVICE"p*; do
if DIR=$(findmnt -n -o target -S "$part"); then