interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / tools / imac-image / build-efi.sh

67 lines · 2303 bytes Raw Blame History
1#!/bin/sh
2# Compose the firmware-hosted Allen sources in the order that compiles, add the `target x86efi`
3# selector, and build the EFI application the boot image carries.
4#
5# The twenty sources are not on main: they live on aienux `feat/allen-imac-competition`
6# (`d4ffde3c`). Build them from a checkout of that branch, or point ALLEN_SRC at one.
7#
8# OMEGA_COMPILER=<seed>/seed/out/omc sh build-efi.sh BOOTX64.EFI
9# OMEGA_COMPILER=<seed>/seed/out/omc sh build-efi.sh BOOTX64.EFI ff17a936...
10#
11# Second argument, if given, is the expected sha256; a difference exits 65 instead of passing.
12set -eu
13root=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
14allen=${ALLEN_SRC:-"$root/native/omega/allen"}
15compiler=${OMEGA_COMPILER:-}
16files="platform.om base.om vendor/sha256-core.om font-data.om font.om surface.om github.om
17http.om net.om tls-crypto.om vendor/cert-sha384.om vendor/cert-p256.om tls-p384.om
18vendor/cert-root.om tls-cert.om tls.om session.om repository-screen.om efi-main.om demo.om"
19
20[ -n "$compiler" ] && [ -x "$compiler" ] || {
21 echo 'OMEGA_COMPILER must name the seed compiler (seed/out/omc)' >&2
22 exit 69
23}
24
25missing=0
26for f in $files; do
27 if [ ! -f "$allen/$f" ]; then
28 echo "missing $allen/$f" >&2
29 missing=1
30 fi
31done
32[ "$missing" = 0 ] || {
33 echo 'the Allen sources are on aienux feat/allen-imac-competition (d4ffde3c), not on main' >&2
34 exit 66
35}
36
37out=${1:-BOOTX64.EFI}
38[ ! -e "$out" ] && [ ! -L "$out" ] || { echo 'fresh output required' >&2; exit 73; }
39unit="${out}.om"
40trap 'rm -f -- "$unit"' EXIT HUP INT TERM
41
42{
43 echo 'target x86efi'
44 for f in $files; do
45 cat "$allen/$f"
46 done
47} > "$unit"
48
49# Compile to a scratch file and publish by link: a refused compile leaves nothing at $out, so a
50# retry is not blocked by the fresh-output guard and no zero-byte EFI can be picked up by imac-image.
51tmp="${out}.build.$$"
52trap 'rm -f -- "$unit" "$tmp"' EXIT HUP INT TERM
53if ! "$compiler" < "$unit" > "$tmp" || [ ! -s "$tmp" ]; then
54 echo 'compile refused; nothing published' >&2
55 exit 64
56fi
57got=$(sha256sum "$tmp" | cut -d' ' -f1)
58
59want=${2:-}
60if [ -n "$want" ] && [ "$got" != "$want" ]; then
61 echo "expected $want; the sources or compiler differ" >&2
62 exit 65
63fi
64
65ln -T -- "$tmp" "$out"
66printf '%s %s\n' "$got" "$out"
67printf 'compiler %s\n' "$(sha256sum "$compiler" | cut -d' ' -f1)"