| 1 | #!/bin/bash |
| 2 | |
| 3 | set -euo pipefail |
| 4 | src=$(cd "$(dirname "$0")" && pwd) |
| 5 | app=${1:?Specify a new output .app path} |
| 6 | [[ $app == /*.app && ! -e $app ]] || { echo 'Choose a new absolute .app path.' >&2; exit 2; } |
| 7 | mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources" |
| 8 | cat > "$app/Contents/Info.plist" <<'PLIST' |
| 9 | <?xml version="1.0" encoding="UTF-8"?> |
| 10 | <plist version="1.0"><dict> |
| 11 | <key>CFBundleIdentifier</key><string>dev.cage.GuestClipboard</string> |
| 12 | <key>CFBundleName</key><string>Cage Guest Clipboard</string> |
| 13 | <key>CFBundleExecutable</key><string>CageGuestClipboard</string> |
| 14 | <key>CFBundlePackageType</key><string>APPL</string> |
| 15 | <key>CFBundleShortVersionString</key><string>1.0</string> |
| 16 | <key>CFBundleVersion</key><string>1</string> |
| 17 | <key>LSUIElement</key><true/> |
| 18 | </dict></plist> |
| 19 | PLIST |
| 20 | xcrun swiftc -parse-as-library -O -target arm64-apple-macos14.0 "$src/guest-clipboard-macos.swift" "$src/macos-diagnostics.swift" -o "$app/Contents/MacOS/CageGuestClipboard" |
| 21 | (cd "$src/../.." && CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags '-s -w' -o "$app/Contents/Resources/cage-guest-files" ./cmd/cage-guest-files) |
| 22 | identity=${CAGE_GUEST_SIGN_IDENTITY:-${CAGE_SIGNING_IDENTITY:--}} |
| 23 | codesign --force --sign "$identity" "$app/Contents/Resources/cage-guest-files" |
| 24 | codesign --force --sign "$identity" --identifier dev.cage.GuestClipboard "$app" |
| 25 | codesign --verify --deep --strict "$app" |