@@ -1,11 +1,14 @@
11#!/usr/bin/env bash
22# Non-Nix installer for the native host (section 14).
33# scripts/install-manifest.sh [--beta] [--nightly] [--all-channels]
4+# The release zip ships this same script as install-host.command next to host/ and extension-id,
5+# so `bash install-host.command` works from the unzipped extension folder too.
46# Copies host/ to ~/.local/share/diagonal-host, links ~/.local/bin/diagonal-host to it, writes the Brave
57# host manifest with that absolute path and the pinned extension ID, then installs the fm schemas
68# and runs the self-test. Safe to re-run.
79set -euo pipefail
8−cd "$(dirname "$0")/.."
10+HERE="$(cd "$(dirname "$0")" && pwd)"
11+if [[ -d "$HERE/host" ]]; then cd "$HERE"; else cd "$HERE/.."; fi
912
1013CHANNELS=("Brave-Browser")
1114for arg in "$@"; do
@@ -24,12 +27,12 @@ if [[ -z "$ID" ]]; then
2427fi
2528
2629PYTHON=$(command -v python3 || true)
27−if [[ -z "$PYTHON" ]]; then
28− echo "python3 not found on PATH" >&2
30+# Brave starts the host with a minimal PATH, so the shebang names this python3 explicitly.
31+# On a Mac without the Command Line Tools, /usr/bin/python3 is a stub that only offers to install them.
32+if [[ -z "$PYTHON" ]] || ! PYTHON=$("$PYTHON" -c 'import sys; print(sys.executable)' 2>/dev/null); then
33+ echo "python3 is not set up. Run: xcode-select --install then run this installer again." >&2
2934 exit 1
3035fi
31−# Brave starts the host with a minimal PATH, so the shebang names this python3 explicitly.
32−PYTHON=$("$PYTHON" -c 'import sys; print(sys.executable)')
3336
3437SHARE="$HOME/.local/share/diagonal-host"
3538BIN="$HOME/.local/bin/diagonal-host"
@@ -37,6 +40,8 @@ mkdir -p "$SHARE" "$(dirname "$BIN")"
3740cp host/prompts.py host/validate.py host/emoji.txt "$SHARE/"
3841sed -e "1s|.*|#!$PYTHON|" -e "s|^ALLOWED_ORIGIN = \".*\"|ALLOWED_ORIGIN = \"chrome-extension://$ID/\"|" host/diagonal-host.py > "$SHARE/diagonal-host.py"
3942chmod 755 "$SHARE/diagonal-host.py"
43+# Files unzipped from a browser download carry the quarantine flag; the host must not.
44+xattr -dr com.apple.quarantine "$SHARE" 2>/dev/null || true
4045ln -sf "$SHARE/diagonal-host.py" "$BIN"
4146echo "host: $BIN -> $SHARE/diagonal-host.py"
4247