You are not logged in.

#1 2022-01-20 05:14:40

covid19
Member
From: Not Wuhan
Registered: 2020-04-20
Posts: 40

Can't patch and rebuild grub 2.06-4

For the past year I've been using a patch to correct the kernel order in grub with default and lts kernels installed, for lts to act like a real backup kernel. With 2.06-4 this patch fails, this is the output:

patching file util/grub.d/10_linux.in
Hunk #1 succeeded at 97 with fuzz 1 (offset 14 lines).
Hunk #2 FAILED at 188.
Hunk #3 FAILED at 250.
2 out of 3 hunks FAILED -- saving rejects to file util/grub.d/10_linux.in.rej
==> ERROR: A failure occurred in prepare().

The contents of the patch are:

diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index de9044c7f..a9087da35 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -178,8 +178,20 @@ title_correction_code=
 submenu_indentation=""
 
 is_top_level=true
+default_kernel_grabbed=false
+default_kernel_name="/boot/vmlinuz-linux"
 while [ "x$list" != "x" ] ; do
   linux=`version_find_latest $list`
+  if ! $default_kernel_grabbed; then
+    for i in $list; do
+      if [ $i == $default_kernel_name ]
+      then
+        linux=$default_kernel_name
+        break
+      fi
+    done
+    default_kernel_grabbed=true
+  fi
   gettext_printf "Found linux image: %s\n" "$linux" >&2
   basename=`basename $linux`
   dirname=`dirname $linux`

Any help is much appreciated, grub has been behaving exactly the way I want with this patch
Thanks

Last edited by covid19 (2022-01-20 05:17:40)

Offline

#2 2022-01-20 08:44:48

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,742

Re: Can't patch and rebuild grub 2.06-4

You  are patching a plain text shell script you can simply inspect even with the installed GRUB version. That exact block is still present in the file maybe just line shifted a bit due to the new compression support in mkrescue. it should be trivial to adjust the patch.

diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index de9044c7f..a9087da35 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -196,8 +196,20 @@ title_correction_code=
 submenu_indentation=""
 
 is_top_level=true
+default_kernel_grabbed=false
+default_kernel_name="/boot/vmlinuz-linux"
 while [ "x$list" != "x" ] ; do
   linux=`version_find_latest $list`
+  if ! $default_kernel_grabbed; then
+    for i in $list; do
+      if [ $i == $default_kernel_name ]
+      then
+        linux=$default_kernel_name
+        break
+      fi
+    done
+    default_kernel_grabbed=true
+  fi
   gettext_printf "Found linux image: %s\n" "$linux" >&2
   basename=`basename $linux`
   dirname=`dirname $linux`

note the only thing changed here is the line at which it should apply. You might have to adjust the index line but I didn't feel like grabbing the git tree to find the real new hash

Last edited by V1del (2022-01-20 09:34:16)

Offline

Board footer

Powered by FluxBB