populate-upstream.sh (1703B)
1 #!/bin/sh 2 # Copy the files bootstrap.sh needs from live-bootstrap's stage0-posix into 3 # build/upstream/, mirroring the upstream directory layout. Runs on the host: 4 # the podman invocations in the Makefile only mount curdir, so anything 5 # bootstrap.sh needs has to land inside curdir first. 6 # 7 # Inputs per arch (A in AArch64|AMD64|riscv64): 8 # bootstrap-seeds/POSIX/$A/hex0-seed 9 # $A/hex0_$A.hex0 10 # $A/hex1_$A.hex0 11 # $A/hex2_$A.hex1 12 # $A/catm_$A.hex2 vendored in src/ for AArch64, mirrored from upstream elsewhere 13 # $A/M0_$A.hex2 14 # $A/ELF-<arch>.hex2 used by both bootstrap.sh (M0.hex2 link) and 15 # the Makefile's final program link 16 # 17 # Usage: populate-upstream.sh [UPSTREAM] 18 # UPSTREAM: path to live-bootstrap checkout (default: ../live-bootstrap) 19 set -eu 20 21 UPSTREAM=${1:-../live-bootstrap} 22 S="$UPSTREAM/seed/stage0-posix" 23 OUT=build/upstream 24 25 if [ ! -d "$S" ]; then 26 echo "populate-upstream.sh: expected '$S' to exist" >&2 27 exit 1 28 fi 29 30 for A in AArch64 AMD64 riscv64; do 31 case "$A" in 32 AArch64) arch=aarch64 ;; 33 AMD64) arch=amd64 ;; 34 riscv64) arch=riscv64 ;; 35 esac 36 37 mkdir -p "$OUT/bootstrap-seeds/POSIX/$A" "$OUT/$A" 38 39 cp "$S/bootstrap-seeds/POSIX/$A/hex0-seed" "$OUT/bootstrap-seeds/POSIX/$A/" 40 cp "$S/$A/hex0_$A.hex0" "$OUT/$A/" 41 cp "$S/$A/hex1_$A.hex0" "$OUT/$A/" 42 cp "$S/$A/hex2_$A.hex1" "$OUT/$A/" 43 if [ "$A" = AArch64 ]; then 44 cp src/catm_AArch64.hex2 "$OUT/$A/" 45 else 46 cp "$S/$A/catm_$A.hex2" "$OUT/$A/" 47 fi 48 cp "$S/$A/M0_$A.hex2" "$OUT/$A/" 49 cp "$S/$A/ELF-$arch.hex2" "$OUT/$A/" 50 done 51 52 echo "populate-upstream: copied into $OUT from $UPSTREAM"