Files
alkane-os/ci/make-afw.sh
x 997771ab5e Wire the schema-driven dashboard and add the .afw firmware package
Dashboard (src/dashboard.rs): the on-box UI now renders from
schema/alkane-bb.json through flare-ui and wschema. The sidebar, the tab strip
and all 20 settings controls come from the schema; the host boundary does what
the crates require - validate the submitted batch with wschema before persisting,
ignore keys that are not in the schema, and never write on a rejected form.
Settings live in /etc/alkane/settings.json (temp dir when the root is read-only).

Web: GET /<section> and /<section>/<tab> render the dashboard, /assets/* serves
the crate's embedded token/component/theme stylesheets, POST /settings applies a
form. The existing JSON API routes are untouched.

Settings wired (all from real runtime knobs): tuning target mode and its four
values, frequency ceiling, the PID gains and limits in milli-units (the schema
has integer kinds only), fan zones/duty/sweep, detection ports and budget,
profile database path, board name.

Tests: 10 dashboard tests (schema loads, all settings present, page renders
inputs, valid submit persists and reloads, out-of-range rejected with nothing
written, unknown keys ignored, percent decoding) plus the existing 162. 172 pass.

Packaging (ci/make-afw.sh): .afw modelled on the Warden .wfw bundle - strict
POSIX ustar, manifest first, payload verified by size and sha256 - with three
deliberate differences: the payload is gzip-compressed, the manifest carries
 and x86_64, and both appear in the file name
(alkane-os-0.1.0-am335x-bb-armv7.afw) so a bundle cannot be mistaken for another
family. Signature is declared  in the manifest until a release key
exists; the sha256 is the only integrity claim today.
2026-11-04 14:06:25 -06:00

69 lines
2.4 KiB
Bash

#!/bin/sh
# Build an .afw firmware package for one control board and architecture.
#
# Modelled on the Warden `.wfw` bundle (scada/flare-edge/docs/firmware-format.md):
# one file, a strict POSIX ustar tar, a JSON manifest first, then the payload,
# with the payload's size and sha256 in the manifest so the device can verify
# before it touches flash.
#
# Differences from .wfw, both deliberate:
#
# * the payload is COMPRESSED (`payload.tar.gz`) because these images ship to
# boards over metered links, and a firmware bundle is mostly redundant;
# * the manifest carries `board` and `arch`, and both go in the file name, so a
# bundle can never be mistaken for another board family. Flashing the wrong
# family is how boards are lost.
#
# Signature: `.wfw` carries an Ed25519 detached signature. We have no release
# key yet, so `.afw` currently ships `members=2` and says so in the manifest
# (`signature: "unsigned"`). Do not claim integrity beyond the sha256 until a
# key exists.
#
# usage: make-afw.sh BOARD ARCH VERSION INPUT_DIR [OUTPUT_DIR]
# e.g. make-afw.sh am335x-bb armv7 0.1.0 /tmp/release
set -eu
BOARD=${1:?board family, e.g. am335x-bb}
ARCH=${2:?architecture, e.g. armv7 or aarch64}
VERSION=${3:?version, e.g. 0.1.0}
INPUT=${4:?directory holding the release files}
OUTPUT=${5:-dist}
mkdir -p "$OUTPUT"
WORK=$(mktemp -d)
trap 'rm -rf "$WORK"' EXIT
# The payload is a tar of the release tree, gzipped at maximum.
tar --format=ustar --owner=0 --group=0 --numeric-owner \
--create --file "$WORK/payload.tar" -C "$INPUT" .
gzip -9 -n -c "$WORK/payload.tar" > "$WORK/payload.tar.gz"
PAYLOAD_SIZE=$(wc -c < "$WORK/payload.tar.gz")
PAYLOAD_SHA=$(sha256sum "$WORK/payload.tar.gz" | cut -d' ' -f1)
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
cat > "$WORK/manifest.json" <<MANIFEST
{
"schema": 1,
"format": "afw",
"board": "$BOARD",
"arch": "$ARCH",
"version": "$VERSION",
"build_date": "$BUILD_DATE",
"compression": "gzip",
"signature": "unsigned",
"payload": {
"file": "payload.tar.gz",
"size": $PAYLOAD_SIZE,
"sha256": "$PAYLOAD_SHA"
}
}
MANIFEST
NAME="alkane-os-$VERSION-$BOARD-$ARCH.afw"
(cd "$WORK" && tar --format=ustar --owner=0 --group=0 --numeric-owner \
--create --file "$OUTPUT/$NAME" manifest.json payload.tar.gz)
printf '%s\n' "$OUTPUT/$NAME"
printf 'board %s\narch %s\npayload %s bytes\nsha256 %s\n' \
"$BOARD" "$ARCH" "$PAYLOAD_SIZE" "$PAYLOAD_SHA"