|
| 1 | +#!/bin/bash |
| 2 | +# Build macOS installer package for Wavetable |
| 3 | + |
| 4 | +set -e |
| 5 | + |
| 6 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 7 | +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" |
| 8 | +VERSION="${VERSION:-1.0.0}" |
| 9 | +PLUGIN_NAME="Wavetable" |
| 10 | + |
| 11 | +# Paths |
| 12 | +BIN_DIR="$ROOT_DIR/ci/bin" |
| 13 | +PKG_ROOT="$SCRIPT_DIR/pkg_root" |
| 14 | +OUTPUT_DIR="$SCRIPT_DIR/output" |
| 15 | + |
| 16 | +# Signing identities (set via environment or leave empty for unsigned) |
| 17 | +DEV_APP_ID="${DEV_APP_ID:-}" |
| 18 | +DEV_INST_ID="${DEV_INST_ID:-}" |
| 19 | + |
| 20 | +echo "Building Wavetable $VERSION installer..." |
| 21 | + |
| 22 | +# Clean and create directories |
| 23 | +rm -rf "$PKG_ROOT" "$OUTPUT_DIR" |
| 24 | +mkdir -p "$PKG_ROOT" |
| 25 | +mkdir -p "$OUTPUT_DIR" |
| 26 | + |
| 27 | +# Create package root structure |
| 28 | +mkdir -p "$PKG_ROOT/Library/Audio/Plug-Ins/VST" |
| 29 | +mkdir -p "$PKG_ROOT/Library/Audio/Plug-Ins/VST3" |
| 30 | +mkdir -p "$PKG_ROOT/Library/Audio/Plug-Ins/Components" |
| 31 | +mkdir -p "$PKG_ROOT/Library/Application Support/SocaLabs/Wavetable/Wavetables" |
| 32 | +mkdir -p "$PKG_ROOT/Library/Application Support/SocaLabs/Wavetable/Presets" |
| 33 | + |
| 34 | +# Copy plugins |
| 35 | +if [ -d "$BIN_DIR/vst/$PLUGIN_NAME.vst" ]; then |
| 36 | + cp -R "$BIN_DIR/vst/$PLUGIN_NAME.vst" "$PKG_ROOT/Library/Audio/Plug-Ins/VST/" |
| 37 | +fi |
| 38 | + |
| 39 | +if [ -d "$BIN_DIR/vst3/$PLUGIN_NAME.vst3" ]; then |
| 40 | + cp -R "$BIN_DIR/vst3/$PLUGIN_NAME.vst3" "$PKG_ROOT/Library/Audio/Plug-Ins/VST3/" |
| 41 | +fi |
| 42 | + |
| 43 | +if [ -d "$BIN_DIR/au/$PLUGIN_NAME.component" ]; then |
| 44 | + cp -R "$BIN_DIR/au/$PLUGIN_NAME.component" "$PKG_ROOT/Library/Audio/Plug-Ins/Components/" |
| 45 | +fi |
| 46 | + |
| 47 | +# Copy wavetables and presets |
| 48 | +cp -R "$ROOT_DIR/plugin/Resources/WavetablesFLAC/"* "$PKG_ROOT/Library/Application Support/SocaLabs/Wavetable/Wavetables/" |
| 49 | +cp -R "$ROOT_DIR/plugin/Resources/Presets/"* "$PKG_ROOT/Library/Application Support/SocaLabs/Wavetable/Presets/" |
| 50 | + |
| 51 | +# Set permissions |
| 52 | +chmod -R 755 "$PKG_ROOT/Library/Audio" |
| 53 | +chmod -R 755 "$PKG_ROOT/Library/Application Support" |
| 54 | + |
| 55 | +# Build component package |
| 56 | +pkgbuild --root "$PKG_ROOT" \ |
| 57 | + --identifier "com.socalabs.wavetable.pkg" \ |
| 58 | + --version "$VERSION" \ |
| 59 | + --install-location "/" \ |
| 60 | + "$OUTPUT_DIR/Wavetable-component.pkg" |
| 61 | + |
| 62 | +# Create distribution.xml |
| 63 | +cat > "$OUTPUT_DIR/distribution.xml" << EOF |
| 64 | +<?xml version="1.0" encoding="utf-8"?> |
| 65 | +<installer-gui-script minSpecVersion="1"> |
| 66 | + <title>Wavetable $VERSION</title> |
| 67 | + <organization>com.socalabs</organization> |
| 68 | + <domains enable_localSystem="true"/> |
| 69 | + <options customize="never" require-scripts="true" rootVolumeOnly="true" /> |
| 70 | + <welcome file="welcome.txt" mime-type="text/plain" /> |
| 71 | + <choices-outline> |
| 72 | + <line choice="default"> |
| 73 | + <line choice="com.socalabs.wavetable.pkg"/> |
| 74 | + </line> |
| 75 | + </choices-outline> |
| 76 | + <choice id="default"/> |
| 77 | + <choice id="com.socalabs.wavetable.pkg" visible="false"> |
| 78 | + <pkg-ref id="com.socalabs.wavetable.pkg"/> |
| 79 | + </choice> |
| 80 | + <pkg-ref id="com.socalabs.wavetable.pkg" version="$VERSION" onConclusion="none">Wavetable-component.pkg</pkg-ref> |
| 81 | +</installer-gui-script> |
| 82 | +EOF |
| 83 | + |
| 84 | +# Create welcome text |
| 85 | +cat > "$OUTPUT_DIR/welcome.txt" << EOF |
| 86 | +Welcome to the Wavetable $VERSION installer. |
| 87 | +
|
| 88 | +This will install: |
| 89 | +- Wavetable VST2 plugin |
| 90 | +- Wavetable VST3 plugin |
| 91 | +- Wavetable AU plugin |
| 92 | +- Factory wavetables |
| 93 | +- Factory presets |
| 94 | +
|
| 95 | +Click Continue to proceed with the installation. |
| 96 | +EOF |
| 97 | + |
| 98 | +# Build product archive |
| 99 | +UNSIGNED_PKG="$OUTPUT_DIR/${PLUGIN_NAME}_${VERSION}_Mac_unsigned.pkg" |
| 100 | +SIGNED_PKG="$OUTPUT_DIR/${PLUGIN_NAME}_${VERSION}_Mac.pkg" |
| 101 | + |
| 102 | +productbuild --distribution "$OUTPUT_DIR/distribution.xml" \ |
| 103 | + --package-path "$OUTPUT_DIR" \ |
| 104 | + --resources "$OUTPUT_DIR" \ |
| 105 | + "$UNSIGNED_PKG" |
| 106 | + |
| 107 | +# Sign if identity is available |
| 108 | +if [ -n "$DEV_INST_ID" ]; then |
| 109 | + echo "Signing installer..." |
| 110 | + productsign --sign "$DEV_INST_ID" "$UNSIGNED_PKG" "$SIGNED_PKG" |
| 111 | + rm "$UNSIGNED_PKG" |
| 112 | + echo "Signed installer: $SIGNED_PKG" |
| 113 | +else |
| 114 | + mv "$UNSIGNED_PKG" "$SIGNED_PKG" |
| 115 | + echo "Unsigned installer: $SIGNED_PKG" |
| 116 | +fi |
| 117 | + |
| 118 | +# Cleanup |
| 119 | +rm -rf "$PKG_ROOT" |
| 120 | +rm -f "$OUTPUT_DIR/Wavetable-component.pkg" |
| 121 | +rm -f "$OUTPUT_DIR/distribution.xml" |
| 122 | +rm -f "$OUTPUT_DIR/welcome.txt" |
| 123 | + |
| 124 | +echo "Done! Installer created: $SIGNED_PKG" |
0 commit comments