Skip to content

pacman-hook-kernel-install: Script and hook fixes#5

Open
1Naim wants to merge 6 commits into
eNV25:masterfrom
1Naim:fix/kernel-install
Open

pacman-hook-kernel-install: Script and hook fixes#5
1Naim wants to merge 6 commits into
eNV25:masterfrom
1Naim:fix/kernel-install

Conversation

@1Naim
Copy link
Copy Markdown

@1Naim 1Naim commented Apr 30, 2026

I've been using this for a while and noticed some weird behaviours, so I went ahead and tried to make it inline with how other similar hooks are behaving. I've been running these for a while now, so they should be stable.

P.S. I only updated the pkgrel here, but with how the fixes are looking, maybe a version bump is better.

1Naim added 6 commits April 24, 2026 12:28
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 <dnaim@cachyos.org>
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 <dnaim@cachyos.org>
There are a lot of redundant targets that are already covered by
another. Remove them.

Signed-off-by: Eric Naim <dnaim@cachyos.org>
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 <dnaim@cachyos.org>
This makes sure that kernel-install remove gets to run before all the
kernel files are removed.

Signed-off-by: Eric Naim <dnaim@cachyos.org>
Signed-off-by: Eric Naim <dnaim@cachyos.org>
@eNV25
Copy link
Copy Markdown
Owner

eNV25 commented Apr 30, 2026

Doesn't not running remove on upgrades leave old versions lying around?

Running everything PostTransaction reduces the chance of an unbootable system due to a failed upgrade.

The current logic only works with pacman-owned files. Running kernel-install's own install all command means installing every kernel, not just the ones owned by pacman.

Also, isn't remove always followed by add during upgrades? Did you really run into a situation where this didn't happen?

@1Naim
Copy link
Copy Markdown
Author

1Naim commented May 1, 2026

Doesn't not running remove on upgrades leave old versions lying around?

It doesn't. I don't have any orphaned files lying around both in /boot and /lib/modules. My guess here is that Upgrade implies Remove, but I'll have to double check that for confirmation.

Running everything PostTransaction reduces the chance of an unbootable system due to a failed upgrade.

Right, I made it a PreTransaction because of the continue line I made where it would skip kernel-install if vmlinuz isn't found. I guess I can check for the command too and keep it as PostTransaction. Do you prefer this?

The current logic only works with pacman-owned files. Running kernel-install's own install all command means installing every kernel, not just the ones owned by pacman

OK, I'll revert that change. I don't use any non-pacman owned kernels so I didn't consider that.

Also, isn't remove always followed by add during upgrades? Did you really run into a situation where this didn't happen?

Can you elaborate more? I did run into a situation where something updated and I was left with no boot entries because add didn't run. I've since forgotten though, but the changes here fixed it for me.

@eNV25
Copy link
Copy Markdown
Owner

eNV25 commented May 2, 2026

Running PreTransaction and PostTransaction is probably fine, as that is what mkinitcpio does. In fact it is probably better to make this as similar as possible to mkinitcpio. At the same time there are differences, because kernel-install has versioned output paths, but mkinitcpio has the same output path for all versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants