From: Stefan Reinauer Date: Sun, 21 Jun 2026 18:35:56 +0000 (-0700) Subject: package: detach stale WinUAE DMG mounts X-Git-Url: https://gitweb.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=49889a1ed6abed6c8f2097e45e554f66efc57896;p=francis%2Fwinuae.git package: detach stale WinUAE DMG mounts A previous failed or interrupted packaging run can leave /Volumes/WinUAE mounted and make the next hdiutil attach pick a different mount point. Detect that case, detach the old image mount, and fail if the path belongs to something other than a disk image. --- diff --git a/tools/macos-dmg.sh b/tools/macos-dmg.sh index d22c41ed..ab0f4e74 100755 --- a/tools/macos-dmg.sh +++ b/tools/macos-dmg.sh @@ -90,6 +90,32 @@ apply_volume_icon() { apply_volume_icon "${staging_dir}" +detach_existing_volume_mount() { + local target_mount="/Volumes/${volume_name}" + + if [[ ! -e "${target_mount}" ]]; then + return + fi + + if ! hdiutil info | awk -F '\t' -v target="${target_mount}" '$NF == target { found = 1 } END { exit found ? 0 : 1 }'; then + echo "error: ${target_mount} already exists and is not a mounted disk image" >&2 + echo "error: detach or rename it before creating the WinUAE DMG" >&2 + exit 1 + fi + + echo "detaching existing ${target_mount} before creating the WinUAE DMG" + hdiutil detach "${target_mount}" -quiet + for _ in {1..20}; do + if [[ ! -e "${target_mount}" ]]; then + return + fi + sleep 0.5 + done + + echo "error: ${target_mount} is still present after detach" >&2 + exit 1 +} + background_tiff="${staging_dir}/.background/background.tiff" background_source="${source_dir}/od-unix/graphics/dmg_background.tiff" if [[ ! -f "${background_source}" ]]; then @@ -98,6 +124,7 @@ if [[ ! -f "${background_source}" ]]; then fi cp "${background_source}" "${background_tiff}" +detach_existing_volume_mount hdiutil create -volname "${volume_name}" -srcfolder "${staging_dir}" -fs HFS+ -format UDRW -ov "${rw_dmg}" >/dev/null mount_dir="$(hdiutil attach "${rw_dmg}" -readwrite -noverify -noautoopen | awk -F '\t' '/\/Volumes\// { print $NF; exit }')" if [[ -z "${mount_dir}" || ! -d "${mount_dir}" ]]; then