forked from 1b-agent/opencadstudio-upstream
Simplify macOS DMG staging
This commit is contained in:
1 parent
b6ad2eba26
commit
31e769a948
1 file changed
+4
-54
@@ -113,71 +113,21 @@ echo "==> dmg"
|
|||||||
DMG="$DIST/OpenCADStudio-v$VERSION-macos-arm64.dmg"
|
DMG="$DIST/OpenCADStudio-v$VERSION-macos-arm64.dmg"
|
||||||
rm -f "$DMG"
|
rm -f "$DMG"
|
||||||
|
|
||||||
# Stage the .app next to a symlink to /Applications so the DMG opens onto
|
# Stage the app next to the install-location shortcut (#769).
|
||||||
# the familiar "drag the icon onto Applications" installer layout, rather
|
|
||||||
# than dropping just the bare .app into the user's Downloads-mounted volume
|
|
||||||
# with no indication of where it's supposed to go (#769).
|
|
||||||
STAGING="$DIST/dmg-staging"
|
STAGING="$DIST/dmg-staging"
|
||||||
rm -rf "$STAGING"
|
rm -rf "$STAGING"
|
||||||
mkdir -p "$STAGING"
|
mkdir -p "$STAGING"
|
||||||
cp -R "$APP" "$STAGING/"
|
cp -R "$APP" "$STAGING/"
|
||||||
ln -s /Applications "$STAGING/Applications"
|
ln -s /Applications "$STAGING/Applications"
|
||||||
|
|
||||||
# Build read-write first so Finder can save the window's icon layout, then
|
|
||||||
# convert to the compressed read-only image the CI job's own DMG step
|
|
||||||
# already produces — same two-stage approach that layout customization
|
|
||||||
# always needs, since a UDZO image can't be mounted for editing afterward.
|
|
||||||
RW_DMG="$DIST/OpenCADStudio-rw.dmg"
|
|
||||||
rm -f "$RW_DMG"
|
|
||||||
for i in 1 2 3 4 5; do
|
for i in 1 2 3 4 5; do
|
||||||
if hdiutil create -volname "Open CAD Studio" -srcfolder "$STAGING" -ov -format UDRW -fs HFS+ "$RW_DMG"; then
|
if hdiutil create -volname "Open CAD Studio" -srcfolder "$STAGING" -ov -format UDZO "$DMG"; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
echo "hdiutil create (rw) failed (attempt $i), retrying..." >&2
|
rm -f "$DMG"
|
||||||
|
echo "hdiutil failed (attempt $i), retrying..." >&2
|
||||||
sleep 3
|
sleep 3
|
||||||
done
|
done
|
||||||
[ -f "$RW_DMG" ] || { echo "hdiutil create (rw) failed permanently" >&2; exit 1; }
|
|
||||||
|
|
||||||
MOUNT_DIR="$(mktemp -d /tmp/ocs-dmg-mount.XXXXXX)"
|
|
||||||
hdiutil attach "$RW_DMG" -mountpoint "$MOUNT_DIR" -quiet
|
|
||||||
# Finder's own volume list can lag a moment behind `hdiutil attach`
|
|
||||||
# returning, and "container window of <alias>" isn't a valid reference the
|
|
||||||
# way "container window of disk <name>" is — so poll by name (up to 15s)
|
|
||||||
# before touching it, rather than a fixed sleep or a path-based reference.
|
|
||||||
osascript <<APPLESCRIPT || echo "DMG layout script failed (non-fatal, keeping default Finder view)" >&2
|
|
||||||
tell application "Finder"
|
|
||||||
repeat 30 times
|
|
||||||
if (exists disk "Open CAD Studio") then exit repeat
|
|
||||||
delay 0.5
|
|
||||||
end repeat
|
|
||||||
tell disk "Open CAD Studio"
|
|
||||||
open
|
|
||||||
set current view of container window to icon view
|
|
||||||
set toolbar visible of container window to false
|
|
||||||
set statusbar visible of container window to false
|
|
||||||
set the bounds of container window to {200, 120, 760, 480}
|
|
||||||
set viewOptions to the icon view options of container window
|
|
||||||
set arrangement of viewOptions to not arranged
|
|
||||||
set icon size of viewOptions to 96
|
|
||||||
set position of item "OpenCADStudio.app" of container window to {140, 180}
|
|
||||||
set position of item "Applications" of container window to {420, 180}
|
|
||||||
close
|
|
||||||
open
|
|
||||||
update without registering applications
|
|
||||||
delay 1
|
|
||||||
end tell
|
|
||||||
end tell
|
|
||||||
APPLESCRIPT
|
|
||||||
hdiutil detach "$MOUNT_DIR" -quiet
|
|
||||||
|
|
||||||
for i in 1 2 3 4 5; do
|
|
||||||
if hdiutil convert "$RW_DMG" -format UDZO -ov -o "$DMG"; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
echo "hdiutil convert failed (attempt $i), retrying..." >&2
|
|
||||||
sleep 3
|
|
||||||
done
|
|
||||||
rm -f "$RW_DMG"
|
|
||||||
rm -rf "$STAGING"
|
rm -rf "$STAGING"
|
||||||
[ -f "$DMG" ] || { echo "hdiutil failed permanently" >&2; exit 1; }
|
[ -f "$DMG" ] || { echo "hdiutil failed permanently" >&2; exit 1; }
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user