File size: 2,203 Bytes
b39f5b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/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"