mac packaging improvements

This commit is contained in:
Agel committed 2026-11-12 16:49:42 +01:00
1 parent 5151e40bde
commit 154880f4e4
5 files changed
+332 -9

No files matched your search

+2 -1
View File
@@ -39,4 +39,5 @@ Thumbs.db
/aqtinstall.log /aqtinstall.log
.claude/worktrees/ .claude/worktrees/
.junie .junie
/dist/Asteria.dmg
Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

+61
View File
@@ -0,0 +1,61 @@
<svg xmlns="http://www.w3.org/2000/svg" width="660" height="400" viewBox="0 0 660 400">
<defs>
<!-- Asteria Default Theme Gradient (ThemePalette.qml) -->
<linearGradient id="bgGradient" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#0e1125"/>
<stop offset="100%" stop-color="#191d35"/>
</linearGradient>
<!-- Subtle ambient radial glow behind center -->
<radialGradient id="centerGlow" cx="50%" cy="46%" r="55%">
<stop offset="0%" stop-color="#3a5688" stop-opacity="0.22"/>
<stop offset="65%" stop-color="#191d35" stop-opacity="0.06"/>
<stop offset="100%" stop-color="#0e1125" stop-opacity="0"/>
</radialGradient>
<!-- Arrow Accent Gradient (buttonAccent -> sidebarButtonText) -->
<linearGradient id="arrowGradient" gradientUnits="userSpaceOnUse" x1="278" y1="180" x2="378" y2="180">
<stop offset="0%" stop-color="#5785c1"/>
<stop offset="100%" stop-color="#98aaf4"/>
</linearGradient>
<!-- Soft drop shadow for arrow and pills -->
<filter id="softGlow" x="-20%" y="-20%" width="140%" height="140%">
<feGaussianBlur stdDeviation="3" result="blur"/>
<feComposite in="SourceGraphic" in2="blur" operator="over"/>
</filter>
</defs>
<!-- Canvas background -->
<rect width="660" height="400" fill="url(#bgGradient)"/>
<rect width="660" height="400" fill="url(#centerGlow)"/>
<!-- Subtle starry night accents matching Asteria icon -->
<g fill="#c4c8d8">
<circle cx="58" cy="48" r="1.2" opacity="0.28"/>
<circle cx="122" cy="72" r="0.9" opacity="0.22"/>
<circle cx="245" cy="42" r="1.1" opacity="0.24"/>
<circle cx="330" cy="64" r="1.4" opacity="0.30"/>
<circle cx="428" cy="38" r="0.9" opacity="0.20"/>
<circle cx="545" cy="66" r="1.3" opacity="0.28"/>
<circle cx="608" cy="50" r="1.0" opacity="0.22"/>
<circle cx="44" cy="322" r="1.0" opacity="0.20"/>
<circle cx="330" cy="348" r="1.1" opacity="0.22"/>
<circle cx="614" cy="332" r="1.2" opacity="0.24"/>
</g>
<!-- Light frosted label pills aligned directly behind Finder's black text (y=258..269) -->
<rect x="119" y="253" width="112" height="22" rx="11"
fill="#eef1f7" fill-opacity="0.90"/>
<rect x="429" y="253" width="112" height="22" rx="11"
fill="#eef1f7" fill-opacity="0.90"/>
<!-- Directional Arrow (center x=330, y=180) -->
<g filter="url(#softGlow)">
<line x1="278" y1="180" x2="364" y2="180"
stroke="url(#arrowGradient)" stroke-width="5.5" stroke-linecap="round"/>
<path d="M 354 162 L 378 180 L 354 198"
fill="none" stroke="url(#arrowGradient)" stroke-width="5.5"
stroke-linecap="round" stroke-linejoin="round"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

