56 lines
1.8 KiB
Bash
Executable File
56 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Package macOS build as a .dmg disk image
|
|
# Usage: package-macos.sh <build-dir> <qt-dir> <output-dir>
|
|
set -euo pipefail
|
|
|
|
BUILD_DIR="${1:?Usage: package-macos.sh <build-dir> <qt-dir> <output-dir>}"
|
|
QT_DIR="${2:?}"
|
|
OUTPUT_DIR="${3:?}"
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
APP_PATH="$BUILD_DIR/asteria-qt.app"
|
|
DMG_NAME="Asteria.dmg"
|
|
CODESIGN="${CODESIGN:-true}"
|
|
CODESIGN_IDENTITY="${CODESIGN_IDENTITY:--}"
|
|
|
|
if [ ! -d "$APP_PATH" ]; then
|
|
echo "ERROR: App bundle not found at $APP_PATH" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Deploy Qt frameworks into the .app bundle
|
|
"$QT_DIR/bin/macdeployqt" "$APP_PATH" -qmldir="$PROJECT_DIR/src/qml"
|
|
|
|
if [ "$CODESIGN" = "true" ]; then
|
|
echo "Signing $APP_PATH with identity '$CODESIGN_IDENTITY'..."
|
|
xattr -cr "$APP_PATH"
|
|
|
|
CODESIGN_ARGS=(--force --sign "$CODESIGN_IDENTITY")
|
|
if [ "$CODESIGN_IDENTITY" != "-" ]; then
|
|
CODESIGN_ARGS+=(--options runtime --timestamp)
|
|
fi
|
|
|
|
# Sign nested libraries and plugins inside-out before sealing the bundle
|
|
find "$APP_PATH/Contents/Frameworks" "$APP_PATH/Contents/PlugIns" \
|
|
-type f \( -name "*.dylib" -o -name "*.so" \) -print0 2>/dev/null | \
|
|
while IFS= read -r -d '' bin; do
|
|
codesign "${CODESIGN_ARGS[@]}" "$bin"
|
|
done
|
|
|
|
find "$APP_PATH/Contents/Frameworks" -maxdepth 1 -type d -name "*.framework" -print0 2>/dev/null | \
|
|
while IFS= read -r -d '' fw; do
|
|
codesign "${CODESIGN_ARGS[@]}" "$fw"
|
|
done
|
|
|
|
codesign "${CODESIGN_ARGS[@]}" "$APP_PATH"
|
|
codesign --verify --deep --strict --verbose=2 "$APP_PATH"
|
|
fi
|
|
|
|
# Create .dmg directly in output directory
|
|
mkdir -p "$OUTPUT_DIR"
|
|
hdiutil create -volname "Asteria" -srcfolder "$APP_PATH" \
|
|
-ov -format UDZO "$OUTPUT_DIR/$DMG_NAME"
|
|
|
|
echo "Created: $OUTPUT_DIR/$DMG_NAME"
|