Files
pokerfreak-shell/mac/bauen.sh
T

77 lines
3.1 KiB
Bash
Executable File

#!/bin/zsh
# Baut "Pokerfreak Cockpit.app" - ohne Xcode, nur mit den Command Line Tools.
#
# ./mac/bauen.sh baut nach mac/build/
# ./mac/bauen.sh --installieren und kopiert nach ~/Applications (dort ein fester Ort fuers Anmeldeobjekt)
# ./mac/bauen.sh --pruefen vorher die Pruefungen des Kerns (swift run Pruefung)
set -euo pipefail
HIER=${0:A:h}
SHELL_PFAD=${HIER:h}
NAME="Pokerfreak Cockpit"
APP="$HIER/build/$NAME.app"
cd "$HIER"
if [[ " $* " == *" --pruefen "* ]]; then
swift run -c debug Pruefung
fi
swift build -c release --product Cockpit
BIN=$(swift build -c release --show-bin-path)/Cockpit
rm -rf "$APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cp "$BIN" "$APP/Contents/MacOS/Cockpit"
# Symbol einmal zeichnen (liegt danach in build/ und wird wiederverwendet).
if [[ ! -f "$HIER/build/Cockpit.icns" ]]; then
swift "$HIER/werkzeug/icon.swift" "$HIER/build/Cockpit.iconset"
iconutil -c icns "$HIER/build/Cockpit.iconset" -o "$HIER/build/Cockpit.icns"
fi
cp "$HIER/build/Cockpit.icns" "$APP/Contents/Resources/Cockpit.icns"
cat > "$APP/Contents/Info.plist" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key><string>$NAME</string>
<key>CFBundleDisplayName</key><string>$NAME</string>
<key>CFBundleIdentifier</key><string>de.pokerfreak.cockpit</string>
<key>CFBundleExecutable</key><string>Cockpit</string>
<key>CFBundleIconFile</key><string>Cockpit</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleShortVersionString</key><string>1.0</string>
<key>CFBundleVersion</key><string>$(date +%Y%m%d%H%M)</string>
<key>CFBundleDevelopmentRegion</key><string>de</string>
<key>LSMinimumSystemVersion</key><string>26.0</string>
<key>LSUIElement</key><true/>
<key>NSHighResolutionCapable</key><true/>
<key>PokerfreakShell</key><string>$SHELL_PFAD</string>
<key>NSAppleEventsUsageDescription</key><string>Das Cockpit und der Läufer lesen über System Events, welche Tischfenster offen sind und wo sie liegen.</string>
</dict>
</plist>
PLIST
# Signatur: mit einer festen Identitaet (Developer ID aus dem Schluesselbund oder COCKPIT_SIGNATUR)
# bleiben die macOS-Freigaben (Bedienungshilfen, System Events) ueber Neubauten erhalten. Ohne sie
# braeuchte jede neue Fassung die Freigaben neu - und ohne Freigabe sieht das Cockpit keine Tische.
SIGNATUR=${COCKPIT_SIGNATUR:-$(security find-identity -v -p codesigning | sed -n 's/.*"\(Developer ID Application: [^"]*\)".*/\1/p' | head -1)}
if [[ -n "$SIGNATUR" ]]; then
codesign --force --sign "$SIGNATUR" --identifier de.pokerfreak.cockpit "$APP"
echo "signiert: $SIGNATUR"
else
codesign --force --sign - --identifier de.pokerfreak.cockpit "$APP"
echo "WARNUNG: nur ad-hoc signiert - nach jedem Neubau die Freigaben neu erteilen"
fi
if [[ " $* " == *" --installieren "* ]]; then
mkdir -p "$HOME/Applications"
rm -rf "$HOME/Applications/$NAME.app"
cp -R "$APP" "$HOME/Applications/"
APP="$HOME/Applications/$NAME.app"
fi
echo "fertig: $APP"
echo "starten: open \"$APP\""