grub2/0258-Only-set-kernelopts-in-grubenv-if-it-wasn-t-set-befo.patch
Javier Martinez Canillas 420527a50b
A bunch of fixes for BLS
- add 10_linux_bls grub.d snippet to generate menu entries from BLS files
  Resolves: rhbz#1636013
- Only set kernelopts in grubenv if it wasn't set before
  Resolves: rhbz#1636466
- kernel-install: Remove existing initramfs if it's older than the kernel (pjones)
  Resolves: rhbz#1638405
- Update the saved entry correctly after a kernel install (pjones)
  Resolves: rhbz#1638117
- blscfg: sort everything with rpm *package* comparison (pjones)
  Related: rhbz#1638103
- blscfg: Make 10_linux_bls sort the same way as well
  Related: rhbz#1638103
- don't set saved_entry on grub2-mkconfig
  Resolves: rhbz#1636466
- Fix menu entry selection based on ID and title (pjones)
  Resolves: rhbz#1640979

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-10-23 15:57:56 +02:00

79 lines
2.5 KiB
Diff

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