Skip to content

Commit 865a39e

Browse files
committed
fix(macos): drive DMG layout via mount POSIX path instead of disk name
- Update make-dmg.sh to reference the DMG volume through its POSIX mount path rather than the ambiguous disk name, preventing collisions when a volume with the same name already exists - When a pre-existing volume uses the same HFS volname, macOS mounts the new volume at a suffixed path (e.g. "/Volumes/Stitch 1") while the disk name remains "Stitch"; targeting by mount basename or bare disk name could hit the wrong volume - Replace `tell disk "$DISK_NAME"` with a POSIX file alias in AppleScript to unambiguously target the correct mount - Add as_quote() helper to properly escape mount paths for AppleScript double-quoted strings - Update Finder layout script to operate on the mount alias directly instead of through the disk reference - Update detach_dmg() to close windows and eject using the mount alias, ensuring cleanup happens on the correct volume - Bump version to 0.1.136
1 parent 6646881 commit 865a39e

5 files changed

Lines changed: 38 additions & 32 deletions

File tree

.textile-monorepo-source

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
decdf61d60e98beebd2aa5844bae0b27e483936f
1+
f950320de4ed1797eaac61cbdd09f95cc573bbcf

.textile-stitch-release-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.135
1+
0.1.136

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.135"
3+
version = "0.1.136"
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: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ hdiutil create -srcfolder "$STAGE" -volname "$VOL" -fs HFS+ \
5050
-format UDRW -size "${SIZE_MB}m" -ov "$TMP_DMG" >/dev/null
5151

5252
# Capture device + mount point from this attach. If another volume already uses
53-
# the volname, macOS mounts us at "/Volumes/Stitch 1" (etc.); Finder "disk Stitch"
54-
# and a hardcoded /Volumes/$VOL path would then target the wrong volume.
53+
# the volname, macOS mounts us at "/Volumes/Stitch 1" (etc.) while the HFS
54+
# volume name — and Finder's `disk` name — stay "Stitch". Never key Finder off
55+
# basename(mount) ("Stitch 1") or bare `disk "Stitch"` (ambiguous); always use
56+
# the POSIX mount path from this attach.
5557
ATTACH_OUT="$(hdiutil attach -readwrite -noverify -noautoopen "$TMP_DMG")"
5658
DEV="$(printf '%s\n' "$ATTACH_OUT" | awk '/Apple_HFS/ {print $1; exit}')"
5759
# Mount path is everything from /Volumes/… (may contain spaces).
@@ -63,43 +65,46 @@ MNT="$(printf '%s\n' "$ATTACH_OUT" | awk '/Apple_HFS/ {
6365
printf '%s\n' "$ATTACH_OUT" >&2
6466
exit 1
6567
}
66-
# Finder disk name matches the mount folder (e.g. "Stitch" or "Stitch 1").
67-
DISK_NAME="$(basename "$MNT")"
68+
# Escape for AppleScript double-quoted strings.
69+
as_quote() {
70+
printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'
71+
}
72+
MNT_AS="$(as_quote "$MNT")"
6873
# Let the volume settle before scripting Finder.
6974
sleep 2
7075

7176
# Best-effort window layout: size, icon positions, and background. Finder
7277
# automation is available on the macOS CI runners; if it ever isn't, the image
7378
# still works — it just lacks the custom positions/arrow.
7479
osascript <<OSA || echo "warning: Finder layout failed; shipping a plain drag-to-Applications image" >&2
80+
set mntAlias to POSIX file "$MNT_AS" as alias
7581
tell application "Finder"
76-
tell disk "$DISK_NAME"
77-
open
78-
set current view of container window to icon view
79-
set toolbar visible of container window to false
80-
set statusbar visible of container window to false
81-
set the bounds of container window to {200, 120, 800, 520}
82-
set theViewOptions to the icon view options of container window
83-
set arrangement of theViewOptions to not arranged
84-
set icon size of theViewOptions to 120
85-
try
86-
set background picture of theViewOptions to file ".background:background.png"
87-
end try
88-
set position of item "Stitch.app" of container window to {150, 205}
89-
set position of item "Applications" of container window to {455, 205}
90-
update without registering applications
91-
delay 1
92-
close
93-
end tell
82+
open mntAlias
83+
set win to container window of mntAlias
84+
set current view of win to icon view
85+
set toolbar visible of win to false
86+
set statusbar visible of win to false
87+
set the bounds of win to {200, 120, 800, 520}
88+
set theViewOptions to the icon view options of win
89+
set arrangement of theViewOptions to not arranged
90+
set icon size of theViewOptions to 120
91+
try
92+
set background picture of theViewOptions to file ".background:background.png" of mntAlias
93+
end try
94+
set position of item "Stitch.app" of win to {150, 205}
95+
set position of item "Applications" of win to {455, 205}
96+
update without registering applications
97+
delay 1
98+
close win
9499
end tell
95100
OSA
96101

97102
sync
98103

99104
# Finder often keeps the volume busy for a few seconds after layout (Spotlight /
100105
# .DS_Store / the container window). A single detach or even -force can fail with
101-
# "Resource busy" (hdiutil exit 16) on CI runners. Close the window, ask Finder to
102-
# eject *this* mount, then retry detach with backoff before converting.
106+
# "Resource busy" (hdiutil exit 16) on CI runners. Close/eject *this* mount via
107+
# its POSIX path, then retry detach with backoff before converting.
103108
is_detached() {
104109
local target="$1"
105110
local mount="$2"
@@ -113,16 +118,17 @@ is_detached() {
113118
detach_dmg() {
114119
local target="$1"
115120
local mount="$2"
116-
local disk_name="$3"
121+
local mount_as="$3"
117122
local attempt
118123
# Best-effort: drop Finder's hold on this mount before hdiutil fights it.
119124
osascript <<OSA >/dev/null 2>&1 || true
125+
set mntAlias to POSIX file "$mount_as" as alias
120126
tell application "Finder"
121127
try
122-
close every window of disk "$disk_name"
128+
close (every window whose target is mntAlias)
123129
end try
124130
try
125-
eject disk "$disk_name"
131+
eject mntAlias
126132
end try
127133
end tell
128134
OSA
@@ -150,7 +156,7 @@ OSA
150156
return 1
151157
}
152158

153-
detach_dmg "$DEV" "$MNT" "$DISK_NAME"
159+
detach_dmg "$DEV" "$MNT" "$MNT_AS"
154160
hdiutil convert "$TMP_DMG" -format UDZO -imagekey zlib-level=9 -o "$DMG" >/dev/null
155161

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

0 commit comments

Comments
 (0)