aien-train
AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.
Brought by drakestapleton
aien-train / tests / omegallm / efi-image.sh
| 1 | #!/bin/sh |
| 2 | # Compose the ollm UEFI boot image (aien-train#52): a GPT disk with one FAT EFI system partition |
| 3 | # holding \EFI\BOOT\BOOTX64.EFI (the x86efi ollm) and the job files under \OLLM. |
| 4 | # Usage: sh tests/omegallm/efi-image.sh EFI IMG SRC:NAME... |
| 5 | # each SRC:NAME copies file SRC to \OLLM\NAME; one NAME must be JOB.TXT. |
| 6 | # Env: IMAC_IMAGE (required): the Omega-built imac-image tool, which writes imac-boot.img (96 MiB |
| 7 | # GPT + FAT, partition 1 at sector 2048) around ./BOOTX64.EFI in the current directory. A |
| 8 | # relative IMAC_IMAGE is taken from the directory this script is started in. |
| 9 | # mtools (mmd, mcopy) adds the \OLLM files and reads every member back (cmp) before IMG is |
| 10 | # published; IMG must not exist yet. Prints every member's sha256, then the image's. |
| 11 | # File dates come from SOURCE_DATE_EPOCH (default 1793491200 = 2026-11-01T00:00:00Z), so the same |
| 12 | # inputs give the same image bytes. |
| 13 | set -eu |
| 14 | export SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-1793491200}" |
| 15 | [ $# -ge 3 ] || { echo "usage: efi-image.sh EFI IMG SRC:NAME..." >&2; exit 2; } |
| 16 | EFI=$1 IMG=$2 |
| 17 | shift 2 |
| 18 | [ -n "${IMAC_IMAGE:-}" ] && [ -x "$IMAC_IMAGE" ] || { echo "IMAC_IMAGE must name the imac-image tool" >&2; exit 2; } |
| 19 | case $IMAC_IMAGE in /*) ;; *) IMAC_IMAGE=$PWD/$IMAC_IMAGE ;; esac |
| 20 | [ ! -e "$IMG" ] || { echo "fresh output required: $IMG exists" >&2; exit 73; } |
| 21 | [ -f "$EFI" ] || { echo "missing $EFI" >&2; exit 66; } |
| 22 | job=0 |
| 23 | for m in "$@"; do |
| 24 | src=${m%:*} name=${m##*:} |
| 25 | [ "$src" != "$m" ] && [ -n "$name" ] || { echo "member must be SRC:NAME: $m" >&2; exit 2; } |
| 26 | [ -f "$src" ] || { echo "missing $src" >&2; exit 66; } |
| 27 | [ "$name" != JOB.TXT ] || job=1 |
| 28 | done |
| 29 | [ "$job" = 1 ] || { echo "no member named JOB.TXT" >&2; exit 2; } |
| 30 | tmp=$(mktemp -d) |
| 31 | trap 'rm -rf "$tmp"' EXIT HUP INT TERM |
| 32 | cp "$EFI" "$tmp/BOOTX64.EFI" |
| 33 | (cd "$tmp" && "$IMAC_IMAGE" > imac-image.log 2>&1) || { cat "$tmp/imac-image.log" >&2; exit 1; } |
| 34 | d="$tmp/imac-boot.img@@1M" |
| 35 | mmd -i "$d" ::/OLLM |
| 36 | check() { |
| 37 | mcopy -n -i "$d" "::/$1" "$tmp/back" |
| 38 | cmp "$tmp/back" "$2" || { echo "readback differs: $1" >&2; exit 1; } |
| 39 | rm -f "$tmp/back" |
| 40 | echo "$(sha256sum "$2" | cut -d' ' -f1) ::/$1" |
| 41 | } |
| 42 | check EFI/BOOT/BOOTX64.EFI "$EFI" |
| 43 | for m in "$@"; do |
| 44 | mcopy -i "$d" "${m%:*}" "::/OLLM/${m##*:}" |
| 45 | check "OLLM/${m##*:}" "${m%:*}" |
| 46 | done |
| 47 | mv "$tmp/imac-boot.img" "$IMG" |
| 48 | echo "$(sha256sum "$IMG" | cut -d' ' -f1) $(basename "$IMG")" |