#!/bin/sh # Build the riscv64 image the pipeline's jobs run in on narvi-1, and write it # as a root file system tarball for `flow rootfs import`. There is no Docker # on a RISC-V board, so this is Ubuntu Base 24.04.5 riscv64, checked against # its published SHA-256, with the build's packages installed by apt in a # chroot. Run it on a riscv64 Linux machine (narvi) as root or a user with # sudo, then # # FLOW_HOME=~/flow ~/flow/bin/flow rootfs import x16emu-riscv64.tar # # and pin the printed hash in .flow/pipeline.kdl. Rebuild, re-import and # re-pin when the packages below change. set -eu here=$(cd "$(dirname "$0")" && pwd) out=${1:-$here/x16emu-riscv64.tar} release=24.04.5 base=ubuntu-base-$release-base-riscv64.tar.gz sha256=651c516f291259ec913caa1efd0cfff738cd223adfc6617c884f07af487f08cf # What the Makefile needs, as README.md lists for riscv64 Linux: C11 and # C++17 compilers, make, SDL2 and zlib; and Python with pytest for the # conformance suite, once the syscall tier lets a job use loopback TCP. packages="build-essential make libsdl2-dev zlib1g-dev python3 python3-pytest" test "$(uname -m)" = riscv64 || { echo "build-riscv64.sh: run this on a riscv64 machine" >&2; exit 1; } work=$(mktemp -d) root=$work/root cleanup() { sudo umount "$root/proc" "$root/dev" 2>/dev/null || true sudo rm -rf "$work" } trap cleanup EXIT curl -fsSL -o "$work/$base" "https://cdimage.ubuntu.com/ubuntu-base/releases/$release/release/$base" echo "$sha256 $work/$base" | sha256sum -c - >/dev/null mkdir "$root" sudo tar -C "$root" -xzf "$work/$base" sudo mv "$root/etc/resolv.conf" "$work/resolv.conf.image" 2>/dev/null || true sudo cp /etc/resolv.conf "$root/etc/resolv.conf" sudo mount --bind /dev "$root/dev" sudo mount -t proc proc "$root/proc" sudo chroot "$root" sh -c " export DEBIAN_FRONTEND=noninteractive apt-get update -q >/dev/null apt-get install -y -q --no-install-recommends $packages >/dev/null apt-get clean rm -rf /var/lib/apt/lists/*" sudo umount "$root/proc" "$root/dev" # The R49 ROM, from the emulator's own R49 release, for the boot job: the # zip and the ROM in it both checked against their SHA-256. r49=https://github.com/X16Community/x16-emulator/releases/download/r49/x16emu_linux-x86_64-r49.zip curl -fsSL -o "$work/r49.zip" "$r49" echo "efb2d4ad36ae4244370004891aa67bdf85d2ec01b42b7f12f97b48b62aff009d $work/r49.zip" | sha256sum -c - >/dev/null python3 -c 'import sys, zipfile; open(sys.argv[2], "wb").write(zipfile.ZipFile(sys.argv[1]).read("rom.bin"))' "$work/r49.zip" "$work/rom.bin" echo "b81654cc8c87ed96e3ffc7c8e7c312c9f3b7b870c7bb34de61e61eac931b819a $work/rom.bin" | sha256sum -c - >/dev/null sudo install -D -m 0644 "$work/rom.bin" "$root/opt/x16rom/rom.bin" sudo rm "$root/etc/resolv.conf" sudo mv "$work/resolv.conf.image" "$root/etc/resolv.conf" 2>/dev/null || true sudo tar -C "$root" -cf "$out" . sudo chown "$(id -u):$(id -g)" "$out" echo "$out"