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 / scripts / ck_pi5_repro_check.sh

85 lines · 4834 bytes Raw Blame History
1#!/usr/bin/env bash
2# SPDX-License-Identifier: Apache-2.0
3# Copyright 2026 Drake Stapleton (AIEN / aien-dev)
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# ck_pi5_repro_check.sh -- PI5-8 Q1, reproducible builds of every Raspberry Pi 5 image.
18#
19# scripts/ck_pi5_repro_check.sh [commit] (default: HEAD of this checkout)
20#
21# Makes two clean detached worktrees of the SAME commit at two DIFFERENT paths (so build-directory
22# paths that leak into an image show up as a difference), builds every Pi image in each with the same
23# toolchain, and compares the sha256 of each BOOTAA64.EFI and aienos-ck.elf byte for byte. Prints a
24# table and PASS/FAIL (exit 0 only when every BOOTAA64.EFI and every stripped ELF matches; a raw ELF may differ only in Rust symbol-name hash suffixes, see below). Records the toolchain versions used.
25# Env: REPRO_KEEP=1 keeps the worktrees; REPRO_TMP=<dir> sets where they go (default: mktemp -d).
26set -euo pipefail
27root="$(cd "$(dirname "$0")/.." && pwd)"
28commit="$(git -C "${root}" rev-parse "${1:-HEAD}")"
29tmp="${REPRO_TMP:-$(mktemp -d "${TMPDIR:-/tmp}/aienos-repro.XXXXXX")}"
30mkdir -p "${tmp}"
31cleanup() {
32 if [ "${REPRO_KEEP:-}" != 1 ]; then
33 for d in a/aienos-repro b/aienos-repro; do
34 git -C "${root}" worktree remove --force "${tmp}/${d}" 2>/dev/null || true
35 done
36 rm -rf "${tmp}"
37 fi
38}
39trap cleanup EXIT
40# target name -> output directory (relative to the worktree) that holds BOOTAA64.EFI and aienos-ck.elf
41images="pi5:target/native-kernel-pi5
42pi5-store:target/native-kernel-pi5-store/full-pi5-store
43pi5-unlock:target/native-kernel-pi5-unlock/full-pi5-unlock
44pi5-unlock-card:target/native-kernel-pi5-unlock-card/full-pi5-unlock-card
45pi5-fact:target/native-kernel-pi5-unlock-card-fact/full-pi5-unlock-card-fact
46pi5-infer:target/native-kernel-pi5-infer
47pi5-agent:target/native-kernel-pi5-unlock-card-agent/full-pi5-unlock-card-agent
48pi5-lifecycle:target/native-kernel-pi5-unlock-card-lifecycle/full-pi5-unlock-card-lifecycle
49pi5-artifact:target/native-kernel-pi5-artifact
50pi5-pcie:target/native-kernel-pi5-pcie
51pi5-net:target/native-kernel-pi5-net"
52
53echo "commit: ${commit}"
54echo "toolchain:"
55for c in "make --version" "cc --version" "ld --version" "objcopy --version" "rustc -Vv" "cargo -V"; do
56 out="$(${c} 2>&1)"; printf " %s: %s\n" "${c%% *}" "${out%%$'\n'*}"
57done
58git -C "${root}" worktree prune
59for d in a b; do
60 mkdir -p "${tmp}/${d}"
61 git -C "${root}" worktree add -q --detach "${tmp}/${d}/aienos-repro" "${commit}"
62done
63for d in a b; do
64 echo "== build set ${d} (${tmp}/${d}/aienos-repro)"
65 while IFS=: read -r tgt _; do
66 make -C "${tmp}/${d}/aienos-repro/native/kernel" "${tgt}" >"${tmp}/${d}.${tgt}.log" 2>&1 \
67 || { echo "FAIL build ${tgt} in set ${d}; see ${tmp}/${d}.${tgt}.log"; REPRO_KEEP=1; tail -20 "${tmp}/${d}.${tgt}.log"; exit 2; }
68 done <<<"${images}"
69done
70fail=0
71printf '%-16s %-10s %-64s %s\n' IMAGE FILE SHA256 RESULT
72while IFS=: read -r tgt dir; do
73 for f in BOOTAA64.EFI aienos-ck.elf; do
74 pa="${tmp}/a/aienos-repro/${dir}/${f}"; pb="${tmp}/b/aienos-repro/${dir}/${f}"
75 if [ ! -s "${pa}" ] || [ ! -s "${pb}" ]; then printf '%-16s %-10s %-64s %s\n' "${tgt}" "${f}" "-" "MISSING"; fail=1; continue; fi
76 ha="$(sha256sum "${pa}" | cut -d' ' -f1)"; hb="$(sha256sum "${pb}" | cut -d' ' -f1)"
77 if [ "${ha}" = "${hb}" ]; then printf '%-16s %-10s %-64s %s\n' "${tgt}" "${f}" "${ha}" "match"
78 elif [ "${f}" = aienos-ck.elf ] && strip -s -o "${tmp}/sa.elf" "${pa}" && strip -s -o "${tmp}/sb.elf" "${pb}" && cmp -s "${tmp}/sa.elf" "${tmp}/sb.elf"; then
79 # Rust crate-hash suffixes in symbol NAMES (cargo hashes the absolute path of a path dependency outside the crate's
80 # own workspace). Symbols are not in BOOTAA64.EFI; the stripped ELF (all code and data) is byte-identical.
81 printf '%-16s %-10s %-64s %s\n' "${tgt}" "${f}" "${ha}/${hb}" "match-stripped (symbol-name hash suffix only)"
82 else printf '%-16s %-10s %-64s %s\n' "${tgt}" "${f}" "${ha}/${hb}" "DIFFER"; fail=1; fi
83 done
84done <<<"${images}"
85if [ "${fail}" = 0 ]; then echo "PASS ck_pi5_repro_check: every Pi image built twice from ${commit} is byte-identical (EFI exact; Rust-linked ELFs exact once stripped)"; else echo "FAIL ck_pi5_repro_check"; exit 1; fi