installer: fix cmake source dir, absolute qmldir, trap timing, SVG fallback
This commit is contained in:
parent
cd7ade0371
commit
5d7cb5dfe1
1 changed files with 40 additions and 23 deletions
|
|
@ -30,6 +30,9 @@
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Platform check: require macOS
|
||||||
|
[[ "$(uname)" != "Darwin" ]] && { echo "[ERROR] This script requires macOS" >&2; exit 1; }
|
||||||
|
|
||||||
# Color codes for output
|
# Color codes for output
|
||||||
readonly COLOR_RESET='\033[0m'
|
readonly COLOR_RESET='\033[0m'
|
||||||
readonly COLOR_INFO='\033[0;36m' # Cyan
|
readonly COLOR_INFO='\033[0;36m' # Cyan
|
||||||
|
|
@ -49,15 +52,19 @@ error() {
|
||||||
echo -e "${COLOR_ERROR}[ERROR]${COLOR_RESET} $*" >&2
|
echo -e "${COLOR_ERROR}[ERROR]${COLOR_RESET} $*" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Build success flag for cleanup control
|
||||||
|
BUILD_SUCCESS=false
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
info "Cleaning up temporary files..."
|
info "Cleaning up temporary files..."
|
||||||
if [[ -d "$TEMP_DIR" ]]; then
|
if [[ "$BUILD_SUCCESS" == false && -d "$TEMP_DIR" ]]; then
|
||||||
rm -rf "$TEMP_DIR"
|
rm -rf "$TEMP_DIR"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Trap EXIT to ensure cleanup
|
# Trap EXIT for cleanup, ERR for early error exit
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
trap 'exit 1' ERR
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Parse CLI arguments
|
# Parse CLI arguments
|
||||||
|
|
@ -186,7 +193,9 @@ ok "boringtun build complete"
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
info "Step 2: Configuring CMake..."
|
info "Step 2: Configuring CMake..."
|
||||||
|
mkdir -p "$BUILD_DIR"
|
||||||
CMAKE_ARGS=(
|
CMAKE_ARGS=(
|
||||||
|
"-S" "$REPO_ROOT"
|
||||||
"-B" "$BUILD_DIR"
|
"-B" "$BUILD_DIR"
|
||||||
"-DCMAKE_BUILD_TYPE=Release"
|
"-DCMAKE_BUILD_TYPE=Release"
|
||||||
)
|
)
|
||||||
|
|
@ -225,7 +234,8 @@ ok "Found: $APP_BUNDLE"
|
||||||
|
|
||||||
info "Step 5: Running macdeployqt to bundle Qt frameworks..."
|
info "Step 5: Running macdeployqt to bundle Qt frameworks..."
|
||||||
# Use macdeployqt without -dmg (we'll create the DMG ourselves)
|
# Use macdeployqt without -dmg (we'll create the DMG ourselves)
|
||||||
macdeployqt "$APP_BUNDLE" -qmldir=app
|
# Use absolute path for -qmldir
|
||||||
|
macdeployqt "$APP_BUNDLE" -qmldir="$REPO_ROOT/app"
|
||||||
ok "macdeployqt complete"
|
ok "macdeployqt complete"
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
@ -276,24 +286,8 @@ mkdir -p "$OUTPUT_DIR"
|
||||||
|
|
||||||
# Prepare background image
|
# Prepare background image
|
||||||
DMG_BG_PATH="$REPO_ROOT/package/mac/dmg-background.png"
|
DMG_BG_PATH="$REPO_ROOT/package/mac/dmg-background.png"
|
||||||
if [[ -f "$REPO_ROOT/package/mac/dmg-background.svg" ]]; then
|
|
||||||
info "Converting SVG background to PNG..."
|
|
||||||
if command -v rsvg-convert &>/dev/null; then
|
|
||||||
rsvg-convert -w 660 -h 400 "$REPO_ROOT/package/mac/dmg-background.svg" -o "$DMG_BG_PATH"
|
|
||||||
ok "SVG converted to PNG"
|
|
||||||
else
|
|
||||||
info "rsvg-convert not found; creating placeholder background"
|
|
||||||
# Create a simple dark placeholder PNG (if needed; create-dmg works without a background)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use create-dmg
|
|
||||||
DMG_OUTPUT="$OUTPUT_DIR/DragonMoonlight-$VERSION.dmg"
|
|
||||||
rm -f "$DMG_OUTPUT"
|
|
||||||
|
|
||||||
CREATE_DMG_ARGS=(
|
CREATE_DMG_ARGS=(
|
||||||
--volname "DragonMoonlight"
|
--volname "DragonMoonlight"
|
||||||
--volicon "$APP_BUNDLE/Contents/Resources/icon.icns"
|
|
||||||
--window-pos 200 120
|
--window-pos 200 120
|
||||||
--window-size 660 400
|
--window-size 660 400
|
||||||
--icon-size 128
|
--icon-size 128
|
||||||
|
|
@ -302,14 +296,34 @@ CREATE_DMG_ARGS=(
|
||||||
--app-drop-link 500 185
|
--app-drop-link 500 185
|
||||||
)
|
)
|
||||||
|
|
||||||
if [[ -f "$DMG_BG_PATH" ]]; then
|
# Handle SVG background conversion
|
||||||
|
if [[ -f "$REPO_ROOT/package/mac/dmg-background.svg" ]]; then
|
||||||
|
info "Converting SVG background to PNG..."
|
||||||
|
if command -v rsvg-convert &>/dev/null; then
|
||||||
|
rsvg-convert -w 660 -h 400 "$REPO_ROOT/package/mac/dmg-background.svg" -o "$DMG_BG_PATH"
|
||||||
CREATE_DMG_ARGS+=(--background "$DMG_BG_PATH")
|
CREATE_DMG_ARGS+=(--background "$DMG_BG_PATH")
|
||||||
|
ok "SVG converted to PNG"
|
||||||
|
else
|
||||||
|
info "rsvg-convert not found — DMG will use plain background (brew install librsvg to add branding)"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for icon and conditionally add --volicon
|
||||||
|
if [[ -f "$APP_BUNDLE/Contents/Resources/icon.icns" ]]; then
|
||||||
|
CREATE_DMG_ARGS+=(--volicon "$APP_BUNDLE/Contents/Resources/icon.icns")
|
||||||
|
else
|
||||||
|
info "Warning: icon.icns not found; DMG will not have custom volume icon"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use create-dmg
|
||||||
|
DMG_OUTPUT="$OUTPUT_DIR/DragonMoonlight-$VERSION.dmg"
|
||||||
|
rm -f "$DMG_OUTPUT"
|
||||||
|
|
||||||
create-dmg "${CREATE_DMG_ARGS[@]}" "$DMG_OUTPUT" "$(dirname "$APP_BUNDLE")/DragonMoonlight.app"
|
create-dmg "${CREATE_DMG_ARGS[@]}" "$DMG_OUTPUT" "$(dirname "$APP_BUNDLE")/DragonMoonlight.app"
|
||||||
|
|
||||||
if [[ ! -f "$DMG_OUTPUT" ]]; then
|
# Validate DMG is non-zero
|
||||||
error "Failed to create DMG at $DMG_OUTPUT"
|
if [[ ! -s "$DMG_OUTPUT" ]]; then
|
||||||
|
error "DMG is empty or missing: $DMG_OUTPUT"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -327,6 +341,9 @@ ok "SHA256: $CHECKSUM"
|
||||||
# Summary
|
# Summary
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
# Mark build as successful before cleanup runs
|
||||||
|
BUILD_SUCCESS=true
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
ok "=== Build Complete ==="
|
ok "=== Build Complete ==="
|
||||||
echo " Version: $VERSION"
|
echo " Version: $VERSION"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue