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 <mlewando@redhat.com>
Reviewed-by: Leo Sandoval <lsandova@redhat.com>
This commit is contained in:
Marta Lewandowska 2024-11-12 13:36:06 -06:00 committed by Leo Sandoval
parent 6baa4881ea
commit 5b940b00df
2 changed files with 13 additions and 3 deletions

10
99-grub-mkconfig.install Normal file → Executable file
View File

@ -9,16 +9,22 @@ ARCH=$(uname -m)
[[ -f /etc/default/grub ]] && . /etc/default/grub [[ -f /etc/default/grub ]] && . /etc/default/grub
# Can't assume a BLS capable bootloader on ppc64 # 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 $ARCH != "ppc64" && $ARCH != "ppc64le" ]]; then
exit 0 exit 0
fi fi
COMMAND="$1" 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 case "$COMMAND" in
add|remove) add|remove)
grub2-mkconfig --no-grubenv-update -o /boot/grub2/grub.cfg >& /dev/null grub2-mkconfig --no-grubenv-update -o $grub_cfg >& /dev/null
;; ;;
*) *)
;; ;;

View File

@ -7,7 +7,7 @@
Name: grub2 Name: grub2
Epoch: 1 Epoch: 1
Version: 2.02 Version: 2.02
Release: 158%{?dist} Release: 159%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more Summary: Bootloader with support for Linux, Multiboot and more
Group: System Environment/Base Group: System Environment/Base
License: GPLv3+ License: GPLv3+
@ -523,6 +523,10 @@ fi
%endif %endif
%changelog %changelog
* Tue Nov 12 2024 Leo Sandoval <lsandova@redhat.com> - 2.02-159
- Fix default behavior when GRUB_ENABLE_BLSCFG is not present
- Resolves: #RHEL-4319
* Thu Sep 19 2024 Leo Sandoval <lsandova@redhat.com> - 2.02-158 * Thu Sep 19 2024 Leo Sandoval <lsandova@redhat.com> - 2.02-158
- grub-mkconfig.in: turn off executable owner bit - grub-mkconfig.in: turn off executable owner bit
- Resolves: #RHEL-58835 - Resolves: #RHEL-58835