needrestart
needrestart copied to clipboard
Handle GRUB_DEFAULT
Hello,
every time I run apt upgrade, I get a message
The currently running kernel version is 5.8.0-3-amd64 which is not the expected kernel version 5.9.0-1-amd64.
I am aware of that, 5.9 does not work for me (yet), so I edited /etc/default/grub to set GRUB_DEFAULT to the older version. I also have the option autoinstall_all_kernels in dkms (not necessary, but a bit safer), so everything is working properly, it is just a bit annoying to have needrestart nagging me. I can disable kernel checks, or maybe use the filtering function on kernel filename, I just thought it might be nice if needrestart detected that I already went out of my way to ensure that I would use precisely the kernel I am running. Not sure if it is worth the trouble...
Since needrestart 3.5+ it is possible to filter the kernel image filename by a regex:
# Filter kernel image filenames by regex. This is required on Raspian having
# multiple kernel image variants installed in parallel.
$nrconf{kernelfilter} = qr(kernel7\.img);
Maybe this solves your issue if you change the pattern appropriate.
Thanks. As I mentioned in the report, I know I could filter, I just thought it would be nice if I didn't need to, if I could specify in just one place (GRUB_DEFAULT?) what the expected kernel is and not have to repeat that information for various tools like needrestart. But I understand that the existence of filtering gives this request a low priority (warning that GRUB_DEFAULT doesn't point to the latest kernel might even be considered a feature...).
Sorry I missed your point. Needrestart's config is pure perl so it should be possible to hack something. Maybe you could show the relevant line from your /etc/default/grub file.
I think this requirement is not generic enough to be added to needrestart.
Sorry I missed your point. Needrestart's config is pure perl so it should be possible to hack something. Maybe you could show the relevant line from your
/etc/default/grubfile.
The line looks like GRUB_DEFAULT="gnulinux-advanced-XXX>gnulinux-5.8.0-3-amd64-advanced-XXX" where XXX is a rather long random looking string of [0-9a-f-]. You are right indeed, since the config file for needrestart is just perl code, I could make it open /etc/default/grub, extract the value of GRUB_DEFAULT, then open /boot/grub/grub.cfg, find the name of the kernel image for this menu entry, and set $nrconf{kernelfilter} based on that. Hmm, I guess that's overkill for my current need, but I'll remember the idea, thanks.
I think this requirement is not generic enough to be added to needrestart.
Yeah, I guess so.