aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / tools / imac-image / build-efi.sh
| 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. |
| 12 | set -eu |
| 13 | root=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) |
| 14 | allen=${ALLEN_SRC:-"$root/native/omega/allen"} |
| 15 | compiler=${OMEGA_COMPILER:-} |
| 16 | files="platform.om base.om vendor/sha256-core.om font-data.om font.om surface.om github.om |
| 17 | http.om net.om tls-crypto.om vendor/cert-sha384.om vendor/cert-p256.om tls-p384.om |
| 18 | vendor/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 | |
| 25 | missing=0 |
| 26 | for f in $files; do |
| 27 | if [ ! -f "$allen/$f" ]; then |
| 28 | echo "missing $allen/$f" >&2 |
| 29 | missing=1 |
| 30 | fi |
| 31 | done |
| 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 | |
| 37 | out=${1:-BOOTX64.EFI} |
| 38 | [ ! -e "$out" ] && [ ! -L "$out" ] || { echo 'fresh output required' >&2; exit 73; } |
| 39 | unit="${out}.om" |
| 40 | trap '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. |
| 51 | tmp="${out}.build.$$" |
| 52 | trap 'rm -f -- "$unit" "$tmp"' EXIT HUP INT TERM |
| 53 | if ! "$compiler" < "$unit" > "$tmp" || [ ! -s "$tmp" ]; then |
| 54 | echo 'compile refused; nothing published' >&2 |
| 55 | exit 64 |
| 56 | fi |
| 57 | got=$(sha256sum "$tmp" | cut -d' ' -f1) |
| 58 | |
| 59 | want=${2:-} |
| 60 | if [ -n "$want" ] && [ "$got" != "$want" ]; then |
| 61 | echo "expected $want; the sources or compiler differ" >&2 |
| 62 | exit 65 |
| 63 | fi |
| 64 | |
| 65 | ln -T -- "$tmp" "$out" |
| 66 | printf '%s %s\n' "$got" "$out" |
| 67 | printf 'compiler %s\n' "$(sha256sum "$compiler" | cut -d' ' -f1)" |