From 97b94515270022f006498d482d3e18b2debd02ec Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mar 11 2021 10:20:43 +0000 Subject: Fix config file generation failing due invalid petitboot version value Resolves: rhbz#1921479 Signed-off-by: Javier Martinez Canillas --- diff --git a/0269-10_linux.in-Check-if-petitboot-sysfs-has-a-valid-ver.patch b/0269-10_linux.in-Check-if-petitboot-sysfs-has-a-valid-ver.patch new file mode 100644 index 0000000..79c805f --- /dev/null +++ b/0269-10_linux.in-Check-if-petitboot-sysfs-has-a-valid-ver.patch @@ -0,0 +1,67 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +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 +--- + 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 + diff --git a/grub.patches b/grub.patches index e581739..a8628d1 100644 --- a/grub.patches +++ b/grub.patches @@ -266,3 +266,4 @@ Patch0265: 0265-Fix-const-char-pointers-in-grub-core-net-url.c.patch Patch0266: 0266-Add-systemd-integration-scripts-to-make-systemctl-re.patch Patch0267: 0267-systemd-integration.sh-Also-set-old-menu_show_once-g.patch Patch0268: 0268-tftp-roll-over-block-counter-to-prevent-timeouts-wit.patch +Patch0269: 0269-10_linux.in-Check-if-petitboot-sysfs-has-a-valid-ver.patch diff --git a/grub2.spec b/grub2.spec index c921bca..36524a7 100644 --- a/grub2.spec +++ b/grub2.spec @@ -14,7 +14,7 @@ Name: grub2 Epoch: 1 Version: 2.04 -Release: 32%{?dist} +Release: 33%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -516,6 +516,10 @@ rm -r /boot/grub2.tmp/ || : %endif %changelog +* Thu Mar 11 2021 Javier Martinez Canillas - 2.04-33 +- Fix config file generation failing due invalid petitboot version value + Resolves: rhbz#1921479 + * Tue Feb 09 2021 Javier Martinez Canillas - 2.04-32 - Fix module loading in the 20_linux_xen script Resolves: rhbz#1858364