aports/main/grub/0009-fix-kernel-version-detection.patch
Dermot Bradley 1895cf9fc2 main/grub: correct detection of linux-edge-virt by grub-mkconfig
grub-mkconfig does not correctly handle the linux-edge-virt package
when creating /boot/grub.grub.cfg. It incorrectly looks for the file
initramfs-virt rather than initramfs-edge-virt due to a regex pattern
that behaves differently on Alpine compared to other distros (the
regex assumes that kernel package versions and filenames will include
the numeric kernel version).

The enclosed patch changes the regex pattern to act correctly on
Alpine.
2021-11-01 14:34:26 +00:00

65 lines
2.6 KiB
Diff

From: Dermot Bradley <dermot_bradley@yahoo.com>
Date: Fri, 29 Oct 2021 18:51 +0100
Subject: Fix grub-mkconfig detection of linux-edge-virt
grub-mkconfig does not correctly handle the linux-edge-virt package
when creating /boot/grub.grub.cfg. The 10_linux and 20_linux_xen
files determine the "version" of the kernel using a regex pattern
that does not correctly handle the presence of 2 "-" characters.
As a result, when using the linux-edge-virt package grub-mkconfig
incorrectly believes the version is "virt" rather than "edge-virt"
and it searches for /boot/initramfs-edge which does not exist,
resulting in no "initrd" line being placed in the grub.cfg to point
to the initramfs.
This issue does not appear with the linux-lts, linux-virt, linux-edge
packages as their kernel and initramfs files only have a single "-"
in their filenames.
This is likely to be an Alpine-specific Grub issue as many/most other
Linux distros include the actual kernel numeric version as part of
the initramfs filenames (as, unlike Alpine they support multiple
kernels being simultaneously installed and so need to distinguish
between them).
This fix simply changes the regex pattern to remove everything prior
to, and including, the first "-" symbol, so leaving "lts", "edge",
"edge-virt", or "virt" as appropriate.
---
diff -aur a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -201,7 +201,7 @@
basename=`basename $linux`
dirname=`dirname $linux`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
- version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
+ version=`echo $basename | sed -e "s,^[^-]*-,,g"`
alt_version=`echo $version | sed -e "s,\.old$,,g"`
linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
diff -aur a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -181,7 +181,7 @@
for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do
if grub_file_is_not_garbage "$i"; then
basename=$(basename $i)
- version=$(echo $basename | sed -e "s,^[^0-9]*-,,g")
+ version=$(echo $basename | sed -e "s,^[^-]*-,,g")
dirname=$(dirname $i)
config=
for j in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
@@ -275,7 +275,7 @@
basename=`basename $linux`
dirname=`dirname $linux`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
- version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
+ version=`echo $basename | sed -e "s,^[^-]*-,,g"`
alt_version=`echo $version | sed -e "s,\.old$,,g"`
linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"