Don't add a class option to menu entries generated for ppc64le

For ppc64le a grub config file with menuentry commands is still generated
even when BLS support is enabled. That's because BLS support was added to
Petitboot 1.8.0 and any previous version won't be able to parse BLS files.

To make the BLS snippets the source of truth, these are used to generate
the menuentry commands in the grub config file.

And to keep it consistent across all ppc64le machines regardless of the
firmware used, the grub config file is also generated for machines with
OF that use grub2 and would have BLS support.

The BLS snippets created by the kernel package have fields that are used
to specify the generated menuentry command users and class options. These
fields are not present in BLS snippets created by OSTree though, so the
script generating the menuentry commands will add options with an empty
argument which will lead to grub failing to parse them.

We could check if the field is defined before attempting to add those, but
since the grub2 blscfg module also supports setting these to variables, it
could lead to an empty argument even if was defined in the BLS snippet if
the variable doesn't exist.

So to make more robust, just don't add a class to the menuentry commands
generated by the script. It's better to not have a class for the menuentry
than grub2 failing to parse the command and not populating the boot menu.

Resolves: rhbz#1758225

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2019-10-04 17:22:52 +02:00
parent c432d1fe96
commit 3814958e1a
No known key found for this signature in database
GPG key ID: C751E590D63F3D69
3 changed files with 84 additions and 1 deletions

View file

@ -0,0 +1,78 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Fri, 4 Oct 2019 16:43:05 +0200
Subject: [PATCH] Don't add a class option to menu entries generated for
ppc64le
For ppc64le a grub config file with menuentry commands is still generated
even when BLS support is enabled. That's because BLS support was added to
Petitboot 1.8.0 and any previous version won't be able to parse BLS files.
To make the BLS snippets the source of truth, these are used to generate
the menuentry commands in the grub config file.
And to keep it consistent across all ppc64le machines regardless of the
firmware used, the grub config file is also generated for machines with
OF that use grub2 and would have BLS support.
The BLS snippets created by the kernel package have fields that are used
to specify the generated menuentry command users and class options. These
fields are not present in BLS snippets created by OSTree though, so the
script generating the menuentry commands will add options with an empty
argument which will lead to grub failing to parse them.
We could check if the field is defined before attempting to add those, but
since the grub2 blscfg module also supports setting these to variables, it
could lead to an empty argument even if was defined in the BLS snippet if
the variable doesn't exist.
So to make more robust, just don't add a class to the menuentry commands
generated by the script. It's better to not have a class for the menuentry
than grub2 failing to parse the command and not populating the boot menu.
Resolves: rhbz#1758225
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
util/grub.d/10_linux_bls.in | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in
index 1b7536435f1..68fbedf2129 100644
--- a/util/grub.d/10_linux_bls.in
+++ b/util/grub.d/10_linux_bls.in
@@ -127,9 +127,7 @@ read_config()
initrd=""
options=""
linux=""
- grub_users=""
grub_arg=""
- grub_class=""
while read -r line
do
@@ -148,15 +146,9 @@ read_config()
"options")
options=${value}
;;
- "grub_users")
- grub_users=${value}
- ;;
"grub_arg")
grub_arg=${value}
;;
- "grub_class")
- grub_class=${value}
- ;;
esac
done < ${config_file}
}
@@ -180,7 +172,7 @@ populate_menu()
for bls in "${files[@]}" ; do
read_config "${blsdir}/${bls}.conf"
- menu="${menu}menuentry '${title}' --class ${grub_class} ${grub_arg} --id=${bls} {\n"
+ menu="${menu}menuentry '${title}' ${grub_arg} --id=${bls} {\n"
menu="${menu}\t linux ${linux} ${options}\n"
if [ -n "${initrd}" ] ; then
menu="${menu}\t initrd ${boot_prefix}${initrd}\n"

View file

@ -185,3 +185,4 @@ Patch0184: 0184-arm-Move-trampolines-into-code-section.patch
Patch0185: 0185-arm-Align-section-alignment-with-manual-relocation-o.patch
Patch0186: 0186-grub-core-loader-efi-fdt.c-Do-not-copy-random-memory.patch
Patch0187: 0187-linux-efi-arm-fdt-break-FDT-extra-allocation-space-o.patch
Patch0188: 0188-Don-t-add-a-class-option-to-menu-entries-generated-f.patch

View file

@ -7,7 +7,7 @@
Name: grub2
Epoch: 1
Version: 2.02
Release: 97%{?dist}
Release: 98%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
License: GPLv3+
URL: http://www.gnu.org/software/grub/
@ -518,6 +518,10 @@ rm -r /boot/grub2.tmp/ || :
%endif
%changelog
* Fri Oct 04 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-98
- Don't add a class option to menu entries generated for ppc64le
Resolves: rhbz#1758225
* Wed Aug 07 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-97
- Include regexp module in EFI builds