420527
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
420527
From: Javier Martinez Canillas <javierm@redhat.com>
420527
Date: Fri, 5 Oct 2018 16:29:47 +0200
420527
Subject: [PATCH] Only set kernelopts in grubenv if it wasn't set before
420527
420527
Users may want to use a different command line parameters, so if there's
420527
a kernelopts var set in grubenv, grub2-mkconfig shouldn't reset it.
420527
420527
While being there, print a warning so users know that they shouldn't edit
420527
the grub config file and instead edit the BootLoaderSpec config files.
420527
420527
Resolves: rhbz#1636466
420527
420527
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
420527
---
420527
 util/grub.d/10_linux.in     | 20 +++++++++++++++++++-
420527
 util/grub.d/10_linux_bls.in |  4 +++-
420527
 2 files changed, 22 insertions(+), 2 deletions(-)
420527
420527
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
420527
index 9682e97b7f5..01e66e5fc74 100644
420527
--- a/util/grub.d/10_linux.in
420527
+++ b/util/grub.d/10_linux.in
420527
@@ -82,6 +82,20 @@ case x"$GRUB_FS" in
420527
 	;;
420527
 esac
420527
 
420527
+populate_header_warn()
420527
+{
420527
+cat <
420527
+
420527
+# This section was generated by a script. Do not modify the generated file - all changes
420527
+# will be lost the next time file is regenerated. Instead edit the BootLoaderSpec files.
420527
+#
420527
+# The blscfg command parses the BootLoaderSpec files stored in /boot/loader/entries and
420527
+# populates the boot menu. Please refer to the Boot Loader Specification documentation
420527
+# for the files format: https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/.
420527
+
420527
+EOF
420527
+}
420527
+
420527
 mktitle ()
420527
 {
420527
   local title_type
420527
@@ -141,6 +155,8 @@ linux_entry ()
420527
         prepare_grub_to_access_device ${boot_device} boot
420527
     fi
420527
 
420527
+    populate_header_warn
420527
+
420527
     cat << EOF
420527
 insmod blscfg
420527
 blscfg
420527
@@ -150,7 +166,9 @@ fi
420527
 EOF
420527
 
420527
     ${grub_editenv} - set saved_entry=0
420527
-    ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}"
420527
+    if ! grub2-editenv - list | grep -q kernelopts; then
420527
+	${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}"
420527
+    fi
420527
 
420527
     exit 0
420527
   fi
420527
diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in
420527
index 3cc7803c6a1..8a3379578bd 100644
420527
--- a/util/grub.d/10_linux_bls.in
420527
+++ b/util/grub.d/10_linux_bls.in
420527
@@ -201,7 +201,9 @@ linux_entry ()
420527
     populate_menu
420527
 
420527
     ${grub_editenv} - set saved_entry=0
420527
-    ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}"
420527
+    if ! grub2-editenv - list | grep -q kernelopts; then
420527
+	${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}"
420527
+    fi
420527
 
420527
     exit 0
420527
   fi