1 Star 0 Fork 46

庞庆 / grub2

forked from src-anolis-os / grub2 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0237-Only-set-kernelopts-in-grubenv-if-it-wasn-t-set-befo.patch 2.48 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2022-04-13 15:15 . update to grub2-2.02-120.el8.src.rpm
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 9682e97b7..01e66e5fc 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 3cc7803c6..8a3379578 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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/pang-qing/grub2.git
git@gitee.com:pang-qing/grub2.git
pang-qing
grub2
grub2
a8

搜索帮助

344bd9b3 5694891 D2dac590 5694891