From 9d0f911af62979d8f7f928d447bf0683bf8ad3d4 Mon Sep 17 00:00:00 2001 From: Nicolas Frayer Date: Tue, 29 Jul 2025 11:10:35 +0200 Subject: [PATCH] spec/posttrans: move grub config stub creation out of spec Resolves: #RHEL-69943 Signed-off-by: Nicolas Frayer --- gen_grub_cfgstub | 29 +++++++++++++++++++++++++++++ grub.macros | 3 +++ grub2.spec | 19 +++++++------------ 3 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 gen_grub_cfgstub diff --git a/gen_grub_cfgstub b/gen_grub_cfgstub new file mode 100644 index 0000000..c73ee53 --- /dev/null +++ b/gen_grub_cfgstub @@ -0,0 +1,29 @@ +#!/bin/sh +set -eu + +if [ $# -ne 2 ] + then + echo "Missing argument" + echo "Usage: script.sh GRUB_HOME EFI_HOME" + exit 1 +fi + +GRUB_HOME=$1 +EFI_HOME=$2 + +# create a stub grub2 config in EFI +BOOT_UUID=$(grub2-probe --target=fs_uuid "${GRUB_HOME}") +GRUB_DIR=$(grub2-mkrelpath "${GRUB_HOME}") + +echo "Generating grub stub config for drive " "${BOOT_UUID}" +echo "GRUB_DIR=" "${GRUB_DIR}" +echo "EFI_HOME=" "${EFI_HOME}" + +cat << EOF > "${EFI_HOME}"/grub.cfg.stb +search --no-floppy --root-dev-only --fs-uuid --set=dev ${BOOT_UUID} +set prefix=(\$dev)${GRUB_DIR} +export \$prefix +configfile \$prefix/grub.cfg +EOF + +mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg diff --git a/grub.macros b/grub.macros index ae0d1e0..685b897 100644 --- a/grub.macros +++ b/grub.macros @@ -597,6 +597,8 @@ install -m 700 %{3} $RPM_BUILD_ROOT%{efi_esp_dir}/%{3} \ %ifarch %{arm} \ install -D -m 700 %{2} $RPM_BUILD_ROOT%{efi_esp_boot}/BOOTARM.EFI \ %endif \ +install -D -m 700 %{SOURCE13} \\\ + ${RPM_BUILD_ROOT}/usr/bin/gen_grub_cfgstub \ install -D -m 700 unicode.pf2 \\\ ${RPM_BUILD_ROOT}/boot/grub2/fonts/unicode.pf2 \ ${RPM_BUILD_ROOT}/%{_bindir}/grub2-editenv \\\ @@ -720,6 +722,7 @@ ln -s ../boot/grub2/grub.cfg \\\ %attr(0700,root,root) %verify(not mtime) %{efi_esp_boot}/BOOTARM.EFI \ %endif \ %attr(0700,root,root)/boot/grub2/fonts \ +%attr(0700,root,root)/usr/bin/gen_grub_cfgstub \ %dir %attr(0700,root,root)/boot/loader/entries \ %ghost %config(noreplace) %attr(0600,root,root)/boot/grub2/grub.cfg \ %ghost %config(noreplace) %verify(not mtime) %attr(0700,root,root)%{efi_esp_dir}/grub.cfg \ diff --git a/grub2.spec b/grub2.spec index a762d10..63c827b 100644 --- a/grub2.spec +++ b/grub2.spec @@ -17,7 +17,7 @@ Name: grub2 Epoch: 1 Version: 2.12 -Release: 23%{?dist} +Release: 24%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPL-3.0-or-later URL: http://www.gnu.org/software/grub/ @@ -35,6 +35,7 @@ Source9: strtoull_test.c Source10: 20-grub.install Source11: grub.patches Source12: sbat.csv.in +Source13: gen_grub_cfgstub %include %{SOURCE1} @@ -395,23 +396,13 @@ if test -f ${EFI_HOME}/grub.cfg; then fi # create a stub grub2 config in EFI -BOOT_UUID=$(grub2-probe --target=fs_uuid ${GRUB_HOME}) -GRUB_DIR=$(grub2-mkrelpath ${GRUB_HOME}) - -cat << EOF > ${EFI_HOME}/grub.cfg.stb -search --no-floppy --root-dev-only --fs-uuid --set=dev ${BOOT_UUID} -set prefix=(\$dev)${GRUB_DIR} -export \$prefix -configfile \$prefix/grub.cfg -EOF +gen_grub_cfgstub $GRUB_HOME $EFI_HOME || : if test -f ${EFI_HOME}/grubenv; then cp -a ${EFI_HOME}/grubenv ${EFI_HOME}/grubenv.rpmsave mv --force ${EFI_HOME}/grubenv ${GRUB_HOME}/grubenv fi -mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg - %files common -f grub.lang %dir %{_libdir}/grub/ %dir %{_datarootdir}/grub/ @@ -583,6 +574,10 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %endif %changelog +* Tue Jul 29 2025 Nicolas Frayer 2.12-24 +- spec/posttrans: move grub config stub creation out of spec +- Resolves: #RHEL-69943 + * Tue Jul 15 2025 Leo Sandoval 2.12-23 - Set correctly the memory attributes for the kernel PE sections - Resolves: #RHEL-97086