aboutsummaryrefslogtreecommitdiffstats
path: root/main/grub/0009-fix-kernel-version-detection.patch
blob: f0141b8d01d6def1404de068cae7e4988e1a8d41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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}"