Fix config file generation failing due invalid petitboot version value

Resolves: rhbz#1921479

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2021-03-11 12:16:42 +01:00
parent a9c2368688
commit 0022b7c68a
No known key found for this signature in database
GPG key ID: C751E590D63F3D69
3 changed files with 73 additions and 1 deletions

View file

@ -0,0 +1,67 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Wed, 10 Mar 2021 12:50:15 +0100
Subject: [PATCH] 10_linux.in: Check if petitboot sysfs has a valid version
The script assumes that the petitboot sysfs entry contains a valid version
number, but this is not always the case. For example, on a Talos II system
a user reported that contained the following value:
$ cat /sys/firmware/devicetree/base/ibm,firmware-versions/petitboot
0ed84c0-p94177c1
This lead to the script wrongly trying to compare these hashes as if they
were integers values, which caused the following error when re-generating
the GRUB configuration file:
/etc/grub.d/10_linux: line 234: test: 0ed84c0-p94177c1: integer expression expected
/etc/grub.d/10_linux: line 235: test: 0ed84c0-p94177c1: integer expression expected
Check that the major and minor values are integers before attempting to do
the comparison. If these aren't numbers, then generate the menu with a set
of menuentry commands, since there's no way to know the petitboot version.
Resolves: rhbz#1921479
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
util/grub.d/10_linux.in | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index e61b6c94f11..b9426eb2e2e 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -223,20 +223,25 @@ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then
arch="$(uname -m)"
if [ "x${arch}" = "xppc64le" ] && [ -d /sys/firmware/opal ]; then
+ BLS_POPULATE_MENU="true"
petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot"
if test -e ${petitboot_path}; then
read -r -d '' petitboot_version < ${petitboot_path}
petitboot_version="$(echo ${petitboot_version//v})"
- major_version="$(echo ${petitboot_version} | cut -d . -f1)"
- minor_version="$(echo ${petitboot_version} | cut -d . -f2)"
- if test -z ${petitboot_version} || test ${major_version} -lt 1 || \
- test ${major_version} -eq 1 -a ${minor_version} -lt 8; then
- BLS_POPULATE_MENU="true"
+ if test -n ${petitboot_version}; then
+ major_version="$(echo ${petitboot_version} | cut -d . -f1)"
+ minor_version="$(echo ${petitboot_version} | cut -d . -f2)"
+
+ re='^[0-9]+$'
+ if [[ $major_version =~ $re ]] && [[ $minor_version =~ $re ]] &&
+ ([[ ${major_version} -gt 1 ]] ||
+ [[ ${major_version} -eq 1 &&
+ ${minor_version} -ge 8 ]]); then
+ BLS_POPULATE_MENU="false"
+ fi
fi
- else
- BLS_POPULATE_MENU="true"
fi
fi

View file

@ -301,3 +301,4 @@ Patch0300: 0300-appended-signatures-documentation.patch
Patch0301: 0301-ieee1275-link-appended-signature-enforcement-to-ibm-.patch Patch0301: 0301-ieee1275-link-appended-signature-enforcement-to-ibm-.patch
Patch0302: 0302-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch Patch0302: 0302-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch
Patch0303: 0303-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch Patch0303: 0303-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch
Patch0304: 0304-10_linux.in-Check-if-petitboot-sysfs-has-a-valid-ver.patch

View file

@ -14,7 +14,7 @@
Name: grub2 Name: grub2
Epoch: 1 Epoch: 1
Version: 2.04 Version: 2.04
Release: 38%{?dist} Release: 39%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more Summary: Bootloader with support for Linux, Multiboot and more
License: GPLv3+ License: GPLv3+
URL: http://www.gnu.org/software/grub/ URL: http://www.gnu.org/software/grub/
@ -551,6 +551,10 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg
%endif %endif
%changelog %changelog
* Thu Mar 11 2021 Javier Martinez Canillas <javierm@redhat.com> - 2.04-39
- Fix config file generation failing due invalid petitboot version value
Resolves: rhbz#1921479
* Fri Mar 05 2021 Javier Martinez Canillas <javierm@redhat.com> - 2.04-38 * Fri Mar 05 2021 Javier Martinez Canillas <javierm@redhat.com> - 2.04-38
- Fix keyboards that report IBM PC AT scan codes (rmetrich) - Fix keyboards that report IBM PC AT scan codes (rmetrich)