Repository navigation
Fix bundled Ghostty theme picker helper packaging #1416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
fc94a07
e48a701
0350b78
cab0e29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| usage() { | ||
| cat <<'EOF' | ||
| Usage: ./scripts/build-ghostty-cli-helper.sh [--universal] --output <path> | ||
|
|
||
| Options: | ||
| --universal Build a universal macOS helper (arm64 + x86_64). | ||
| --output <path> Destination path for the built helper. | ||
| EOF | ||
| } | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
| REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" | ||
| GHOSTTY_DIR="$REPO_ROOT/ghostty" | ||
|
|
||
| OUTPUT_PATH="" | ||
| UNIVERSAL="false" | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| --universal) | ||
| UNIVERSAL="true" | ||
| shift | ||
| ;; | ||
| --output) | ||
| OUTPUT_PATH="${2:-}" | ||
| shift 2 | ||
| ;; | ||
| -h|--help) | ||
| usage | ||
| exit 0 | ||
| ;; | ||
| *) | ||
| echo "Unknown option: $1" >&2 | ||
| usage >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [[ -z "$OUTPUT_PATH" ]]; then | ||
| echo "Missing required --output path" >&2 | ||
| usage >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! command -v zig >/dev/null 2>&1; then | ||
| echo "error: zig is required to build the Ghostty CLI helper" >&2 | ||
| exit 1 | ||
|
Comment on lines
+83
to
+85
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This new helper builder exits immediately if Useful? React with 👍 / 👎.
Comment on lines
+83
to
+85
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This helper now hard-fails when Useful? React with 👍 / 👎. |
||
| fi | ||
|
|
||
| if [[ ! -f "$GHOSTTY_DIR/build.zig" ]]; then | ||
| echo "error: Ghostty submodule is missing at $GHOSTTY_DIR" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| build_helper() { | ||
| local prefix="$1" | ||
| local target="${2:-}" | ||
| local args=( | ||
| zig build | ||
| cli-helper | ||
| -Dapp-runtime=none | ||
| -Demit-macos-app=false | ||
| -Demit-xcframework=false | ||
| -Doptimize=ReleaseFast | ||
| --prefix | ||
| "$prefix" | ||
| ) | ||
|
|
||
| if [[ -n "$target" ]]; then | ||
| args+=("-Dtarget=$target") | ||
| fi | ||
|
|
||
| ( | ||
| cd "$GHOSTTY_DIR" | ||
| "${args[@]}" | ||
| ) | ||
| } | ||
|
|
||
| TMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/cmux-ghostty-helper.XXXXXX")" | ||
| trap 'rm -rf "$TMP_DIR"' EXIT | ||
|
|
||
| mkdir -p "$(dirname "$OUTPUT_PATH")" | ||
|
|
||
| if [[ "$UNIVERSAL" == "true" ]]; then | ||
| ARM64_PREFIX="$TMP_DIR/arm64" | ||
| X86_PREFIX="$TMP_DIR/x86_64" | ||
| build_helper "$ARM64_PREFIX" "aarch64-macos" | ||
| build_helper "$X86_PREFIX" "x86_64-macos" | ||
| /usr/bin/lipo -create \ | ||
| "$ARM64_PREFIX/bin/ghostty" \ | ||
| "$X86_PREFIX/bin/ghostty" \ | ||
| -output "$OUTPUT_PATH" | ||
| else | ||
| HOST_PREFIX="$TMP_DIR/host" | ||
| build_helper "$HOST_PREFIX" | ||
| install -m 755 "$HOST_PREFIX/bin/ghostty" "$OUTPUT_PATH" | ||
| fi | ||
|
|
||
| chmod +x "$OUTPUT_PATH" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verify helper architecture set, not just existence.
This check can pass with a single-arch helper, which risks shipping a non-universal release artifact.
Suggested hardening
- name: Verify bundled Ghostty theme picker helper if: steps.guard_release_assets.outputs.skip_all != 'true' run: | set -euo pipefail HELPER_BINARY="build/Build/Products/Release/cmux.app/Contents/Resources/bin/ghostty" [ -x "$HELPER_BINARY" ] || { echo "Ghostty theme picker helper not found at $HELPER_BINARY" >&2; exit 1; } + HELPER_ARCHS="$(/usr/bin/lipo -archs "$HELPER_BINARY")" + case " $HELPER_ARCHS " in + *" arm64 "*) ;; + *) echo "Ghostty helper missing arm64 architecture: $HELPER_ARCHS" >&2; exit 1 ;; + esac + case " $HELPER_ARCHS " in + *" x86_64 "*) ;; + *) echo "Ghostty helper missing x86_64 architecture: $HELPER_ARCHS" >&2; exit 1 ;; + esac📝 Committable suggestion
🤖 Prompt for AI Agents