diff --git a/20-grub.install b/20-grub.install index 30e5d5b..b82dffa 100755 --- a/20-grub.install +++ b/20-grub.install @@ -153,7 +153,7 @@ case "$COMMAND" in fi fi if [ -n "$NEWDEFAULT" ]; then - grub2-editenv - set "saved_entry=${NEWDEFAULT}" + grub2-editenv - set "tmp_saved_entry=${NEWDEFAULT}" fi # this probably isn't the best place to do this, but it will do for now. diff --git a/95-set-boot-entry.install b/95-set-boot-entry.install new file mode 100755 index 0000000..9f92f9f --- /dev/null +++ b/95-set-boot-entry.install @@ -0,0 +1,44 @@ +#!/bin/bash + +[[ -f /etc/default/grub ]] && . /etc/default/grub +[[ -f /etc/os-release ]] && . /etc/os-release + +COMMAND="$1" +KERNEL_VERSION="$2" +BOOT_DIR_ABS="$3" +KERNEL_IMAGE="$4" + +case "$COMMAND" in + add) + if [[ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]] || [[ ! -f /sbin/new-kernel-pkg ]]; then + entry=$(grub2-editenv list | grep tmp_saved_entry) + if [ -n "$entry" ]; then + BLS_ID=${entry##tmp_saved_entry=} + BLS_DIR="/boot/loader/entries" + BLS_TARGET="${BLS_DIR}/${BLS_ID}.conf" + + LINUX="$(grep '^linux[ \t]' "${BLS_TARGET}" | sed -e 's,^linux[ \t]*,,' | awk '{print $1}')" + INITRD="$(grep '^initrd[ \t]' "${BLS_TARGET}" | sed -e 's,^initrd[ \t]*,,' | awk '{print $1}')" + + ROOTPREFIX="" + [ -z "$(grub2-mkrelpath /boot)" ] && ROOTPREFIX="/boot" + + if [ -e "${ROOTPREFIX}${LINUX}" -a -n "${INITRD}" ]; then + if [ ! -e "${ROOTPREFIX}${INITRD}" ]; then + echo "Error: ${ROOTPREFIX}${INITRD} not found." + exit 1 + fi + if ! lsinitrd ${ROOTPREFIX}${INITRD} > /dev/null; then + echo "Error: ${ROOTPREFIX}${INITRD} appears to be corrupt." + exit 1 + fi + fi + + grub2-editenv - unset "tmp_saved_entry" + grub2-editenv - set "saved_entry=$BLS_ID" + fi + fi + ;; + *) + ;; +esac diff --git a/grub2.spec b/grub2.spec index 6f395d9..239550e 100644 --- a/grub2.spec +++ b/grub2.spec @@ -16,7 +16,7 @@ Name: grub2 Epoch: 1 Version: 2.06 -Release: 129%{?dist} +Release: 130%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -36,6 +36,7 @@ Source11: grub.patches Source12: sbat.csv.in Source13: gen_grub_cfgstub Source14: sbat.ppc.csv +Source15: 95-set-boot-entry.install %include %{SOURCE1} @@ -264,6 +265,7 @@ rm -vf ${RPM_BUILD_ROOT}/%{_sbindir}/%{name}-macbless # Install kernel-install scripts install -d -m 0755 %{buildroot}%{_prefix}/lib/kernel/install.d/ install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE10} +install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE15} install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE3} install -d -m 0755 %{buildroot}%{_sysconfdir}/kernel/install.d/ # Install systemd user service to set the boot_success flag @@ -379,6 +381,7 @@ fi %dir %{_datarootdir}/grub/ %attr(0700,root,root) %dir %{_sysconfdir}/grub.d %{_prefix}/lib/kernel/install.d/20-grub.install +%{_prefix}/lib/kernel/install.d/95-set-boot-entry.install %{_prefix}/lib/kernel/install.d/99-grub-mkconfig.install %dir %{_datarootdir}/grub %exclude %{_datarootdir}/grub/* @@ -543,6 +546,10 @@ fi %endif %changelog +* Wed Jul 01 2026 Josue Hernandez 2.06-130 +- Wait for initrmafs and kernel to be installed before set default kernel +- Resolves: #RHEL-191464 + * Thu Jun 18 2026 Nicolas Frayer 2.06-129 - ieee1275/powerpc: implements fibre channel discovery for ofpathname - Resolves: #RHEL-53369