From 5d3963841da86836020e3658cc055d9f6c33655b Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 26 Apr 2021 18:43:51 +0200 Subject: [PATCH] grubby-bs: Fix changing kernel cmdline params not working on ppc64le Currently the grubby script re-generates a GRUB config file that contains menuentry commands for every /boot/loader/entries/*.conf file snippet. But this is only needed for ppc64le machines that have a Petitboot version that doesn't support parsing BLS snippets. Instead of generating a config on any ppc64le machine, restrict this for the case where is really needed. The /etc/grub.d/10_linux script already takes this into account and does not add menuentry commands unless is needed. But the grubby script didn't check this, causing changing kernel cmdline params to not work on ppc64le. Signed-off-by: Javier Martinez Canillas --- grubby-bls | 29 +++++++++++++++++++++++++++-- grubby.spec | 5 ++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/grubby-bls b/grubby-bls index def45dd..aa1f3a2 100755 --- a/grubby-bls +++ b/grubby-bls @@ -581,8 +581,33 @@ remove_var_prefix() { update_grubcfg() { - if [[ $arch = 'ppc64' || $arch = 'ppc64le' ]]; then - grub2-mkconfig --no-grubenv-update -o "${grub_config}" >& /dev/null + # Older ppc64le OPAL firmware (petitboot version < 1.8.0) don't have BLS support + # so grub2-mkconfig has to be run to generate a config with menuentry commands. + if [ "${arch}" = "ppc64le" ] && [ -d /sys/firmware/opal ]; then + RUN_MKCONFIG="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})" + + 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 + RUN_MKCONFIG="false" + fi + fi + fi + fi + + if [[ $RUN_MKCONFIG = "true" ]]; then + grub2-mkconfig --no-grubenv-update -o "${grub_config}" >& /dev/null fi } diff --git a/grubby.spec b/grubby.spec index 1f7fd07..4f22e97 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 51%{?dist} +Release: 52%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Mon Apr 26 2021 Javier Martinez Canillas - 8.40-52 +- grubby-bs: Fix changing kernel cmdline params not working on ppc64le + * Tue Jan 26 2021 Fedora Release Engineering - 8.40-51 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild