From 38d54f10ff0ac4e4e0322a9d8d540dd26b461c4f Mon Sep 17 00:00:00 2001 From: Luxferre Date: Sat, 7 Nov 2026 21:21:15 +0200 Subject: [PATCH] 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//modules-initfs as /usr/share/mkinitfs/modules/00-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. --- AGENTS.md | 2 +- CHANGELOG.md | 16 ++++++++++++++++ scripts/apply-bananarchy-overlay.sh | 24 ++++++++++++++++++++++++ scripts/check-rebuild.sh | 11 +++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index cd226cf..547411b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -27,7 +27,7 @@ It uses a pure **X11 (`Xlibre` + `sxmo-de-dwm`)** stack (no Wayland) with **Adre - `prebuilt/`: cross-compiled `armv7` binaries and kernel modules (`sxmo-x11`, `fcitx5-t9`, `xlibre`, `kernel-6.12.1-msm8916`, `bantam`, `games`, `gsocket`). - `devices/` & `patches/`: device trees (`.dts`/`.dtb`), MIPI-DBI panel init sequences, and upstream patch sets. - `vendor/edl/`: vendored, patched EDL client library (MIT) used by `flash-edl.py`; a local `edl/` checkout or `BANANARCHY_EDL_DIR` overrides it. -- `scripts/rootfs-packages.txt`: single source of truth for the `armv7` rootfs package set, read by both `bootstrap-rootfs.sh` and `rebuild-image.sh`. +- `scripts/rootfs-packages.txt`: single source of truth for the `armv7` rootfs package set, read by both `bootstrap-rootfs.sh` and `rebuild-image.sh`. It intentionally contains no `device-*` package; `scripts/apply-bananarchy-overlay.sh` installs the per-device `devices//modules-initfs` list as `/usr/share/mkinitfs/modules/00-device-.modules` (plus its `initramfs.load` mapping) so a clean-clone bootstrap still builds the correct initramfs. `scripts/check-rebuild.sh` guards this. - `scripts/rootfs-prune-packages.txt`: denylist of Wayland-only, Rust-based, and retired packages purged from existing rootfs trees by `bootstrap-rootfs-container.sh` and `rebuild-image.sh`. - `scripts/prune-rootfs-packages.sh`: two-phase rootfs pruner (`world` before `apk add`, `purge` after) that reads the denylist and pins `install_if` packages with negative `!pkg` world constraints plus `apk fix`; the `world` phase is required so apk can atomically replace Rust `sudo-rs` with C `sudo`. diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ace9a8..3957b32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,22 @@ Release versions follow the `
` format (where `2026` is `a`, --- +## Unreleased — reproducible device initramfs module lists + +- `scripts/apply-bananarchy-overlay.sh` now installs the tracked + `devices//modules-initfs` list into + `/usr/share/mkinitfs/modules/00-device-.modules` plus its + `initramfs.load` mapping, and removes stale lists from other devices. + Without the `device-*` package (not in `scripts/rootfs-packages.txt`), a + clean-clone bootstrap previously produced an initramfs missing 7 device + modules (panel, keypad and both PMIC drivers, including the new + `pm8916_bms_vm`). A clean clone rebuild now produces the same 27-module + initramfs as an existing rootfs, with the fixed BMS module byte-identical. +- `scripts/check-rebuild.sh` guards the per-device module lists and the + overlay installation step. + +--- + ## Unreleased — VM-BMS clamp and runtime power policies - **Kernel fix (patch 0007)**: `pm8916_bms_vm.c` now bounds VADC raw samples diff --git a/scripts/apply-bananarchy-overlay.sh b/scripts/apply-bananarchy-overlay.sh index 1a05665..a5e9fdc 100755 --- a/scripts/apply-bananarchy-overlay.sh +++ b/scripts/apply-bananarchy-overlay.sh @@ -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 diff --git a/scripts/check-rebuild.sh b/scripts/check-rebuild.sh index c345233..bb3d6f0 100755 --- a/scripts/check-rebuild.sh +++ b/scripts/check-rebuild.sh @@ -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"