boot2.sh (3600B)
1 #!/bin/sh 2 ## boot2.sh — rebuild catm via M1pp+hex2pp, then build scheme1. 3 ## 4 ## Stage 2 of the README's chain. First rebuilds catm from catm.P1pp via 5 ## the freshly-built M1pp+hex2pp pipeline (replacing the seed boot0 catm 6 ## so later stages have zero boot0 dependencies); then builds the 7 ## scheme1 interpreter from scheme1.P1pp using the new catm. 8 ## 9 ## ─── Inputs (sources, from canonical tree) ─────────────────────────── 10 ## build/$ARCH/src/src/catm/catm.P1pp 11 ## build/$ARCH/src/src/scheme1/scheme1.P1pp 12 ## build/$ARCH/src/src/P1/{P1-$ARCH.M1pp, P1.M1pp, P1pp.P1pp} 13 ## build/$ARCH/src/src/stage0-posix/ELF.hex2 14 ## 15 ## ─── Inputs (binaries from prior stages) ────────────────────────────── 16 ## build/$ARCH/$DRIVER/boot0/catm (only to bootstrap catm.P1pp build) 17 ## build/$ARCH/$DRIVER/boot1/{M1pp, hex2pp} 18 ## 19 ## ─── Outputs ────────────────────────────────────────────────────────── 20 ## build/$ARCH/$DRIVER/boot2/{catm, scheme1} 21 ## 22 ## Usage: boot/boot2.sh <arch> 23 ## <arch> ∈ {aarch64, amd64, riscv64} for either DRIVER (default podman). 24 25 set -eu 26 27 . boot/lib-arch.sh 28 bootlib_init boot2 "${1:-}" 29 driver_init busybox 30 require_src 31 32 BOOT0=build/$ARCH/$DRIVER/boot0 33 BOOT1=build/$ARCH/$DRIVER/boot1 34 require_prev "$BOOT0" catm 35 require_prev "$BOOT1" M1pp hex2pp 36 37 . boot/lib-pipeline.sh 38 pipeline_init "$STAGE" "$OUT" "$DRIVER" 39 40 # ─── inputs ─────────────────────────────────────────────────────────── 41 pipeline_input catm0 "$BOOT0/catm" # bootstrap; replaced by output 'catm' 42 pipeline_input M1pp "$BOOT1/M1pp" 43 pipeline_input hex2pp "$BOOT1/hex2pp" 44 pipeline_input_from_src "P1/P1-$ARCH.M1pp" backend.M1pp 45 pipeline_input_from_src P1/P1.M1pp frontend.M1pp 46 pipeline_input_from_src P1/P1pp.P1pp libp1pp.P1pp 47 pipeline_input_from_src stage0-posix/ELF.hex2 48 pipeline_input_from_src catm/catm.P1pp 49 pipeline_input_from_src scheme1/scheme1.P1pp 50 51 # ─── pipeline ───────────────────────────────────────────────────────── 52 # .P1pp -> ELF, applied to each of catm.P1pp and scheme1.P1pp: 53 # catm backend + frontend + libp1pp + <src> -> combined.M1pp 54 # M1pp combined.M1pp -> expanded.hex2pp 55 # catm ELF.hex2 + expanded.hex2pp -> linked.hex2pp 56 # hex2pp -B 0x600000 linked.hex2pp -> ELF binary 57 build_p1pp() { # $1 = catm-bin name (catm0 or catm), $2 = src .P1pp, $3 = out 58 _catm=$1; _src=$2; _out=$3 59 stage "$_catm" combined.M1pp backend.M1pp frontend.M1pp libp1pp.P1pp "$_src" \ 60 -- backend.M1pp frontend.M1pp libp1pp.P1pp "$_src" -- combined.M1pp 61 stage M1pp combined.M1pp expanded.hex2pp -- combined.M1pp -- expanded.hex2pp 62 stage "$_catm" linked.hex2pp ELF.hex2 expanded.hex2pp -- ELF.hex2 expanded.hex2pp -- linked.hex2pp 63 stage hex2pp -B 0x600000 linked.hex2pp "$_out" -- linked.hex2pp -- "$_out" 64 } 65 66 echo "[$BOOT_TAG] catm.P1pp -> catm; scheme1.P1pp -> scheme1" 67 build_p1pp catm0 catm.P1pp catm # bootstrap with boot0 catm 68 build_p1pp catm scheme1.P1pp scheme1 # uses just-built catm 69 70 pipeline_export catm scheme1 71 pipeline_run 72 73 echo "[$BOOT_TAG] OK -> $OUT/{catm, scheme1}"