Skip to content

Commit a6f958c

Browse files
committed
fix(build): retry DMG detach when volume is busy
- Add robust detach logic to handle Finder keeping volumes busy after layout operations - Close Finder windows and request eject before attempting hdiutil detach - Retry detach with exponential backoff (sleep 1–8s) across up to 8 attempts, trying both device node and mount point paths - Treat already-unmounted volumes as success and proceed with conversion - Log hdiutil info on final failure for CI debugging - Bump version to 0.1.131
1 parent 572a4ac commit a6f958c

5 files changed

Lines changed: 57 additions & 5 deletions

File tree

.textile-monorepo-source

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
925818ee85697c7d0f3bcf7dd124b00664c3cf07
1+
1d899f81dd075c776cc1e1b09ef22c1fa21860be

.textile-stitch-release-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.130
1+
0.1.131

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stitch-bot"
3-
version = "0.1.130"
3+
version = "0.1.131"
44
edition = "2021"
55
description = "Stitch — Textile filler-network operator bot; market-makes the filler order book with signed UniswapX limit orders."
66
license = "AGPL-3.0-or-later"

packaging/macos/make-dmg.sh

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,59 @@ end tell
8181
OSA
8282

8383
sync
84-
hdiutil detach "$DEV" >/dev/null 2>&1 || hdiutil detach "$DEV" -force >/dev/null
84+
85+
# Finder often keeps the volume busy for a few seconds after layout (Spotlight /
86+
# .DS_Store / the container window). A single detach or even -force can fail with
87+
# "Resource busy" (hdiutil exit 16) on CI runners. Close the window, ask Finder to
88+
# eject, then retry detach with backoff before converting.
89+
is_detached() {
90+
local target="$1"
91+
# Mount point gone and device no longer listed → already ejected (e.g. via Finder).
92+
if [ ! -d "/Volumes/$VOL" ] && ! hdiutil info 2>/dev/null | grep -q "$target"; then
93+
return 0
94+
fi
95+
return 1
96+
}
97+
98+
detach_dmg() {
99+
local target="$1"
100+
local attempt
101+
# Best-effort: drop Finder's hold before hdiutil fights it.
102+
osascript <<OSA >/dev/null 2>&1 || true
103+
tell application "Finder"
104+
try
105+
close every window of disk "$VOL"
106+
end try
107+
try
108+
eject disk "$VOL"
109+
end try
110+
end tell
111+
OSA
112+
if is_detached "$target"; then
113+
return 0
114+
fi
115+
for attempt in 1 2 3 4 5 6 7 8; do
116+
if hdiutil detach "$target" >/dev/null 2>&1; then
117+
return 0
118+
fi
119+
if hdiutil detach "$target" -force >/dev/null 2>&1; then
120+
return 0
121+
fi
122+
# Also try the mount point — device node vs path can disagree after eject.
123+
if [ -d "/Volumes/$VOL" ] && hdiutil detach "/Volumes/$VOL" -force >/dev/null 2>&1; then
124+
return 0
125+
fi
126+
if is_detached "$target"; then
127+
return 0
128+
fi
129+
sleep "$attempt"
130+
done
131+
echo "error: could not detach $target (/Volumes/$VOL) after retries" >&2
132+
hdiutil info >&2 || true
133+
return 1
134+
}
135+
136+
detach_dmg "$DEV"
85137
hdiutil convert "$TMP_DMG" -format UDZO -imagekey zlib-level=9 -o "$DMG" >/dev/null
86138

87139
# Ad-hoc ("-") DMGs aren't worth signing (nothing verifies them); sign only with

0 commit comments

Comments
 (0)