hyperkitty-chromium / bin /bootstrap.sh
SNAPKITTYWEST's picture
Add bin/bootstrap.sh
b39f5b0 verified
Raw
History Blame Contribute Delete
2.2 kB
#!/usr/bin/env bash
# HyperKitty Chromium :: reproducible bootstrap.
#
# Installs every dependency listed in <technology_constraints> via
# Homebrew (project-local: this script never touches anything
# outside what Brewfile lists, and never assumes a package is
# already present globally), then validates the environment and
# compiles the project. Safe to re-run.
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
log() { printf '\033[1;34m==>\033[0m %s\n' "$1"; }
fail() { printf '\033[1;31mERROR:\033[0m %s\n' "$1" >&2; exit 1; }
command -v brew >/dev/null 2>&1 || fail "Homebrew is required: https://brew.sh"
log "Installing dependencies from ./Brewfile (erlang, rebar3, chromium, git, node)"
brew bundle --file=Brewfile
log "Validating environment"
ERL_VERSION="$(erl -eval 'io:format("~s~n", [erlang:system_info(otp_release)]), halt().' -noshell 2>/dev/null || true)"
[ -n "$ERL_VERSION" ] || fail "erl not found on PATH after brew bundle"
log "Erlang/OTP release: $ERL_VERSION"
command -v rebar3 >/dev/null 2>&1 || fail "rebar3 not found on PATH after brew bundle"
log "rebar3: $(rebar3 version)"
CHROMIUM_BIN="$(command -v chromium || command -v chromium-browser || true)"
[ -n "$CHROMIUM_BIN" ] || fail "chromium executable not found on PATH after brew bundle"
log "Chromium: $CHROMIUM_BIN ($("$CHROMIUM_BIN" --version 2>/dev/null || echo unknown))"
log "Recording the resolved Chromium path in config/sys.config"
# In-place, idempotent: replaces only the chromium_executable value,
# leaving the rest of the (version-controlled) config file untouched.
if command -v perl >/dev/null 2>&1; then
perl -0pi -e "s#\{chromium_executable,\s*\"[^\"]*\"\}#{chromium_executable, \"$CHROMIUM_BIN\"}#" \
config/sys.config
else
log "perl not found -- please set {chromium_executable, \"$CHROMIUM_BIN\"} in config/sys.config manually"
fi
log "Fetching and compiling dependencies (pinned versions from rebar.config / rebar.lock)"
rebar3 get-deps
rebar3 compile
log "Running the test suite"
rebar3 eunit
log "Bootstrap complete."
log "Start an interactive shell with: rebar3 shell --config config/sys.config"
log "Build a release with: rebar3 as prod release"