install_new_lg4ff: regenerate the initramfs only when it carries the other copy
Some checks failed
dependency freshness / dependencies on newest stable (push) Has been cancelled
md-naming / markdown naming convention (push) Has been cancelled
Pre-commit checks / pre-commit (push) Has been cancelled
Python tests / test (push) Has been cancelled
Shell tests / shell-tests (push) Has been cancelled
Shell tests / arch-tests (push) Has been cancelled

The dkms pacman hook already rebuilds every preset on install and remove,
so the unconditional mkinitcpio -P cost 20 s twice per run on the host.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SS8M5wk88nJTXxDWz61KKk
This commit is contained in:
Krzysztof Rudnicki 2026-09-14 22:15:43 +02:00
parent 7e2d78c7db
commit b3f3f55863
2 changed files with 40 additions and 8 deletions

View File

@ -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"]
}

View File

@ -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
}