Make device initramfs module lists reproducible from a clean clone

A clean clone of the repo bootstraps a rootfs without any device-* package
(none is in scripts/rootfs-packages.txt). mkinitfs therefore omitted the
per-device module list and produced an initramfs missing 7 modules:
panel-mipi-dbi, drm_mipi_dbi, drm_dma_helper, matrix_keypad,
matrix-keymap, pm8916_lbc and the new pm8916_bms_vm. The shipped image was
only correct because an existing rootfs happened to have device-nokia-argon
installed.

- scripts/apply-bananarchy-overlay.sh now installs the tracked
  devices/<device>/modules-initfs as
  /usr/share/mkinitfs/modules/00-device-<device>.modules plus its
  initramfs.load mapping, and removes stale lists from other devices.
  Verified for all five targets (argon/beatles/tough keep 5 modules,
  sparkler/leo keep 3).
- scripts/check-rebuild.sh guards the per-device lists and the overlay step.
- AGENTS.md / CHANGELOG.md document the package-list decision.

Verification from a fresh clone of origin/master at bc1c19a:
- scripts/check-rebuild.sh passes.
- scripts/build-kernel-audio.sh downloads the gitignored kernel tarball,
  applies all 7 patches (including 0007) and reproduces all 72 committed
  kernel artifacts byte-for-byte; the only zImage difference is the embedded
  build timestamp (42 bytes, verified by decompressing both vmlinux images).
- rebuild-image.sh nokia-argon --mkinitfs now produces an initramfs with the
  identical 27-module set, the fixed pm8916_bms_vm.ko.zst SHA-256 match and
  initramfs.load present.
- Main image rebuilt and verified: kernel + DTB byte-identical, 27 modules,
  BMS SHA-256 match.
This commit is contained in:
Luxferre committed 2026-11-07 21:21:15 +02:00
1 parent bc1c19a483
commit 38d54f10ff
4 files changed
+52 -1

No files matched your search

+24
View File
@@ -317,6 +317,30 @@ if [ -f "$BASE_DIR/devices/$DEVICE_DIR/$DEVICEINFO_FILE" ]; then
"$TARGET_ROOTFS/usr/share/deviceinfo/device-$DEVICE"
ln -sf "device-$DEVICE" "$TARGET_ROOTFS/usr/share/deviceinfo/deviceinfo"
fi
# A freshly bootstrapped rootfs has no device-* package, so mkinitfs would
# otherwise omit the panel, keypad and PMIC drivers from the initramfs.
# Install the tracked per-device module list (and its initramfs.load mapping)
# so a clean clone rebuilds the same boot image as an existing rootfs.
MODULES_INITFS="$BASE_DIR/devices/$DEVICE_DIR/modules-initfs"
if [ -f "$MODULES_INITFS" ]; then
mkdir -p "$TARGET_ROOTFS/usr/share/mkinitfs/modules" \
"$TARGET_ROOTFS/usr/share/mkinitfs/files"
# Drop stale lists left by another device build or a device-* apk, so
# mkinitfs only sees the current device's module set.
for f in "$TARGET_ROOTFS"/usr/share/mkinitfs/modules/00-device-*.modules \
"$TARGET_ROOTFS"/usr/share/mkinitfs/files/00-device-*-modules.files; do
[ -f "$f" ] || continue
case "${f##*/}" in
"00-device-$DEVICE.modules"|"00-device-$DEVICE-modules.files") ;;
*) rm -f "$f" ;;
esac
done
MODULES_DEST="/usr/share/mkinitfs/modules/00-device-$DEVICE.modules"
cp -a "$MODULES_INITFS" "$TARGET_ROOTFS$MODULES_DEST"
printf '%s:%s\n' "$MODULES_DEST" /usr/lib/modules/initramfs.load \
> "$TARGET_ROOTFS/usr/share/mkinitfs/files/00-device-$DEVICE-modules.files"
fi
if [ -f "$TARGET_ROOTFS/boot/extlinux/extlinux.conf" ]; then
sed -i "s|^[[:space:]]*fdt .*|\tfdt /$DTB_FILE|" "$TARGET_ROOTFS/boot/extlinux/extlinux.conf"
fi
+11
View File
@@ -168,6 +168,17 @@ elif ! grep -qxF '.bantam.cfg' "$BASE_DIR/.gitignore"; then
fail ".bantam.cfg ignore rule is missing"
fi
echo "[check] Device initramfs module lists..."
for dev in nokia-argon nokia-beatles nokia-tough nokia-sparkler; do
if [ ! -f "$BASE_DIR/devices/$dev/modules-initfs" ]; then
fail "missing devices/$dev/modules-initfs"
fi
done
if ! grep -q 'MODULES_INITFS' "$BASE_DIR/scripts/apply-bananarchy-overlay.sh" || \
! grep -q 'initramfs.load' "$BASE_DIR/scripts/apply-bananarchy-overlay.sh"; then
fail "apply-bananarchy-overlay.sh no longer installs the device initramfs module list"
fi
echo "[check] Docker availability..."
if ! command -v docker >/dev/null 2>&1; then
fail "docker is not installed"