mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-11-28 07:44:52 +00:00
Another set of BLS fixes
BLS files should only be copied by grub-switch-to-blscfg if BLS isn't set Related: rhbz#1638117 Fix get_entry_number() wrongly dereferencing the tail pointer Resolves: rhbz#1654936 Make grub2-mkconfig to honour GRUB_CMDLINE_LINUX in /etc/default/grub Resolves: rhbz#1637875 Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
parent
1f092caba7
commit
4ff5f8dcef
5 changed files with 265 additions and 1 deletions
120
0270-BLS-files-should-only-be-copied-by-grub-switch-to-bl.patch
Normal file
120
0270-BLS-files-should-only-be-copied-by-grub-switch-to-bl.patch
Normal file
|
@ -0,0 +1,120 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 4 Dec 2018 10:48:45 +0100
|
||||
Subject: [PATCH] BLS files should only be copied by grub-switch-to-blscfg if
|
||||
BLS isn't set
|
||||
|
||||
Currently the grub-switch-to-blscfg script doesn't update the grub.cfg if
|
||||
GRUB_ENABLE_BLSCFG=true is already set in /etc/default/grub. But it still
|
||||
copies the BLS files which may overwrite fields modified by the user.
|
||||
|
||||
Related: rhbz#1638117
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
util/grub-switch-to-blscfg.in | 80 +++++++++++++++++++++++--------------------
|
||||
1 file changed, 42 insertions(+), 38 deletions(-)
|
||||
|
||||
diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in
|
||||
index d353370cc51..eeea1307706 100644
|
||||
--- a/util/grub-switch-to-blscfg.in
|
||||
+++ b/util/grub-switch-to-blscfg.in
|
||||
@@ -220,49 +220,51 @@ EOF
|
||||
) | cat
|
||||
}
|
||||
|
||||
-for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
|
||||
- bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
|
||||
- linux="/vmlinuz-${kernelver}"
|
||||
- linux_path="/boot${linux}"
|
||||
- kernel_dir="/lib/modules/${kernelver}"
|
||||
+copy_bls() {
|
||||
+ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
|
||||
+ bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
|
||||
+ linux="/vmlinuz-${kernelver}"
|
||||
+ linux_path="/boot${linux}"
|
||||
+ kernel_dir="/lib/modules/${kernelver}"
|
||||
|
||||
- if [ ! -d "${kernel_dir}" ] ; then
|
||||
- continue
|
||||
- fi
|
||||
- if [ ! -f "${linux_path}" ]; then
|
||||
- continue
|
||||
- fi
|
||||
+ if [ ! -d "${kernel_dir}" ] ; then
|
||||
+ continue
|
||||
+ fi
|
||||
+ if [ ! -f "${linux_path}" ]; then
|
||||
+ continue
|
||||
+ fi
|
||||
|
||||
- linux_relpath="$("${grub_mkrelpath}" "${linux_path}")"
|
||||
- bootprefix="${linux_relpath%%"${linux}"}"
|
||||
+ linux_relpath="$("${grub_mkrelpath}" "${linux_path}")"
|
||||
+ bootprefix="${linux_relpath%%"${linux}"}"
|
||||
|
||||
- if [ -f "${kernel_dir}/bls.conf" ] ; then
|
||||
- cp -af "${kernel_dir}/bls.conf" "${bls_target}"
|
||||
- if [ -n "${bootprefix}" ]; then
|
||||
- sed -i -e "s,^\(linux[^ \t]*[ \t]\+\).*,\1${bootprefix}${linux},g" "${bls_target}"
|
||||
- sed -i -e "/^initrd/ s,\([ \t]\+\)\([^ \t]\+\),\1${bootprefix}\2,g" "${bls_target}"
|
||||
- fi
|
||||
- else
|
||||
- mkbls "${kernelver}" \
|
||||
- "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \
|
||||
- "${bootprefix}" \
|
||||
- >"${bls_target}"
|
||||
- fi
|
||||
+ if [ -f "${kernel_dir}/bls.conf" ] ; then
|
||||
+ cp -af "${kernel_dir}/bls.conf" "${bls_target}"
|
||||
+ if [ -n "${bootprefix}" ]; then
|
||||
+ sed -i -e "s,^\(linux[^ \t]*[ \t]\+\).*,\1${bootprefix}${linux},g" "${bls_target}"
|
||||
+ sed -i -e "/^initrd/ s,\([ \t]\+\)\([^ \t]\+\),\1${bootprefix}\2,g" "${bls_target}"
|
||||
+ fi
|
||||
+ else
|
||||
+ mkbls "${kernelver}" \
|
||||
+ "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \
|
||||
+ "${bootprefix}" \
|
||||
+ >"${bls_target}"
|
||||
+ fi
|
||||
|
||||
- if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then
|
||||
- bls_debug="$(echo ${bls_target} | sed -e "s/${kernelver}/${kernelver}~debug/")"
|
||||
- cp -aT "${bls_target}" "${bls_debug}"
|
||||
- title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')"
|
||||
- blsid="$(grep '^id[ \t]' "${bls_debug}" | sed -e "s/\.${ARCH}/-debug.${arch}/")"
|
||||
- sed -i -e "s/^title.*/title ${title}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${bls_debug}"
|
||||
- sed -i -e "s/^id.*/${blsid}/" "${bls_debug}"
|
||||
- sed -i -e "s/^options.*/options \$kernelopts ${GRUB_CMDLINE_LINUX_DEBUG}/" "${bls_debug}"
|
||||
- fi
|
||||
-done
|
||||
+ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then
|
||||
+ bls_debug="$(echo ${bls_target} | sed -e "s/${kernelver}/${kernelver}~debug/")"
|
||||
+ cp -aT "${bls_target}" "${bls_debug}"
|
||||
+ title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')"
|
||||
+ blsid="$(grep '^id[ \t]' "${bls_debug}" | sed -e "s/\.${ARCH}/-debug.${arch}/")"
|
||||
+ sed -i -e "s/^title.*/title ${title}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${bls_debug}"
|
||||
+ sed -i -e "s/^id.*/${blsid}/" "${bls_debug}"
|
||||
+ sed -i -e "s/^options.*/options \$kernelopts ${GRUB_CMDLINE_LINUX_DEBUG}/" "${bls_debug}"
|
||||
+ fi
|
||||
+ done
|
||||
|
||||
-if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then
|
||||
- mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf"
|
||||
-fi
|
||||
+ if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then
|
||||
+ mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf"
|
||||
+ fi
|
||||
+}
|
||||
|
||||
GENERATE=0
|
||||
if grep '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" \
|
||||
@@ -283,6 +285,8 @@ elif ! grep -q '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" ; then
|
||||
fi
|
||||
|
||||
if [ "${GENERATE}" -eq 1 ] ; then
|
||||
+ copy_bls
|
||||
+
|
||||
if [ $arch = "x86_64" ] && [ ! -d /sys/firmware/efi ]; then
|
||||
if ! cp ${prefix}/lib/grub//i386-pc/blscfg.mod ${grubdir}/i386-pc/ ; then
|
||||
exit 1
|
|
@ -0,0 +1,34 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 4 Dec 2018 10:53:49 +0100
|
||||
Subject: [PATCH] Fix get_entry_number() wrongly dereferencing the tail pointer
|
||||
|
||||
The get_entry_number_helper() function attempts to lookup a boot entry by
|
||||
either title or id matching the value of an environment variable. If they
|
||||
are a substring of the variable, the tail pointer is set to the first char
|
||||
of the remainder of the string.
|
||||
|
||||
When get_entry_number() calls this function, it checks if this first char
|
||||
is a NUL byte, to know if the variable matched correctly. But tail can be
|
||||
set to NULL as well to indicate that there isn't a remainder in the string.
|
||||
|
||||
Resolves: rhbz#1654936
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
grub-core/normal/menu.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
|
||||
index fc25c702f3c..7e32c498aa8 100644
|
||||
--- a/grub-core/normal/menu.c
|
||||
+++ b/grub-core/normal/menu.c
|
||||
@@ -563,7 +563,7 @@ get_entry_number (grub_menu_t menu, const char *name)
|
||||
|
||||
grub_error_push ();
|
||||
entry = get_entry_number_helper(menu, val, &tail);
|
||||
- if (*tail != '\0')
|
||||
+ if (tail && *tail != '\0')
|
||||
entry = -1;
|
||||
grub_error_pop ();
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Mon, 10 Dec 2018 13:11:58 +0100
|
||||
Subject: [PATCH] Make grub2-mkconfig to honour GRUB_CMDLINE_LINUX in
|
||||
/etc/default/grub
|
||||
|
||||
The kernelopts grub environment variable is set with the GRUB_CMDLINE_LINUX
|
||||
value only if wasn't set before. This is because the kernel cmdline params
|
||||
of the entries are not in the grub.cfg anymore so grub2-mkconfig shouldn't
|
||||
have side effects on neither the entries nor their kernel cmdline params.
|
||||
|
||||
But there's a lot of documentation pointing at modifying GRUB_CMDLINE_LINUX
|
||||
to change the kernel cmdline params and users have built a muscle memory on
|
||||
it, so the BLS support should be compatible.
|
||||
|
||||
Make the grub2-mkconfig script update the $kernelopts environment variable
|
||||
unless the --no-grubenv-update option is used.
|
||||
|
||||
Resolves: rhbz#1637875
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
util/grub-mkconfig.8 | 4 ++++
|
||||
util/grub-mkconfig.in | 6 ++++++
|
||||
util/grub.d/10_linux.in | 2 +-
|
||||
util/grub.d/10_linux_bls.in | 2 +-
|
||||
4 files changed, 12 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/util/grub-mkconfig.8 b/util/grub-mkconfig.8
|
||||
index a2d1f577b9b..434fa4deda4 100644
|
||||
--- a/util/grub-mkconfig.8
|
||||
+++ b/util/grub-mkconfig.8
|
||||
@@ -13,5 +13,9 @@
|
||||
\fB--output\fR=\fIFILE\fR
|
||||
Write generated output to \fIFILE\fR.
|
||||
|
||||
+.TP
|
||||
+\fB--no-grubenv-update\fR
|
||||
+Do not update variables in the grubenv file.
|
||||
+
|
||||
.SH SEE ALSO
|
||||
.BR "info grub"
|
||||
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
|
||||
index c20171919d9..5e643e16973 100644
|
||||
--- a/util/grub-mkconfig.in
|
||||
+++ b/util/grub-mkconfig.in
|
||||
@@ -50,6 +50,8 @@ grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@"
|
||||
export TEXTDOMAIN=@PACKAGE@
|
||||
export TEXTDOMAINDIR="@localedir@"
|
||||
|
||||
+export GRUB_GRUBENV_UPDATE="yes"
|
||||
+
|
||||
. "${pkgdatadir}/grub-mkconfig_lib"
|
||||
|
||||
# Usage: usage
|
||||
@@ -59,6 +61,7 @@ usage () {
|
||||
gettext "Generate a grub config file"; echo
|
||||
echo
|
||||
print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")"
|
||||
+ print_option_help "--no-grubenv-update" "$(gettext "do not update variables in the grubenv file")"
|
||||
print_option_help "-h, --help" "$(gettext "print this message and exit")"
|
||||
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
|
||||
echo
|
||||
@@ -94,6 +97,9 @@ do
|
||||
--output=*)
|
||||
grub_cfg=`echo "$option" | sed 's/--output=//'`
|
||||
;;
|
||||
+ --no-grubenv-update)
|
||||
+ GRUB_GRUBENV_UPDATE="no"
|
||||
+ ;;
|
||||
-*)
|
||||
gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2
|
||||
usage
|
||||
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
|
||||
index b54d2774a7d..da2992ac9f1 100644
|
||||
--- a/util/grub.d/10_linux.in
|
||||
+++ b/util/grub.d/10_linux.in
|
||||
@@ -165,7 +165,7 @@ if [ -s \$prefix/grubenv ]; then
|
||||
fi
|
||||
EOF
|
||||
|
||||
- if ! grub2-editenv - list | grep -q kernelopts; then
|
||||
+ if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then
|
||||
${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}"
|
||||
fi
|
||||
|
||||
diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in
|
||||
index 8cff4c58ab5..175bedd0763 100644
|
||||
--- a/util/grub.d/10_linux_bls.in
|
||||
+++ b/util/grub.d/10_linux_bls.in
|
||||
@@ -225,7 +225,7 @@ linux_entry ()
|
||||
populate_header_warn
|
||||
populate_menu
|
||||
|
||||
- if ! grub2-editenv - list | grep -q kernelopts; then
|
||||
+ if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then
|
||||
${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}"
|
||||
fi
|
||||
|
|
@ -267,3 +267,6 @@ Patch0266: 0266-blscfg-expand-grub_users-before-passing-to-grub_norm.patch
|
|||
Patch0267: 0267-Make-the-menu-entry-users-option-argument-to-be-opti.patch
|
||||
Patch0268: 0268-10_linux_bls-add-missing-menu-entries-options.patch
|
||||
Patch0269: 0269-Fix-menu-entry-selection-based-on-title.patch
|
||||
Patch0270: 0270-BLS-files-should-only-be-copied-by-grub-switch-to-bl.patch
|
||||
Patch0271: 0271-Fix-get_entry_number-wrongly-dereferencing-the-tail-.patch
|
||||
Patch0272: 0272-Make-grub2-mkconfig-to-honour-GRUB_CMDLINE_LINUX-in-.patch
|
||||
|
|
10
grub2.spec
10
grub2.spec
|
@ -7,7 +7,7 @@
|
|||
Name: grub2
|
||||
Epoch: 1
|
||||
Version: 2.02
|
||||
Release: 64%{?dist}
|
||||
Release: 65%{?dist}
|
||||
Summary: Bootloader with support for Linux, Multiboot and more
|
||||
Group: System Environment/Base
|
||||
License: GPLv3+
|
||||
|
@ -492,6 +492,14 @@ fi
|
|||
%endif
|
||||
|
||||
%changelog
|
||||
* Tue Dec 11 2018 Javier Martinez Canillas <javierm@redhat.com> - 2.02-65
|
||||
- BLS files should only be copied by grub-switch-to-blscfg if BLS isn't set
|
||||
Related: rhbz#1638117
|
||||
- Fix get_entry_number() wrongly dereferencing the tail pointer
|
||||
Resolves: rhbz#1654936
|
||||
- Make grub2-mkconfig to honour GRUB_CMDLINE_LINUX in /etc/default/grub
|
||||
Resolves: rhbz#1637875
|
||||
|
||||
* Fri Nov 30 2018 Javier Martinez Canillas <javierm@redhat.com> - 2.02-64
|
||||
- Add comments and revert logic changes in 01_fallback_counting
|
||||
- Remove quotes when reading ID value from /etc/os-release
|
||||
|
|
Loading…
Reference in a new issue