diff --git a/docs/superpowers/evidence/new-lg4ff-conditional-regen-2026-09-14.json b/docs/superpowers/evidence/new-lg4ff-conditional-regen-2026-09-14.json new file mode 100644 index 00000000..b42bdc44 --- /dev/null +++ b/docs/superpowers/evidence/new-lg4ff-conditional-regen-2026-09-14.json @@ -0,0 +1,28 @@ +{ + "intent": "Stop install_new_lg4ff.sh from regenerating the initramfs when the dkms pacman hook has already done it.", + "scope": ["linux_configuration/fixes/install_new_lg4ff.sh regen_initramfs()"], + "changes": [ + "Regenerate only when an image carries hid-logitech from the location modprobe no longer resolves to; images without the module, or already matching, are left alone" + ], + "verification": [ + { + "command": "linux_configuration/fixes/install_new_lg4ff.sh --status", + "result": "pass", + "evidence": "rc=0 on the host with new-lg4ff installed (module file updates/dkms/hid-logitech.ko.zst, loaded hid-logitech-new)" + }, + { + "command": "lsinitcpio -l /boot/initramfs-linux.img | grep hid-logitech", + "result": "pass", + "evidence": "empty after the host install: the hook-regenerated image no longer bundles the module, so the conditional path reports 'already matches' instead of a 20 s rebuild" + }, + { + "command": "shellcheck linux_configuration/fixes/install_new_lg4ff.sh", + "result": "pass", + "evidence": "clean" + } + ], + "risks": [ + "A hand-built initramfs that bundles the in-tree copy is still caught: it lists kernel/drivers/hid/ while modprobe resolves updates/dkms/" + ], + "rollback": ["git revert; the unconditional regen returns"] +} diff --git a/linux_configuration/fixes/install_new_lg4ff.sh b/linux_configuration/fixes/install_new_lg4ff.sh index 8452c141..246ff470 100755 --- a/linux_configuration/fixes/install_new_lg4ff.sh +++ b/linux_configuration/fixes/install_new_lg4ff.sh @@ -82,19 +82,23 @@ reload_module() { } regen_initramfs() { - # Only the images that actually carry the module need rebuilding. - local img rebuilt=0 + # Rebuild only when an image carries hid-logitech from the OTHER location + # than modprobe now resolves. The dkms pacman hook already regenerates on + # install and remove, so this is a safety net, not the normal path. + local want="kernel/drivers/hid/hid-logitech" + [[ "$(module_path)" == */updates/dkms/* ]] && want="updates/dkms/hid-logitech" + local img stale=0 listing for img in /boot/initramfs-*.img; do [[ -f $img ]] || continue - if lsinitcpio -l "$img" 2>/dev/null | grep -q 'hid-logitech'; then - rebuilt=1 - fi + listing="$(lsinitcpio -l "$img" 2>/dev/null | grep 'hid-logitech' || true)" + [[ -z $listing ]] && continue + grep -q "$want" <<<"$listing" || stale=1 done - if ((rebuilt)); then - log "initramfs bundles hid-logitech: regenerating all presets" + if ((stale)); then + log "initramfs bundles the other hid-logitech: regenerating all presets" sudo mkinitcpio -P else - log "initramfs does not bundle hid-logitech: nothing to regenerate" + log "initramfs already matches $(module_path)" fi }