48 lines
1.1 KiB
Bash
48 lines
1.1 KiB
Bash
#!/bin/bash
|
|
# Shared helpers for TargetPrint release scripts.
|
|
|
|
macos_root() {
|
|
# Works when this tree is the Gitea repo root *or* lives under macos/.
|
|
local here
|
|
here="$(cd "$(dirname "${BASH_SOURCE[1]}")/.." && pwd)"
|
|
if [[ -d "$here/TargetPrint.xcodeproj" ]]; then
|
|
echo "$here"
|
|
return
|
|
fi
|
|
if [[ -d "$here/macos/TargetPrint.xcodeproj" ]]; then
|
|
echo "$here/macos"
|
|
return
|
|
fi
|
|
echo "$here"
|
|
}
|
|
|
|
sign_app() {
|
|
local app="$1"
|
|
local entitlements="$2"
|
|
local identity="${MACOS_CODESIGN_IDENTITY:--}"
|
|
if ! command -v codesign >/dev/null 2>&1; then
|
|
echo "codesign not available; skipping"
|
|
return 0
|
|
fi
|
|
codesign --force --deep --options runtime \
|
|
--sign "$identity" \
|
|
--entitlements "$entitlements" \
|
|
"$app"
|
|
codesign --verify --verbose=2 "$app" || true
|
|
}
|
|
|
|
cpu_jobs() {
|
|
if [ -n "${JOBS:-}" ]; then
|
|
echo "$JOBS"
|
|
return
|
|
fi
|
|
sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo 4
|
|
}
|
|
|
|
zip_app() {
|
|
local app="$1"
|
|
local dest="$2"
|
|
rm -f "$dest"
|
|
ditto -c -k --keepParent "$app" "$dest"
|
|
}
|