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 / scripts / omega_lock_check.sh
| 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 | # omega_lock_check.sh -- the vendored Omega sources (native/kernel/third_party/omega) |
| 18 | # are byte for byte the files of the omega commit named in omega.lock. |
| 19 | # |
| 20 | # omega.lock: line 1 is the full omega commit sha; every further line is |
| 21 | # sha256 <hex> <vendored path> <path in omega> |
| 22 | # Always: each vendored file's sha256 equals the recorded one (offline). |
| 23 | # When possible: the recorded sha256 equals the blob at that commit in omega |
| 24 | # (OMEGA_LOCK_REPO=<local omega checkout>, else a shallow fetch of the commit |
| 25 | # from GitHub; skipped with a NOTE when neither works, never a PASS for it). |
| 26 | # Exit 0 only when every check that ran passed. No Python. |
| 27 | set -u |
| 28 | cd "$(dirname "$0")/.." || exit 2 |
| 29 | lock=omega.lock |
| 30 | [ -r "$lock" ] || { echo "OMEGA_LOCK: FAIL $lock missing"; exit 1; } |
| 31 | sha=$(sed -n 1p "$lock") |
| 32 | case "$sha" in |
| 33 | [0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]*) ;; |
| 34 | *) echo "OMEGA_LOCK: FAIL line 1 is not a commit sha"; exit 1 ;; |
| 35 | esac |
| 36 | [ ${#sha} -eq 40 ] || { echo "OMEGA_LOCK: FAIL line 1 is not a full sha"; exit 1; } |
| 37 | fail=0 |
| 38 | n=0 |
| 39 | while read -r tag hex path opath; do |
| 40 | [ "$tag" = sha256 ] || continue |
| 41 | n=$((n + 1)) |
| 42 | if [ ! -r "$path" ]; then echo "FAIL $path missing"; fail=1; continue; fi |
| 43 | have=$(sha256sum "$path" | cut -d' ' -f1) |
| 44 | if [ "$have" = "$hex" ]; then echo "PASS $path sha256 matches omega.lock"; else echo "FAIL $path sha256 $have, omega.lock says $hex"; fail=1; fi |
| 45 | done < "$lock" |
| 46 | [ "$n" -gt 0 ] || { echo "OMEGA_LOCK: FAIL no sha256 lines"; exit 1; } |
| 47 | |
| 48 | # upstream check |
| 49 | repo="${OMEGA_LOCK_REPO:-}" |
| 50 | tmp="" |
| 51 | if [ -z "$repo" ] && command -v git >/dev/null 2>&1; then |
| 52 | tmp=$(mktemp -d) |
| 53 | if git -C "$tmp" init -q 2>/dev/null && git -C "$tmp" fetch -q --depth=1 https://github.com/aien-dev/omega.git "$sha" 2>/dev/null; then |
| 54 | repo="$tmp" |
| 55 | up=FETCH_HEAD |
| 56 | fi |
| 57 | fi |
| 58 | [ -n "${up:-}" ] || up="$sha" |
| 59 | if [ -n "$repo" ] && git -C "$repo" cat-file -e "$up^{commit}" 2>/dev/null; then |
| 60 | while read -r tag hex path opath; do |
| 61 | [ "$tag" = sha256 ] || continue |
| 62 | blob=$(git -C "$repo" show "$up:$opath" 2>/dev/null | sha256sum | cut -d' ' -f1) |
| 63 | if [ "$blob" = "$hex" ]; then echo "PASS omega $opath at ${sha:0:12} matches omega.lock"; else echo "FAIL omega $opath at ${sha:0:12} is $blob, omega.lock says $hex"; fail=1; fi |
| 64 | done < "$lock" |
| 65 | else |
| 66 | echo "NOTE upstream check not run (no OMEGA_LOCK_REPO and no fetch of $sha); offline sha256 check only" |
| 67 | fi |
| 68 | [ -n "$tmp" ] && rm -rf "$tmp" |
| 69 | if [ "$fail" = 0 ]; then echo "OMEGA_LOCK: PASS commit=$sha files=$n"; exit 0; fi |
| 70 | echo "OMEGA_LOCK: FAIL commit=$sha" |
| 71 | exit 1 |