#!/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 and the conformance suite need, as README.md lists for # riscv64 Linux: C11 and C++17 compilers, make, SDL2 and zlib, Python and # pytest. 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" 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"