知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.
Swift androidlinuxlive-captionsmacosmeeting-notesmenubar-appsimultaneous-interpretationspeech-recognitionsubtitlesswiftswiftuitranslationwindows
build: package a DMG installer with a drawn background and Finder layout
wquguru132056e19289
diff --git a/Resources/dmg/DS_Store b/Resources/dmg/DS_Storenew file mode 100644index 0000000..1b50c2eBinary files /dev/null and b/Resources/dmg/DS_Store differdiff --git a/scripts/dmg-template.sh b/scripts/dmg-template.shnew file mode 100755index 0000000..06e1643--- /dev/null+++ b/scripts/dmg-template.sh@@ -0,0 +1,48 @@+#!/usr/bin/env bash+# Regenerates Resources/dmg/DS_Store, the installer window layout, by letting Finder lay out a+# scratch volume. Run it on a Mac after changing the window size, icon positions or background;+# keep them in step with Sources/LiveSubs/DMGBackground.swift. The first run asks to let the+# terminal control Finder (System Settings › Privacy & Security › Automation).+set -euo pipefail+cd "$(dirname "$0")/.."++[[ -d build/LiveSubs.app && -f build/dmg/background.tiff ]] || { echo "run scripts/package.sh first" >&2; exit 1; }+# A neutral scratch path: Finder records the disk image path in the layout.+WORK=/tmp/livesubs-dmg-template+[[ ! -e "/Volumes/Live Subs" ]] || { echo "eject the volume named Live Subs first" >&2; exit 1; }+rm -rf "$WORK" && mkdir -p "$WORK/stage/.background"+cp -R build/LiveSubs.app "$WORK/stage/"+ln -s /Applications "$WORK/stage/Applications"+cp build/dmg/background.tiff "$WORK/stage/.background/background.tiff"+hdiutil create -quiet -srcfolder "$WORK/stage" -volname "Live Subs" -fs HFS+ -format UDRW -size 60m "$WORK/rw.dmg"+hdiutil attach -quiet -readwrite -noverify -noautoopen "$WORK/rw.dmg"++# Window 640 × 400 of content (428 with the title bar); icons at the background's marks.+osascript <<'APPLESCRIPT'+tell application "Finder"+ tell disk "Live Subs"+ 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, 840, 548}+ set opts to the icon view options of container window+ set arrangement of opts to not arranged+ set icon size of opts to 112+ set text size of opts to 13+ set background picture of opts to file ".background:background.tiff"+ set position of item "LiveSubs.app" of container window to {170, 205}+ set position of item "Applications" of container window to {470, 205}+ update without registering applications+ delay 2+ close+ end tell+end tell+APPLESCRIPT++sync+mkdir -p Resources/dmg+cp "/Volumes/Live Subs/.DS_Store" Resources/dmg/DS_Store+hdiutil detach "/Volumes/Live Subs" -quiet+rm -rf "$WORK"+echo "Updated Resources/dmg/DS_Store"diff --git a/scripts/package.sh b/scripts/package.shnew file mode 100755index 0000000..5e7d9f0--- /dev/null+++ b/scripts/package.sh@@ -0,0 +1,45 @@+#!/usr/bin/env bash+# Builds the release app and packages it in build/:+# LiveSubs-<version>-macOS-AppleSilicon.dmg drag-to-Applications installer (recommended download)+# LiveSubs-<version>-macOS-AppleSilicon.zip the bare app+# checksums.txt SHA-256 of both+set -euo pipefail+cd "$(dirname "$0")/.."++RELEASE=1 scripts/build.sh+APP=build/LiveSubs.app+ID=$(/usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" "$APP/Contents/Info.plist")+[[ "$ID" == com.wquguru.cicada ]] || { echo "Not a release build: $ID" >&2; exit 1; }+VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" Resources/Info.plist)+NAME="LiveSubs-$VERSION-macOS-AppleSilicon"+rm -f build/LiveSubs-*.zip build/LiveSubs-*.dmg build/checksums.txt++ditto -c -k --keepParent "$APP" "build/$NAME.zip"++# Installer window background, drawn by the app itself at 1x and 2x.+rm -rf build/dmg && mkdir -p build/dmg+"$APP/Contents/MacOS/LiveSubs" --render-dmg-background build/dmg/background.png 1+"$APP/Contents/MacOS/LiveSubs" --render-dmg-background build/dmg/[email protected] 2+tiffutil -cathidpicheck build/dmg/background.png build/dmg/[email protected] -out build/dmg/background.tiff 2>/dev/null++# The window layout is a Finder-made .DS_Store kept in the repo (scripts/dmg-template.sh), so+# packaging needs no Finder scripting and works in CI. Without it the DMG still works, just+# without the arranged window. The volume is always named "Live Subs".+STAGE=build/dmg/stage+MOUNT=build/dmg/mount+mkdir -p "$STAGE/.background" "$MOUNT"+cp -R "$APP" "$STAGE/"+ln -s /Applications "$STAGE/Applications"+cp build/dmg/background.tiff "$STAGE/.background/background.tiff"+[[ -f Resources/dmg/DS_Store ]] && cp Resources/dmg/DS_Store "$STAGE/.DS_Store"+cp "$APP/Contents/Resources/AppIcon.icns" "$STAGE/.VolumeIcon.icns"+hdiutil create -quiet -srcfolder "$STAGE" -volname "Live Subs" -fs HFS+ -format UDRW -ov build/dmg/rw.dmg+hdiutil attach -quiet -readwrite -noverify -noautoopen -nobrowse -mountpoint "$MOUNT" build/dmg/rw.dmg+SetFile -a C "$MOUNT" 2>/dev/null || true+hdiutil detach -quiet "$MOUNT"+hdiutil convert -quiet build/dmg/rw.dmg -format UDZO -imagekey zlib-level=9 -ov -o "build/$NAME.dmg"+# Drop the staged copy so Spotlight and Launch Services don't list a second LiveSubs.app.+rm -rf "$STAGE" "$MOUNT" build/dmg/rw.dmg++(cd build && shasum -a 256 "$NAME.dmg" "$NAME.zip" > checksums.txt)+echo "Packaged build/$NAME.dmg, build/$NAME.zip, build/checksums.txt"