+174
View File
@@ -0,0 +1,174 @@
#!/usr/bin/env python3
"""Generate a macOS Finder .DS_Store for a DMG installer window without AppleEvents/TCC."""
import ctypes
import plistlib
import struct
import sys
from pathlib import Path
def make_carbon_alias(volume_root: Path, target_path: Path) -> bytes:
"""Create a genuine Carbon AliasRecord ('alis') via macOS CoreServices."""
cs = ctypes.CDLL("/System/Library/Frameworks/CoreServices.framework/CoreServices")
cs.FSPathMakeRef.argtypes = [ctypes.c_char_p, ctypes.c_void_p, ctypes.c_void_p]
cs.FSPathMakeRef.restype = ctypes.c_int32
cs.FSNewAlias.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)]
cs.FSNewAlias.restype = ctypes.c_int32
cs.GetHandleSize.argtypes = [ctypes.c_void_p]
cs.GetHandleSize.restype = ctypes.c_long
cs.DisposeHandle.argtypes = [ctypes.c_void_p]
cs.DisposeHandle.restype = None
from_ref = (ctypes.c_ubyte * 80)()
err = cs.FSPathMakeRef(str(volume_root).encode("utf-8"), from_ref, None)
if err != 0:
raise RuntimeError(f"FSPathMakeRef({volume_root}) failed with OSStatus {err}")
target_ref = (ctypes.c_ubyte * 80)()
err = cs.FSPathMakeRef(str(target_path).encode("utf-8"), target_ref, None)
if err != 0:
raise RuntimeError(f"FSPathMakeRef({target_path}) failed with OSStatus {err}")
alias_handle = ctypes.c_void_p()
err = cs.FSNewAlias(from_ref, target_ref, ctypes.byref(alias_handle))
if err != 0 or not alias_handle:
raise RuntimeError(f"FSNewAlias({target_path}) failed with OSStatus {err}")
try:
size = cs.GetHandleSize(alias_handle)
ptr = ctypes.cast(alias_handle, ctypes.POINTER(ctypes.c_void_p))[0]
return ctypes.string_at(ptr, size)
finally:
cs.DisposeHandle(alias_handle)
def encode_record(filename: str, code: bytes, dtype: bytes, value: bytes) -> bytes:
utf16 = filename.encode("utf-16-be")
return struct.pack(">I", len(filename)) + utf16 + code + dtype + value
def build_ds_store(volume_root: Path, bg_path: Path, app_name: str) -> bytes:
alias_bytes = make_carbon_alias(volume_root, bg_path)
bwsp_plist = plistlib.dumps(
{
"ContainerShowSidebar": False,
"ShowPathbar": False,
"ShowSidebar": False,
"ShowStatusBar": False,
"ShowTabView": False,
"ShowToolbar": False,
"WindowBounds": "{{200, 300}, {660, 428}}",
},
fmt=plistlib.FMT_BINARY,
)
icvp_plist = plistlib.dumps(
{
"arrangeBy": "none",
"backgroundColorBlue": 1.0,
"backgroundColorGreen": 1.0,
"backgroundColorRed": 1.0,
"backgroundImageAlias": alias_bytes,
"backgroundType": 2,
"gridOffsetX": 0.0,
"gridOffsetY": 0.0,
"gridSpacing": 100.0,
"iconSize": 128.0,
"labelOnBottom": True,
"scrollPositionX": 0.0,
"scrollPositionY": 0.0,
"showIconPreview": True,
"showItemInfo": False,
"textSize": 13.0,
"viewOptionsVersion": 1,
},
fmt=plistlib.FMT_BINARY,
)
iloc_app = struct.pack(">IIII", 175, 180, 0xFFFFFFFF, 0xFFFF0000)
iloc_apps = struct.pack(">IIII", 485, 180, 0xFFFFFFFF, 0xFFFF0000)
records = [
(".", b"bwsp", b"blob", struct.pack(">I", len(bwsp_plist)) + bwsp_plist),
(".", b"icvp", b"blob", struct.pack(">I", len(icvp_plist)) + icvp_plist),
(".", b"vSrn", b"long", struct.pack(">I", 1)),
(".", b"vstl", b"type", b"icnv"),
("Applications", b"Iloc", b"blob", struct.pack(">I", len(iloc_apps)) + iloc_apps),
(app_name, b"Iloc", b"blob", struct.pack(">I", len(iloc_app)) + iloc_app),
]
records.sort(key=lambda r: (r[0].lower(), r[1].lower()))
# B-tree leaf node (4096 bytes)
leaf_body = bytearray()
leaf_body += struct.pack(">II", 0, len(records)) # next_node=0 (leaf), record_count
for fname, code, dtype, val in records:
leaf_body += encode_record(fname, code, dtype, val)
if len(leaf_body) > 4096:
raise RuntimeError(f"Leaf node overflow: {len(leaf_body)} > 4096")
leaf_block = bytes(leaf_body).ljust(4096, b"\x00")
# DSDB master block (32 bytes)
# root_node_block=2, height=0 (single leaf), num_records, num_nodes=1, page_size=4096
dsdb_block = struct.pack(">IIIII", 2, 0, len(records), 1, 4096).ljust(32, b"\x00")
# Root bookkeeping block at buddy offset 0x2000 (size 2048 = 2^11)
# Block table: 0 -> root (0x200b), 1 -> DSDB (0x0045), 2 -> leaf (0x100c)
addrs = [0x2000 | 11, 0x0040 | 5, 0x1000 | 12]
root_body = bytearray()
root_body += struct.pack(">II", len(addrs), 0)
for a in addrs:
root_body += struct.pack(">I", a)
root_body += b"\x00" * ((256 - len(addrs)) * 4)
# Table of Contents: 1 entry ("DSDB" -> block 1)
root_body += struct.pack(">IB4sI", 1, 4, b"DSDB", 1)
# Free lists for buddy buckets 0..31 covering [0x0000..0x4000)
freelists = {
5: [0x0020, 0x0060],
7: [0x0080],
8: [0x0100],
9: [0x0200],
10: [0x0400],
11: [0x0800, 0x2800],
12: [0x3000],
}
for bucket in range(32):
entries = freelists.get(bucket, [])
root_body += struct.pack(">I", len(entries))
for off in entries:
root_body += struct.pack(">I", off)
if len(root_body) > 2048:
raise RuntimeError(f"Root block overflow: {len(root_body)} > 2048")
root_block = bytes(root_body).ljust(2048, b"\x00")
# Assemble buddy heap [0x0000..0x4000) prefixed by 4-byte alignment header (0x00000001)
heap = bytearray(0x4000)
heap[0x0000:0x0020] = struct.pack(">4sIII16s", b"Bud1", 0x2000, 2048, 0x2000, b"\x00" * 16)
heap[0x0040:0x0060] = dsdb_block
heap[0x1000:0x2000] = leaf_block
heap[0x2000:0x2800] = root_block
return struct.pack(">I", 1) + bytes(heap)
def main() -> int:
if len(sys.argv) != 4:
print(f"Usage: {sys.argv[0]} <mount-dir> <bg-image-path> <app-bundle-name>", file=sys.stderr)
return 2
mount_dir = Path(sys.argv[1]).resolve()
bg_path = Path(sys.argv[2]).resolve()
app_name = sys.argv[3]
ds_store_bytes = build_ds_store(mount_dir, bg_path, app_name)
out_path = mount_dir / ".DS_Store"
out_path.write_bytes(ds_store_bytes)
return 0
if __name__ == "__main__":
raise SystemExit(main())
+95 -8
View File
@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# Package macOS build as a .dmg disk image # Package macOS build as a styled .dmg disk image
# Usage: package-macos.sh <build-dir> <qt-dir> <output-dir> # Usage: package-macos.sh <build-dir> <qt-dir> <output-dir>
set -euo pipefail set -euo pipefail
@@ -9,17 +9,45 @@ OUTPUT_DIR="${3:?}"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
APP_PATH="$BUILD_DIR/asteria-qt.app" SRC_APP_PATH="$BUILD_DIR/asteria-qt.app"
DMG_NAME="Asteria.dmg" DMG_NAME="Asteria.dmg"
VOL_NAME="Asteria"
APP_BUNDLE_NAME="Asteria.app"
BG_SOURCE="$PROJECT_DIR/packaging/dmg-background.png"
ICON_SOURCE="$PROJECT_DIR/src/assets/asteria-qt.icns"
CODESIGN="${CODESIGN:-true}" CODESIGN="${CODESIGN:-true}"
CODESIGN_IDENTITY="${CODESIGN_IDENTITY:--}" CODESIGN_IDENTITY="${CODESIGN_IDENTITY:--}"
if [ ! -d "$APP_PATH" ]; then if [ ! -d "$SRC_APP_PATH" ]; then
echo "ERROR: App bundle not found at $APP_PATH" >&2 echo "ERROR: App bundle not found at $SRC_APP_PATH" >&2
exit 1 exit 1
fi fi
# Deploy Qt frameworks into the .app bundle if [ ! -f "$BG_SOURCE" ]; then
echo "ERROR: DMG background image not found at $BG_SOURCE" >&2
exit 1
fi
WORK_DIR="$(mktemp -d)"
STAGING_DIR="$WORK_DIR/staging"
RW_DMG="$WORK_DIR/Asteria-rw.dmg"
APP_PATH="$STAGING_DIR/$APP_BUNDLE_NAME"
MOUNT_DIR=""
DEVICE=""
cleanup() {
if [ -n "$DEVICE" ]; then
hdiutil detach "$DEVICE" -quiet 2>/dev/null || \
hdiutil detach "$DEVICE" -force -quiet 2>/dev/null || true
fi
rm -rf "$WORK_DIR"
}
trap cleanup EXIT
mkdir -p "$STAGING_DIR/.background"
ditto "$SRC_APP_PATH" "$APP_PATH"
# Deploy Qt frameworks into the staged .app bundle
"$QT_DIR/bin/macdeployqt" "$APP_PATH" -qmldir="$PROJECT_DIR/src/qml" "$QT_DIR/bin/macdeployqt" "$APP_PATH" -qmldir="$PROJECT_DIR/src/qml"
if [ "$CODESIGN" = "true" ]; then if [ "$CODESIGN" = "true" ]; then
@@ -47,9 +75,68 @@ if [ "$CODESIGN" = "true" ]; then
codesign --verify --deep --strict --verbose=2 "$APP_PATH" codesign --verify --deep --strict --verbose=2 "$APP_PATH"
fi fi
# Create .dmg directly in output directory # Populate standard macOS drag-to-Applications DMG layout
ln -s /Applications "$STAGING_DIR/Applications"
cp "$BG_SOURCE" "$STAGING_DIR/.background/dmg-background.png"
if [ -f "$ICON_SOURCE" ]; then
cp "$ICON_SOURCE" "$STAGING_DIR/.VolumeIcon.icns"
fi
# Create temporary read-write HFS+ DMG to configure Finder metadata
hdiutil create -srcfolder "$STAGING_DIR" -volname "$VOL_NAME" \
-fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -ov "$RW_DMG" >/dev/null
ATTACH_PLIST="$WORK_DIR/attach.plist"
hdiutil attach -readwrite -noverify -noautoopen -plist "$RW_DMG" > "$ATTACH_PLIST"
IFS=$'\t' read -r DEVICE MOUNT_DIR < <(python3 - "$ATTACH_PLIST" <<'PY'
import plistlib, sys
with open(sys.argv[1], "rb") as f:
data = plistlib.load(f)
dev = ""
mnt = ""
for ent in data.get("system-entities", []):
if "mount-point" in ent:
dev = ent.get("dev-entry", "")
mnt = ent["mount-point"]
break
print(f"{dev}\t{mnt}")
PY
)
if [ -z "$DEVICE" ] || [ -z "$MOUNT_DIR" ]; then
echo "ERROR: Failed to attach temporary DMG" >&2
exit 1
fi
# Hide background directory and enable custom volume icon
if command -v SetFile >/dev/null 2>&1; then
SetFile -a V "$MOUNT_DIR/.background" || true
if [ -f "$MOUNT_DIR/.VolumeIcon.icns" ]; then
SetFile -a V "$MOUNT_DIR/.VolumeIcon.icns" || true
SetFile -c icnC "$MOUNT_DIR/.VolumeIcon.icns" || true
SetFile -a C "$MOUNT_DIR" || true
fi
fi
# Configure Finder view options and icon coordinates (.DS_Store) without AppleEvents/TCC
python3 "$SCRIPT_DIR/generate_ds_store.py" \
"$MOUNT_DIR" \
"$MOUNT_DIR/.background/dmg-background.png" \
"$APP_BUNDLE_NAME"
if command -v SetFile >/dev/null 2>&1; then
SetFile -a V "$MOUNT_DIR/.DS_Store" || true
fi
sync
sleep 1
hdiutil detach "$DEVICE" >/dev/null || hdiutil detach "$DEVICE" -force >/dev/null
DEVICE=""
# Convert to compressed read-only DMG
mkdir -p "$OUTPUT_DIR" mkdir -p "$OUTPUT_DIR"
hdiutil create -volname "Asteria" -srcfolder "$APP_PATH" \ hdiutil convert "$RW_DMG" -format UDZO -imagekey zlib-level=9 -ov -o "$OUTPUT_DIR/$DMG_NAME" >/dev/null
-ov -format UDZO "$OUTPUT_DIR/$DMG_NAME" hdiutil verify "$OUTPUT_DIR/$DMG_NAME" >/dev/null
echo "Created: $OUTPUT_DIR/$DMG_NAME" echo "Created: $OUTPUT_DIR/$DMG_NAME"