interplane.Get Omega
Read in your language

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

branch main Branches Tags History

mailhand / build.sh

56 lines · 2534 bytes Raw Blame History
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.
12set -eu
13cd "$(dirname "$0")"
14die() { echo "build.sh: $2" >&2; exit "$1"; }
15UNITS=${1:-src/UNITS}
16OUT=${2:-build/mailhand}
17OMC=${OMC:-./omc}
18[ -f PIN ] || die 2 "PIN is missing"
19set -- $(cat PIN)
20[ $# -eq 4 ] && [ "$1" = omega-mv ] && [ "$3" = omc-sha256 ] || die 2 "PIN must be two lines: omega-mv REV, omc-sha256 SHA"
21rev=$2 sha=$4
22case $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"
24got=$(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)"
26mkdir -p build "$(dirname "$OUT")"
27# the dependency generator
28{ printf "om2\n"; grep -v "^om2$" tools/deps.om; } > build/depsgen.om
29rc=0
30"$OMC" < build/depsgen.om > build/depsgen.new 2> build/depsgen.err || rc=$?
31if [ $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"
35fi
36chmod 755 build/depsgen.new
37mv build/depsgen.new build/depsgen
38build/depsgen src/UNITS tests/srv/UNITS "$UNITS" || die 1 "build/depsgen failed (DEPS)"
39unit="$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"
46rc=0
47"$OMC" < "$unit" > "$OUT.new" 2> "$OUT.err" || rc=$?
48if [ $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
53fi
54chmod 755 "$OUT.new"
55mv "$OUT.new" "$OUT"
56sha256sum "$OUT"