Files
strawberry/build_tools/macos/print_mas_build_cmd.sh
David Helkowski 7a954b3f32 Enhance macOS build scripts for provisioning profile handling and identity management
This commit improves the `find_mas_provisioning_profile.sh` script by expanding the search for provisioning profiles to include both `.provisionprofile` and `.mobileprovision` files. It also introduces a new function to print SHA-1 values for identities, helping to avoid ambiguity when multiple identities share the same display name. Additionally, the `check_signing_identities.sh` script is updated to provide clearer recommendations for using SHA-1 hashes with codesigning and installer identities, enhancing the overall usability and clarity for developers working with macOS builds.
2026-01-22 21:15:07 +09:00

71 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ts() { date +"%H:%M:%S"; }
usage() {
cat <<'EOF'
Usage:
./build_tools/macos/print_mas_build_cmd.sh [--bundle-id com.dryark.strawberry] [--profile <path>]
What it does:
- Tries to auto-pick a provisioning profile for the bundle id
- Prints an exact build command you can copy/paste for build_mas_pkg.sh
Notes:
- This helper intentionally does NOT try to auto-pick signing identities by parsing Apple tool output.
Use SHA-1 identities from:
./build_tools/macos/check_signing_identities.sh
EOF
}
if [[ "$(uname -s)" != "Darwin" ]]; then
echo "Error: This script is for macOS only." >&2
exit 1
fi
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
repo_root="$(cd -- "${script_dir}/../.." && pwd)"
bundle_id="com.dryark.strawberry"
profile_path=""
codesign_identity=""
installer_identity=""
while [[ $# -gt 0 ]]; do
case "$1" in
--bundle-id) bundle_id="${2:-}"; shift 2 ;;
--profile) profile_path="${2:-}"; shift 2 ;;
--codesign-identity) codesign_identity="${2:-}"; shift 2 ;;
--installer-identity) installer_identity="${2:-}"; shift 2 ;;
-h|--help) usage; exit 0 ;;
*) echo "Unknown arg: $1" >&2; usage; exit 2 ;;
esac
done
if [[ -z "$profile_path" ]]; then
# Attempt to auto-select profile using the finder script.
finder="${repo_root}/build_tools/macos/find_mas_provisioning_profile.sh"
if [[ -x "$finder" ]]; then
out="$("$finder" --bundle-id "$bundle_id" 2>/dev/null || true)"
# Parse the line after "Recommended profile:"
profile_path="$(printf '%s\n' "$out" | awk 'found{print $1; exit} /^Recommended profile:/{found=1} found && $0 ~ /^ \\// {print $1; exit}' | sed 's/^[[:space:]]*//')"
fi
fi
echo "==> [$(ts)] Recommended build command:"
echo
echo "./build_tools/macos/build_mas_pkg.sh --run --release --clean \\"
echo " --codesign-identity \"${codesign_identity:-<SHA1 from check_signing_identities.sh>}\" \\"
echo " --installer-identity \"${installer_identity:-<SHA1 from check_signing_identities.sh>}\" \\"
if [[ -n "$profile_path" ]]; then
echo " --provisionprofile \"${profile_path}\""
else
echo " --provisionprofile \"</path/to/profile.provisionprofile>\""
echo
echo "Note: could not auto-pick a provisioning profile for bundle id '${bundle_id}'."
echo "Run:"
echo " ./build_tools/macos/find_mas_provisioning_profile.sh --bundle-id ${bundle_id}"
fi