8000 Polish the macOS installer by EClinick · Pull Request #10 · EClinick/juice · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Packaging/Juice-dmg-background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 4 additions & 12 deletions Scripts/build-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ fi
if [[ "$SIGNING_IDENTITY" == "-" ]]; then
SWIFT_FLAGS+=(-Xswiftc -DDEV_HELPER)
fi
# Link the app-bundle framework path into every Juice executable slice before
# SwiftPM applies its native signature. This keeps LC_RPATH ahead of
# LC_CODE_SIGNATURE and avoids rewriting the finished Mach-O.
SWIFT_FLAGS+=(-Xlinker -rpath -Xlinker "@executable_path/../Frameworks")

cd "$ROOT"
APP_BINARIES=()
Expand Down Expand Up @@ -109,18 +113,6 @@ else
chmod 755 "$APP_PATH/Contents/Library/HelperTools/JuiceHelper"
fi

# SwiftPM linker-signs the native arm64 slice, while the cross-compiled Intel
# slice is unsigned. Strip that 8000 inherited per-slice signature before changing
# Mach-O load commands; otherwise install_name_tool can place the new rpath
# after LC_CODE_SIGNATURE in arm64. Newer static verification accepts that
# layout, but macOS 26.3 rejects the running process's dynamic signature.
codesign --remove-signature "$APP_PATH/Contents/MacOS/Juice"

# SwiftPM gives command-line executables an @loader_path rpath. App bundles
# keep frameworks in Contents/Frameworks, so add the standard app-bundle rpath
# before applying one fresh signature to the completed universal executable.
install_name_tool -add_rpath @executable_path/../Frameworks "$APP_PATH/Contents/MacOS/Juice"

/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $VERSION" "$APP_PATH/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUILD_NUMBER" "$APP_PATH/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $APP_BUNDLE_ID" "$APP_PATH/Contents/Info.plist"
Expand Down
100 changes: 94 additions & 6 deletions Scripts/create-dmg.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail

# Create a simple Finder-ready disk image with a drag-to-Applications layout.
# Create a polished Finder disk image with Juice's Charge Across install layout.
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
OUTPUT_DIR="${OUTPUT_DIR:-$ROOT/dist}"
BACKGROUND_PATH="$ROOT/Packaging/Juice-dmg-background.png"
DEVELOPMENT_BUILD="${DEVELOPMENT_BUILD:-1}"
[[ "$DEVELOPMENT_BUILD" == "0" || "$DEVELOPMENT_BUILD" == "1" ]] || {
echo "DEVELOPMENT_BUILD must be 0 or 1" >&2
8000 Expand All @@ -22,8 +23,20 @@ else
exit 1
fi
fi
STAGING_DIR="$OUTPUT_DIR/dmg-staging"
DMG_PATH="$OUTPUT_DIR/$DMG_NAME"
WORK_DIR=""
MOUNT_DIR=""
MOUNTED=0

cleanup() {
if [[ "$MOUNTED" == "1" && -n "$MOUNT_DIR" && -d "$MOUNT_DIR" ]]; then
hdiutil detach "$MOUNT_DIR" >/dev/null 2>&1 || true
fi
if [[ -n "$WORK_DIR" && -d "$WORK_DIR" ]]; then
rm -rf "$WORK_DIR"
fi
}
trap cleanup EXIT

if [[ "${SKIP_APP_BUILD:-0}" != "1" ]]; then
rm -rf "$OUTPUT_DIR/$APP_NAME"
Expand All @@ -33,13 +46,88 @@ fi
echo "$APP_NAME is missing from $OUTPUT_DIR" >&2
exit 1
}
[[ -f "$BACKGROUND_PATH" ]] || {
echo "DMG background is missing: $BACKGROUND_PATH" >&2
exit 1
}

mkdir -p "$OUTPUT_DIR"
WORK_DIR="$(mktemp -d "$OUTPUT_DIR/.juice-dmg.XXXXXX")"
STAGING_DIR="$WORK_DIR/staging"
RW_DMG_PATH="$WORK_DIR/read-write.dmg"
mkdir -p "$STAGING_DIR/.background"

rm -rf "$STAGING_DIR" "$DMG_PATH"
mkdir -p "$STAGING_DIR"
# Preserve code-signing metadata and the app's stapled notarization ticket.
ditto "$OUTPUT_DIR/$APP_NAME" "$STAGING_DIR/$APP_NAME"
ln -s /Applications "$STAGING_DIR/Applications"
cp "$BACKGROUND_PATH" "$STAGING_DIR/.background/background.png"

rm -f "$DMG_PATH"
hdiutil create \
-volname "$VOLUME_NAME" \
-srcfolder "$STAGING_DIR" \
-ov \
-format UDRW \
"$RW_DMG_PATH" >/dev/null
ATTACH_OUTPUT="$(hdiutil attach \
"$RW_DMG_PATH" \
-readwrite \
-noverify \
-noautoopen)"
MOUNT_DIR="$(awk -F $'\t' '$3 ~ "^/Volumes/" { print $3 }' <<<"$ATTACH_OUTPUT" | tail -n 1)"
[[ -n "$MOUNT_DIR" && -d "$MOUNT_DIR" ]] || {
echo "Could not determine the mounted DMG path." >&2
exit 1
}
MOUNT_NAME="${MOUNT_DIR##*/}"
MOUNTED=1

# Finder writes this layout into the volume's .DS_Store. The real app and
# Applications alias sit over the two icon-safe zones in the background art.
if ! osascript - "$MOUNT_NAME" "$APP_NAME" "$MOUNT_DIR" <<'APPLESCRIPT'
on run arguments
set volumeName to item 1 of arguments
set appName to item 2 of arguments
set mountPath to item 3 of arguments
set backgroundImage to POSIX file (mountPath & "/.background/background.png") as alias

with timeout of 30 seconds
tell application "Finder"
delay 1
tell disk volumeName
open
tell container window
set current view to icon view
set toolbar visible to false
set statusbar visible to false
set bounds to {120, 120, 780, 540}
end tell
tell icon view options of container window
set arrangement to not arranged
set icon size to 128
set text size to 14
set background picture to backgroundImage
end tell
set position of item appName to {145, 215}
set position of item "Applications" to {515, 215}
update without registering applications
delay 1
close
end tell
end tell
end timeout
end run
APPLESCRIPT
then
echo "Finder could not save the DMG layout." >&2
echo "Check the Finder error above and verify Automation permission, then retry." >&2
exit 1
fi

sync
hdiutil detach "$MOUNT_DIR" >/dev/null
MOUNTED=0
MOUNT_DIR=""

hdiutil create -volname "$VOLUME_NAME" -srcfolder "$STAGING_DIR" -ov -format UDZO "$DMG_PATH"
rm -rf "$STAGING_DIR"
hdiutil convert "$RW_DMG_PATH" -format UDZO -o "$DMG_PATH" >/dev/null
echo "Built $DMG_PATH"
2 changes: 1 addition & 1 deletion Scripts/publish-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ wait_for_public_appcast_version() {
die "VERSION must be a stable semantic version such as 0.1.2"
[[ "$DRY_RUN" == "0" || "$DRY_RUN" == "1" ]] || die "DRY_RUN must be 0 or 1"

for command in awk cmp codesign curl ditto gh git grep hdiutil lipo make otool perl plutil rg ruby security sed shasum spctl strings swift xcrun xmllint; do
for command in awk cmp codesign curl ditto gh git grep hdiutil lipo make osascript otool perl plutil rg ruby security sed shasum spctl strings swift tail xcrun xmllint; do
require_command "$command"
done

Expand Down
0