diff options
| author | Pev <pev@high-resolution.co.uk> | 2024-05-15 15:45:43 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-15 15:45:43 +0100 |
| commit | d790fed832188d41c1fb5d8506d833d053e4a81c (patch) | |
| tree | b62372069c8f97015af8431a1cd20cf0591e2701 /scripts/common | |
| parent | 9917c869a7fed6fb210cbd82bda5cb4a28d4119f (diff) | |
Compare mount output using base of dirname (#771)
* Compare mount output using base of dirname
If you're building from a bind-mounted directory, the build will
fail as it will find two entries to unmount, but a single unmount
will remove them both causing an error. Adding a space means that
the mountpoint will only match with a single mount entry ; the
expected path, rather than the pre bind-mount.
* Switch to awk instead of mount, grep, cut pipes
Retry unmount 5 times and give up, letting the user know that they need to resolve the issue manually
---------
Co-authored-by: David Peverley <pev@analogue-micro.com>
Co-authored-by: Serge Schneider <serge@raspberrypi.com>
Diffstat (limited to 'scripts/common')
| -rw-r--r-- | scripts/common | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/scripts/common b/scripts/common index 6150f2b..c305ee2 100644 --- a/scripts/common +++ b/scripts/common @@ -44,12 +44,15 @@ unmount(){ DIR=$1 fi - while mount | grep -q "$DIR"; do - local LOCS - LOCS=$(mount | grep "$DIR" | cut -f 3 -d ' ' | sort -r) - for loc in $LOCS; do - umount "$loc" - done + for i in {1..6}; do + if awk "\$2 ~ /^${DIR//\//\\/}/ {print \$2}" /etc/mtab | sort -r | xargs -r umount; then + break + elif [ "$i" -eq 6 ]; then + log "Failed to unmount ${DIR}. Do not try to delete this directory while it contains mountpoints!" + return 1 + fi + log "Retrying ($i/5)..." + sleep 1 done } export -f unmount |
