#!/bin/bash # prebuild — stage the kernel source tarball this PKGBUILD expects. # # linux-ampere-fourier's source is a snapshot of marfrit/linux-rk3588-marfrit # @ f8f3ad9 (260MB), too big to commit to marfrit-packages and currently # unpushable to Gitea (boltzmann's working clone is shallow; gitea push # refuses shallow updates). Hosting the tarball outside Gitea would need # infrastructure setup that's not in scope for the first iteration. # # So: produce the tarball locally from the kernel working tree just # before makepkg runs. Idempotent — if an existing tarball matches the # expected sha256 we skip the archive step. # # Run from this directory: cd arch/linux-ampere-fourier && ./prebuild.sh # Override the kernel-tree location: LINUX_RK3588_MARFRIT_TREE=/path ./prebuild.sh # # Default tree location matches the boltzmann/ampere convention from # kernel-agent issue #6: $HOME/src/linux-rockchip. set -euo pipefail TREE="${LINUX_RK3588_MARFRIT_TREE:-${HOME}/src/linux-rockchip}" COMMIT=48a8c785de7f5320513052a64e544c6310d7b273 # Generated tarball sha varies with gzip version — script warns-not-fails. # Leave EXPECTED empty for fresh kafr2 builds; first successful build can # pin a canonical sha here if a reproducibility audit needs it. SHA256_EXPECTED= HERE="$(cd "$(dirname "$0")" && pwd)" OUTPUT="${HERE}/linux-rk3588-marfrit-${COMMIT:0:7}.tar.gz" if [ -f "$OUTPUT" ]; then have=$(sha256sum "$OUTPUT" | cut -d' ' -f1) if [ "$have" = "$SHA256_EXPECTED" ]; then echo "prebuild: $OUTPUT already exists with correct sha256" exit 0 else echo "prebuild: existing $OUTPUT sha mismatch (have=$have, want=$SHA256_EXPECTED) — regenerating" >&2 rm -f "$OUTPUT" fi fi if [ ! -d "$TREE/.git" ]; then echo "prebuild: kernel tree not at $TREE" >&2 echo " set LINUX_RK3588_MARFRIT_TREE=/path/to/linux-rockchip and retry" >&2 exit 2 fi cd "$TREE" if ! git cat-file -e "$COMMIT" 2>/dev/null; then echo "prebuild: commit $COMMIT not found in $TREE" >&2 echo " fetch the linux-rk3588-marfrit branch first:" >&2 echo " git fetch linux-rk3588-marfrit" >&2 exit 3 fi echo "prebuild: generating archive from $TREE @ $COMMIT..." git archive --format=tar.gz --prefix=linux-rk3588-marfrit/ "$COMMIT" -o "$OUTPUT" # git archive emits a deterministic tar stream but gzip compression may # vary by version. The sha256 check is informational; warn-don't-fail. have=$(sha256sum "$OUTPUT" | cut -d' ' -f1) if [ "$have" != "$SHA256_EXPECTED" ]; then echo "prebuild: WARNING $OUTPUT sha=$have (canonical=$SHA256_EXPECTED)" >&2 echo " probably a gzip-version difference; tar payload should be identical" >&2 fi echo "prebuild: wrote $OUTPUT ($(du -h "$OUTPUT" | cut -f1), sha=$have)"