I already saw the request in the second link (from where the idea to publish my code), but not the other. I will see it.
But I want to handle just some most common configuration, just becouse /sbin/lilo is no more sufficient itself, but I don't want to substitute an mkinitrd generator as do ubuntu and centos.
Also I dislike as slackware manage the doinst.sh of the kernel-generic and kernel-huge packages. Unless you run only slackpkg upgrade kernel-generic instead slackpkg upgrade-all, your /boot/vmlinuz will be a link to the huge kernel. First slackpkg upgrade kernel-generic:
/var/log/scripts/kernel-generic-4.14.37-x86_64-1
( cd boot ; rm -rf vmlinuz )
( cd boot ; ln -sf vmlinuz-generic-4.14.37 vmlinuz )
then slackpkg upgrade kernel-huge
/var/log/scripts/kernel-huge-4.14.37-x86_64-1
( cd boot ; rm -rf vmlinuz )
( cd boot ; ln -sf vmlinuz-huge-4.14.37 vmlinuz )
as result vmlinuz always will be a link to huge kernel at time of run lookkernel().
If we want consider all aspects, then we have to look&parse lilo.conf and elilo.conf; If someone copied from /boot/README.initrd his lilo.conf will be
image = /boot/vmlinuz-generic-4.14.34
initrd = /boot/initrd.gz
that always fails after a kernel upgrade (Pat should change that example in image = /boot/vmlinuz-generic, that is a link to the latest installed generic vmlinuz).
But /sbin/lilo -t should be sufficient to understand if a configuration is supported.
I will do some comment to linked code, then we can discute and merge it.
Code:
if $(readlink /boot/vmlinuz | grep -q generic); then
echo -e "\n
Your kernel image was updated to a generic kernel. You need a new initrd."
1) after slackpkg upgrade-all (the most used) /boot/vmlinuz always point to /boot/vmlinuz-huge-4.14.37
2) my pc need initrd even if I'm using the kernel-huge
3) slackpkg must assume that you already have configured bootloader, so do you know that you need the vmlinuz; slackpkg just have to rebuild it
Code:
MKINITRD_CMD=$(sed 's/-k *[^ ]\+/-k '$NEWKERNELVERSION'/' /boot/initrd-tree/command_line)
if [ grep -q -- -F /boot/initrd-tree/command_line ] \
&& [ ! grep -q -- -k /boot/initrd-tree/command_line ]; then
MKINITRD_CMD=$(sed 's/-F/-F -k '$NEWKERNELVERSION'/' /boot/initrd-tree/command_line)
fi
or simply
Code:
MKINITRD_CMD=$(sed -e "s/-k *[^ ]\+//g" -e "s/$/ -k $NEWKERNELVERSION /" /boot/initrd-tree/command_line)
so it works even if you use simply -F.
But we cannot handle all possibility from mkinitrd.conf since it contains also OUTPUT_IMAGE="/boot/initrd.gz" and SOURCE_TREE="/boot/initrd-tree". If some of that are not the default, the process may fail. Otherwise we have to include some part of code of /sbin/mkinitrd to parse the string and mkinitrd.conf.
In a myown mkinitrd.conf customization I added something as
KERNEL_VERSION="$(ls /lib/modules|tail -1)" or similar (well, was must complex since this one row is hugely bugged
, but it is the idea )
If a user configure an mkinitrd.conf (that by default does not exists), he is a semi-advanced user and know what are doing and may be an idea to advice he to rebuild initrd himself.
Also I want to change the search order for the bootloader.
If /etc/lilo.conf exists AND /boot/efi/EFI/Slackware/elilo.conf exists, probably elilo is the current bootloader.
Quote:
Rather than do that, it is better to create a new function with a name that lexicographically sorts after the look_kernel function.
|
on my pc the file is called
zlookkernel.sh, then the copy/paste failed
. Fixed at the first post.
At the end I want to distribute it with slackpkg+ (as optional plugin)
[edit] looking LQ for lookkernel(), I found some patches regard EFI.