mailhand
mailhand: agents look after a person's email in seeded Omega. Maildir + MIME parsing, JSONL CLI and MCP, rule triage, policy-gated sending, hash-chained audit. Free (Apache-2.0).
Brought by drakestapleton
mailhand / build.sh
| 1 | #!/bin/sh |
| 2 | # Build mailhand with the pinned seeded Omega compiler (invocation glue only, as omega-mcp build.sh). |
| 3 | # ./build.sh [UNITS-FILE [OUTPUT]] default: src/UNITS -> build/mailhand |
| 4 | # OMC=/path/to/omc (default ./omc) |
| 5 | # PIN is the only file that names the compiler pin: "omega-mv REV" and "omc-sha256 SHA". The compiler |
| 6 | # is refused (exit 2) unless its sha256 is SHA. |
| 7 | # DEPS names the source dependencies (omtls) by one commit each: build/depsgen (tools/deps.om, built |
| 8 | # with the same compiler) fetches their files at that commit into build/deps/ and writes build/gen/LIST |
| 9 | # for src/UNITS, tests/srv/UNITS and UNITS-FILE, with each "@NAME" line replaced by the files of NAME. |
| 10 | # The unit is one "om2" line, then the files build/gen/UNITS-FILE lists, in order, with their own "om2" |
| 11 | # lines dropped and "export fn" read as "fn" (a program unit has a fn main), as omega-mcp does. |
| 12 | set -eu |
| 13 | cd "$(dirname "$0")" |
| 14 | die() { echo "build.sh: $2" >&2; exit "$1"; } |
| 15 | UNITS=${1:-src/UNITS} |
| 16 | OUT=${2:-build/mailhand} |
| 17 | OMC=${OMC:-./omc} |
| 18 | [ -f PIN ] || die 2 "PIN is missing" |
| 19 | set -- $(cat PIN) |
| 20 | [ $# -eq 4 ] && [ "$1" = omega-mv ] && [ "$3" = omc-sha256 ] || die 2 "PIN must be two lines: omega-mv REV, omc-sha256 SHA" |
| 21 | rev=$2 sha=$4 |
| 22 | case $rev$sha in *[!0-9a-f]*) die 2 "PIN: REV and SHA must be lowercase hex" ;; esac |
| 23 | [ ${#rev} -eq 40 ] && [ ${#sha} -eq 64 ] || die 2 "PIN: REV must have 40 hex digits and SHA 64" |
| 24 | got=$(sha256sum "$OMC" | cut -d" " -f1) |
| 25 | [ "$got" = "$sha" ] || die 2 "$OMC has sha256 $got, not the omc-sha256 of PIN (omega-mv $rev:seed/out/omc)" |
| 26 | mkdir -p build "$(dirname "$OUT")" |
| 27 | # the dependency generator |
| 28 | { printf "om2\n"; grep -v "^om2$" tools/deps.om; } > build/depsgen.om |
| 29 | rc=0 |
| 30 | "$OMC" < build/depsgen.om > build/depsgen.new 2> build/depsgen.err || rc=$? |
| 31 | if [ $rc -ne 0 ]; then |
| 32 | cat build/depsgen.err >&2 |
| 33 | rm -f build/depsgen.new |
| 34 | die 1 "omc refused tools/deps.om (exit $rc); line numbers refer to build/depsgen.om" |
| 35 | fi |
| 36 | chmod 755 build/depsgen.new |
| 37 | mv build/depsgen.new build/depsgen |
| 38 | build/depsgen src/UNITS tests/srv/UNITS "$UNITS" || die 1 "build/depsgen failed (DEPS)" |
| 39 | unit="$OUT.om" |
| 40 | { |
| 41 | printf "om2\n" |
| 42 | grep -v "^ *#" "build/gen/$UNITS" | grep -v "^ *$" | while read -r f; do |
| 43 | sed "s/^export fn /fn /" "$f" | grep -v "^om2$" |
| 44 | done |
| 45 | } > "$unit" |
| 46 | rc=0 |
| 47 | "$OMC" < "$unit" > "$OUT.new" 2> "$OUT.err" || rc=$? |
| 48 | if [ $rc -ne 0 ]; then |
| 49 | cat "$OUT.err" >&2 |
| 50 | echo "build.sh: omc refused the unit (exit $rc); line numbers refer to $unit" >&2 |
| 51 | rm -f "$OUT.new" |
| 52 | exit 1 |
| 53 | fi |
| 54 | chmod 755 "$OUT.new" |
| 55 | mv "$OUT.new" "$OUT" |
| 56 | sha256sum "$OUT" |