From 886aff34bb570d9caba40253d76ad5b5511777ab Mon Sep 17 00:00:00 2001 From: Eric Naim Date: Fri, 24 Apr 2026 12:15:16 +0800 Subject: [PATCH 1/6] pacman-hook-kernel-install: Only run remove hook on vmlinuz remove. Such a broad target for the remove hook can cause missing boot entries when something other than the kernel is updated. Signed-off-by: Eric Naim --- .../40-kernel-install-remove.hook | 19 ------------------- pacman-hook-kernel-install/PKGBUILD | 2 +- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/pacman-hook-kernel-install/40-kernel-install-remove.hook b/pacman-hook-kernel-install/40-kernel-install-remove.hook index 4fb81d8..a11e3da 100644 --- a/pacman-hook-kernel-install/40-kernel-install-remove.hook +++ b/pacman-hook-kernel-install/40-kernel-install-remove.hook @@ -1,27 +1,8 @@ [Trigger] Type = Path -Operation = Upgrade Operation = Remove Target = usr/lib/modules/*/vmlinuz -[Trigger] -Type = Path -Operation = Install -Operation = Upgrade -Operation = Remove -Target = usr/lib/initcpio/* -Target = usr/lib/initcpio/*/* -Target = usr/lib/firmware/* -Target = usr/lib/modules/*/extramodules/* -Target = usr/src/*/dkms.conf -Target = usr/lib/booster/* -Target = usr/lib/dracut/* -Target = usr/lib/dracut/*/* -Target = usr/lib/dracut/*/*/* -Target = usr/lib/kernel/* -Target = usr/lib/kernel/*/* -Target = boot/*-ucode.img - [Action] Description = Removing kernel and initrd using kernel-install... When = PostTransaction diff --git a/pacman-hook-kernel-install/PKGBUILD b/pacman-hook-kernel-install/PKGBUILD index 81c82cc..2e81d78 100644 --- a/pacman-hook-kernel-install/PKGBUILD +++ b/pacman-hook-kernel-install/PKGBUILD @@ -4,7 +4,7 @@ pkgname=pacman-hook-kernel-install pkgver=0.16.0 -pkgrel=1 +pkgrel=2 pkgdesc="Pacman hooks for kernel-install." url='https://man.archlinux.org/man/kernel-install.8' arch=('any') From 7cf9abc65aed2128ce21d61c612958e6ee5cb5a8 Mon Sep 17 00:00:00 2001 From: Eric Naim Date: Fri, 24 Apr 2026 12:16:55 +0800 Subject: [PATCH 2/6] pacman-hook-kernel-install: Use kernel-install add-all when all_kernels kernel-install has a handy helper `add-all`. Use that instead of iterating each vmlinuz manually. Additionally, exit the while loop when all_kernels=1. Signed-off-by: Eric Naim --- pacman-hook-kernel-install/kernel-install.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pacman-hook-kernel-install/kernel-install.sh b/pacman-hook-kernel-install/kernel-install.sh index e1f3cf8..af4730b 100644 --- a/pacman-hook-kernel-install/kernel-install.sh +++ b/pacman-hook-kernel-install/kernel-install.sh @@ -22,16 +22,16 @@ while read -r path; do ;; *) all_kernels=1 + break; ;; esac done -((all_kernels)) && for file in usr/lib/modules/*/vmlinuz; do - pacman -Qqo "$file" 1>/dev/null 2>/dev/null && - add_file "$file" -done - -for kver in "${!versions[@]}"; do +if ((all_kernels)); then + kernel-install add-all +else + for kver in "${!versions[@]}"; do kimage="/usr/lib/modules/$kver/vmlinuz" kernel-install "$@" "$kver" "$kimage" || true -done + done +fi From 183d3e922eb77a683cf1f4da0af22cda98bf7356 Mon Sep 17 00:00:00 2001 From: Eric Naim Date: Fri, 24 Apr 2026 12:18:08 +0800 Subject: [PATCH 3/6] pacman-hook-kernel-install: Cleanup kernel-install-add target paths There are a lot of redundant targets that are already covered by another. Remove them. Signed-off-by: Eric Naim --- pacman-hook-kernel-install/90-kernel-install-add.hook | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pacman-hook-kernel-install/90-kernel-install-add.hook b/pacman-hook-kernel-install/90-kernel-install-add.hook index bc480da..e4e5cbb 100644 --- a/pacman-hook-kernel-install/90-kernel-install-add.hook +++ b/pacman-hook-kernel-install/90-kernel-install-add.hook @@ -10,16 +10,12 @@ Operation = Install Operation = Upgrade Operation = Remove Target = usr/lib/initcpio/* -Target = usr/lib/initcpio/*/* Target = usr/lib/firmware/* -Target = usr/lib/modules/*/extramodules/* +Target = usr/lib/modules/*/extramodules/ Target = usr/src/*/dkms.conf Target = usr/lib/booster/* Target = usr/lib/dracut/* -Target = usr/lib/dracut/*/* -Target = usr/lib/dracut/*/*/* Target = usr/lib/kernel/* -Target = usr/lib/kernel/*/* Target = boot/*-ucode.img [Action] From 7bb63e27fb7dfd36436177f6dd9f6501848ba01f Mon Sep 17 00:00:00 2001 From: Eric Naim Date: Fri, 24 Apr 2026 12:23:52 +0800 Subject: [PATCH 4/6] pacman-hook-kernel-install: Skip when vmlinuz doesn't exist. When updating the kernel, the previous version may get added to version=() because extramodules also triggers when removed. To avoid errors such as: Failed to open kernel image file '/usr/lib/modules/7.0.0-1-cachyos/vmlinuz': No such file or directory Check for existence of vmlinuz, and skip if it is not found. Signed-off-by: Eric Naim --- pacman-hook-kernel-install/kernel-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/pacman-hook-kernel-install/kernel-install.sh b/pacman-hook-kernel-install/kernel-install.sh index af4730b..91409a1 100644 --- a/pacman-hook-kernel-install/kernel-install.sh +++ b/pacman-hook-kernel-install/kernel-install.sh @@ -32,6 +32,7 @@ if ((all_kernels)); then else for kver in "${!versions[@]}"; do kimage="/usr/lib/modules/$kver/vmlinuz" + [[ ! -e "$kimage" ]] && continue kernel-install "$@" "$kver" "$kimage" || true done fi From 241de7271bfcc35af0412b26bb3b0e9fa0302034 Mon Sep 17 00:00:00 2001 From: Eric Naim Date: Thu, 30 Apr 2026 13:45:04 +0800 Subject: [PATCH 5/6] pacman-hook-kernel-install: Use PreTransaction for remove hook This makes sure that kernel-install remove gets to run before all the kernel files are removed. Signed-off-by: Eric Naim --- pacman-hook-kernel-install/40-kernel-install-remove.hook | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pacman-hook-kernel-install/40-kernel-install-remove.hook b/pacman-hook-kernel-install/40-kernel-install-remove.hook index a11e3da..f72407d 100644 --- a/pacman-hook-kernel-install/40-kernel-install-remove.hook +++ b/pacman-hook-kernel-install/40-kernel-install-remove.hook @@ -5,6 +5,6 @@ Target = usr/lib/modules/*/vmlinuz [Action] Description = Removing kernel and initrd using kernel-install... -When = PostTransaction +When = PreTransaction Exec = /usr/share/libalpm/scripts/kernel-install remove NeedsTargets From 3e0b3e04b1bf27528c88bda06357a3f7b4ff74c0 Mon Sep 17 00:00:00 2001 From: Eric Naim Date: Fri, 24 Apr 2026 12:28:42 +0800 Subject: [PATCH 6/6] pacman-hook-kernel-install: Update checksums Signed-off-by: Eric Naim --- pacman-hook-kernel-install/.SRCINFO | 8 ++++---- pacman-hook-kernel-install/PKGBUILD | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pacman-hook-kernel-install/.SRCINFO b/pacman-hook-kernel-install/.SRCINFO index 2fa7240..1a2f15b 100644 --- a/pacman-hook-kernel-install/.SRCINFO +++ b/pacman-hook-kernel-install/.SRCINFO @@ -1,7 +1,7 @@ pkgbase = pacman-hook-kernel-install pkgdesc = Pacman hooks for kernel-install. pkgver = 0.16.0 - pkgrel = 1 + pkgrel = 2 url = https://man.archlinux.org/man/kernel-install.8 arch = any license = GPL @@ -10,8 +10,8 @@ pkgbase = pacman-hook-kernel-install source = 90-kernel-install-add.hook source = 40-kernel-install-remove.hook source = kernel-install.sh - sha256sums = e4c08f21a599e299f16df5be6c47436be459786ad471ccd4f5cd55bda5e90f81 - sha256sums = 37c0ef6d0a38f526645234de6f35bcd6bab5496412c1a151cb3162f89cebdff8 - sha256sums = 0ace09a2fe4a4d49bb1767545740297cd03c803ce52bb48b2d72913b6013d49f + sha256sums = a6486c200c21c8b60b3340c0611cdbf16ca2deee6e39f219e20e6987ff983ad4 + sha256sums = a0751e7973b1e8e282192258c544202988ed3a505420d5850861524e89b33eb5 + sha256sums = 91a2ba19a3dcef3f99fd846d3b92c0fdf769eca4e10d1e2eb657e5696bfe6944 pkgname = pacman-hook-kernel-install diff --git a/pacman-hook-kernel-install/PKGBUILD b/pacman-hook-kernel-install/PKGBUILD index 2e81d78..594c545 100644 --- a/pacman-hook-kernel-install/PKGBUILD +++ b/pacman-hook-kernel-install/PKGBUILD @@ -23,6 +23,6 @@ package() { } # sums -sha256sums=('e4c08f21a599e299f16df5be6c47436be459786ad471ccd4f5cd55bda5e90f81' - '37c0ef6d0a38f526645234de6f35bcd6bab5496412c1a151cb3162f89cebdff8' - '0ace09a2fe4a4d49bb1767545740297cd03c803ce52bb48b2d72913b6013d49f') +sha256sums=('a6486c200c21c8b60b3340c0611cdbf16ca2deee6e39f219e20e6987ff983ad4' + 'a0751e7973b1e8e282192258c544202988ed3a505420d5850861524e89b33eb5' + '91a2ba19a3dcef3f99fd846d3b92c0fdf769eca4e10d1e2eb657e5696bfe6944')