dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0254-Make-grub2-mkconfig-to-honour-GRUB_CMDLINE_LINUX-in-.patch

8631a2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8631a2
From: Javier Martinez Canillas <javierm@redhat.com>
8631a2
Date: Mon, 10 Dec 2018 13:11:58 +0100
8631a2
Subject: [PATCH] Make grub2-mkconfig to honour GRUB_CMDLINE_LINUX in
8631a2
 /etc/default/grub
8631a2
8631a2
The kernelopts grub environment variable is set with the GRUB_CMDLINE_LINUX
8631a2
value only if wasn't set before. This is because the kernel cmdline params
8631a2
of the entries are not in the grub.cfg anymore so grub2-mkconfig shouldn't
8631a2
have side effects on neither the entries nor their kernel cmdline params.
8631a2
8631a2
But there's a lot of documentation pointing at modifying GRUB_CMDLINE_LINUX
8631a2
to change the kernel cmdline params and users have built a muscle memory on
8631a2
it, so the BLS support should be compatible.
8631a2
8631a2
Make the grub2-mkconfig script update the $kernelopts environment variable
8631a2
unless the --no-grubenv-update option is used.
8631a2
8631a2
Resolves: rhbz#1637875
8631a2
8631a2
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
8631a2
---
8631a2
 util/grub-mkconfig.8        | 4 ++++
8631a2
 util/grub-mkconfig.in       | 6 ++++++
8631a2
 util/grub.d/10_linux.in     | 2 +-
8631a2
 util/grub.d/10_linux_bls.in | 2 +-
8631a2
 4 files changed, 12 insertions(+), 2 deletions(-)
8631a2
8631a2
diff --git a/util/grub-mkconfig.8 b/util/grub-mkconfig.8
8631a2
index a2d1f577b9b..434fa4deda4 100644
8631a2
--- a/util/grub-mkconfig.8
8631a2
+++ b/util/grub-mkconfig.8
8631a2
@@ -13,5 +13,9 @@
8631a2
 \fB--output\fR=\fIFILE\fR
8631a2
 Write generated output to \fIFILE\fR.
8631a2
 
8631a2
+.TP
8631a2
+\fB--no-grubenv-update\fR
8631a2
+Do not update variables in the grubenv file.
8631a2
+
8631a2
 .SH SEE ALSO
8631a2
 .BR "info grub"
8631a2
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
8631a2
index c20171919d9..5e643e16973 100644
8631a2
--- a/util/grub-mkconfig.in
8631a2
+++ b/util/grub-mkconfig.in
8631a2
@@ -50,6 +50,8 @@ grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@"
8631a2
 export TEXTDOMAIN=@PACKAGE@
8631a2
 export TEXTDOMAINDIR="@localedir@"
8631a2
 
8631a2
+export GRUB_GRUBENV_UPDATE="yes"
8631a2
+
8631a2
 . "${pkgdatadir}/grub-mkconfig_lib"
8631a2
 
8631a2
 # Usage: usage
8631a2
@@ -59,6 +61,7 @@ usage () {
8631a2
     gettext "Generate a grub config file"; echo
8631a2
     echo
8631a2
     print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")"
8631a2
+    print_option_help "--no-grubenv-update" "$(gettext "do not update variables in the grubenv file")"
8631a2
     print_option_help "-h, --help" "$(gettext "print this message and exit")"
8631a2
     print_option_help "-v, --version" "$(gettext "print the version information and exit")"
8631a2
     echo
8631a2
@@ -94,6 +97,9 @@ do
8631a2
     --output=*)
8631a2
 	grub_cfg=`echo "$option" | sed 's/--output=//'`
8631a2
 	;;
8631a2
+    --no-grubenv-update)
8631a2
+	GRUB_GRUBENV_UPDATE="no"
8631a2
+	;;
8631a2
     -*)
8631a2
 	gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2
8631a2
 	usage
8631a2
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
8631a2
index b54d2774a7d..da2992ac9f1 100644
8631a2
--- a/util/grub.d/10_linux.in
8631a2
+++ b/util/grub.d/10_linux.in
8631a2
@@ -165,7 +165,7 @@ if [ -s \$prefix/grubenv ]; then
8631a2
 fi
8631a2
 EOF
8631a2
 
8631a2
-    if ! grub2-editenv - list | grep -q kernelopts; then
8631a2
+    if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then
8631a2
 	${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}"
8631a2
     fi
8631a2
 
8631a2
diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in
8631a2
index 8cff4c58ab5..175bedd0763 100644
8631a2
--- a/util/grub.d/10_linux_bls.in
8631a2
+++ b/util/grub.d/10_linux_bls.in
8631a2
@@ -225,7 +225,7 @@ linux_entry ()
8631a2
     populate_header_warn
8631a2
     populate_menu
8631a2
 
8631a2
-    if ! grub2-editenv - list | grep -q kernelopts; then
8631a2
+    if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then
8631a2
 	${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}"
8631a2
     fi
8631a2