Ordering of pacman hooks

Hi there,

here is the contents of my /etc/pacman.d/hooks directory:

eos-hooks.hook
eos-reboot-required.hook
grub-fix-initrd-generation.hook
grub-update-after-kernel.hook
lsb-release.hook
os-release.hook
touch-vmlinuz.hook
zz-clear-paccache.hook
zz-clear-paccache-unused.hook

The zz.clear-paccache*.hook are the files by @keybreak taken fro here. The touch-vmlinuz.hook is my hook in order to let rEFInd get linux kernel as the last and default choice (see here). As far as I understand the hooks from /usr/share/libalpm/hooks are executed first, then the custom hooks from the directory mentioned above.

I was wondering if one has to be careful concerning a certain ordering scheme because there seems to be no direct dependeny between those hooks.

man alpm-hooks :

I’m not sure that having multiple interdependent hooks is a design consideration for libalpm, so if this is a factor then you might consider merging any dependent custom hooks, especially if the same subset will always trigger? For example, have a single hook that runs a script file?

1 Like

This is a good point here.

I do assume that the hooks in /usr/share/libalpm/hooks are more less independent from each other. I was just wondering if a hook executed before another one could interfere with the latter one in negative way.

1 Like

I’m no expert - but I saw somewhere that alpha order mattered, so I use the grub system (sort of) - I name them with 20-description and 30-description etc if I figure the order is meaningful. When I run a script from the hook - I tend to put it in a subdirectory of /etc/pacman.d/hooks called hooks.bin - so I can find them when they need changing!

(just another thing to keep track of!)

Edit: forgot to mention, having the scripts in /etc/pacman.d/hooks/hooks.bin makes it easier to move them to a different system as well.

1 Like

So I guess cleaning the paccache and touch'ing the kernel as some of the last actions should be no problem here.

1 Like

I can’t see how it would interact with anything, as long as it is specified to ran AFTER :grin:

1 Like

By the way, it is possible to use a service for some task that you have as hooks.

For example, for package cache management we have command

paccache-service-manager

that configures how package cache will be cleaned up periodically.

2 Likes