@@ -1,11 +1,14 @@
1#!/usr/bin/env bash
1#!/usr/bin/env bash
2# Non-Nix installer for the native host (section 14).
2# Non-Nix installer for the native host (section 14).
3# scripts/install-manifest.sh [--beta] [--nightly] [--all-channels]
3# 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.
4# Copies host/ to ~/.local/share/diagonal-host, links ~/.local/bin/diagonal-host to it, writes the Brave
6# Copies host/ to ~/.local/share/diagonal-host, links ~/.local/bin/diagonal-host to it, writes the Brave
5# host manifest with that absolute path and the pinned extension ID, then installs the fm schemas
7# host manifest with that absolute path and the pinned extension ID, then installs the fm schemas
6# and runs the self-test. Safe to re-run.
8# and runs the self-test. Safe to re-run.
7set -euo pipefail
9set -euo pipefail
8−cd "$(dirname "$0")/.."
10+HERE="$(cd "$(dirname "$0")" && pwd)"
11+if [[ -d "$HERE/host" ]]; then cd "$HERE"; else cd "$HERE/.."; fi
10CHANNELS=("Brave-Browser")
13CHANNELS=("Brave-Browser")
11for arg in "$@"; do
14for arg in "$@"; do
@@ -24,12 +27,12 @@ if [[ -z "$ID" ]]; then
26PYTHON=$(command -v python3 || true)
29PYTHON=$(command -v python3 || true)
27−if [[ -z "$PYTHON" ]]; then
30+# Brave starts the host with a minimal PATH, so the shebang names this python3 explicitly.
28− echo "python3 not found on PATH" >&2
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
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)')
34SHARE="$HOME/.local/share/diagonal-host"
37SHARE="$HOME/.local/share/diagonal-host"
35BIN="$HOME/.local/bin/diagonal-host"
38BIN="$HOME/.local/bin/diagonal-host"
@@ -37,6 +40,8 @@ mkdir -p "$SHARE" "$(dirname "$BIN")"
37cp host/prompts.py host/validate.py host/emoji.txt "$SHARE/"
40cp host/prompts.py host/validate.py host/emoji.txt "$SHARE/"
38sed -e "1s|.*|#!$PYTHON|" -e "s|^ALLOWED_ORIGIN = \".*\"|ALLOWED_ORIGIN = \"chrome-extension://$ID/\"|" host/diagonal-host.py > "$SHARE/diagonal-host.py"
41sed -e "1s|.*|#!$PYTHON|" -e "s|^ALLOWED_ORIGIN = \".*\"|ALLOWED_ORIGIN = \"chrome-extension://$ID/\"|" host/diagonal-host.py > "$SHARE/diagonal-host.py"
39chmod 755 "$SHARE/diagonal-host.py"
42chmod 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
40ln -sf "$SHARE/diagonal-host.py" "$BIN"
45ln -sf "$SHARE/diagonal-host.py" "$BIN"
41echo "host: $BIN -> $SHARE/diagonal-host.py"
46echo "host: $BIN -> $SHARE/diagonal-host.py"