You are not logged in.

#1 2021-12-09 08:53:12

PBS
Member
Registered: 2015-06-28
Posts: 53

[SOLVED] How to get kernels being updated in PreTransaction hook

I'm trying to write PreTransaction and PostTransaction hooks which perform an action for each kernel being updated. Whenever the files

/boot/vmlinuz-$kernel
/boot/initramfs-$kernel.img

are updated, I would like to know from the script run by the hook what the values of $kernel are, e.g. linux, linux-lts.

sbupdate does this for PostTransaction hooks by installing a Path trigger on usr/lib/modules/*/vmlinuz. When triggered, the script looks for a pkgver file in the same directory as vmlinuz, and reads its contents to find $kernel. However, this doesn't work for PreTransaction hooks because the pkgver file has not been installed yet. I also can't easily parse it out of * above, which contains $(uname -r). So what is the most robust/preferred way to do this?

Last edited by PBS (2021-12-10 05:14:28)

Offline

#2 2021-12-10 05:12:59

PBS
Member
Registered: 2015-06-28
Posts: 53

Re: [SOLVED] How to get kernels being updated in PreTransaction hook

Ok, I'm going to settle for a compromise. I can install a Package trigger on linux*, then weed out the unwanted matches like linux-headers, linux-docs by checking whether the corresponding kernels exist in /boot. This doesn't give me the same as the other approach, because it misses kernels that are about to be newly installed, but fortunately I don't mind; I only care about updates. If anyone can see any potential disasters here please let me know.

Clearly, this will not be robust against users editing the mkinitcpio presets file to output kernels and initramfs to nonstandard locations, but I don't care since this is also not addressed by the widely-used sbupdate either.

The alternative, parsing $(uname -r) back to a package name, is too tricky for me to get to work. The path by which the information in the PKGBUILD becomes the $(uname -r) string is labyrinthine, so I can't figure out the rule, and it'll break on the slightest change to how these strings are generated.

Last edited by PBS (2021-12-10 05:15:51)

Offline

Board footer

Powered by FluxBB