From 5b940b00df5e2370436b462388621f24006e1525 Mon Sep 17 00:00:00 2001 From: Marta Lewandowska Date: Tue, 12 Nov 2024 13:36:06 -0600 Subject: [PATCH] Fix default behavior when GRUB_ENABLE_BLSCFG is not present Currently on a kernel update, if GRUB_ENABLE_BLSCFG variable is not defined, grub2-mkconfig is not executed but it should. Also RHEL 8 has two grub.cfg stubs depending on how the system boots: /boot/grub2/grub.cfg for BIOS and /efi/EFI/redhat/grub.cfg for UEFI. The following change fixes both issues. Resolves: #RHEL-4319 Signed-off-by: Marta Lewandowska Reviewed-by: Leo Sandoval --- 99-grub-mkconfig.install | 10 ++++++++-- grub2.spec | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) mode change 100644 => 100755 99-grub-mkconfig.install diff --git a/99-grub-mkconfig.install b/99-grub-mkconfig.install old mode 100644 new mode 100755 index b14fc82a..57e2cd21 --- a/99-grub-mkconfig.install +++ b/99-grub-mkconfig.install @@ -9,16 +9,22 @@ ARCH=$(uname -m) [[ -f /etc/default/grub ]] && . /etc/default/grub # Can't assume a BLS capable bootloader on ppc64 -if [[ x$GRUB_ENABLE_BLSCFG != xfalse && +if [[ x$GRUB_ENABLE_BLSCFG = xtrue && $ARCH != "ppc64" && $ARCH != "ppc64le" ]]; then exit 0 fi COMMAND="$1" +grub_cfg=/boot/grub2/grub.cfg +if mountpoint -q /boot/efi; then + os_name=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/' -e 's/\"//g') + grub_cfg=/boot/efi/EFI/$os_name/grub.cfg +fi + case "$COMMAND" in add|remove) - grub2-mkconfig --no-grubenv-update -o /boot/grub2/grub.cfg >& /dev/null + grub2-mkconfig --no-grubenv-update -o $grub_cfg >& /dev/null ;; *) ;; diff --git a/grub2.spec b/grub2.spec index fbad1422..7b894341 100644 --- a/grub2.spec +++ b/grub2.spec @@ -7,7 +7,7 @@ Name: grub2 Epoch: 1 Version: 2.02 -Release: 158%{?dist} +Release: 159%{?dist} Summary: Bootloader with support for Linux, Multiboot and more Group: System Environment/Base License: GPLv3+ @@ -523,6 +523,10 @@ fi %endif %changelog +* Tue Nov 12 2024 Leo Sandoval - 2.02-159 +- Fix default behavior when GRUB_ENABLE_BLSCFG is not present +- Resolves: #RHEL-4319 + * Thu Sep 19 2024 Leo Sandoval - 2.02-158 - grub-mkconfig.in: turn off executable owner bit - Resolves: #RHEL-58835