From f63b7984e5919d4c2d0bf90e4ed39783d33ad3f9 Mon Sep 17 00:00:00 2001 From: Nicolas Frayer Date: Tue, 29 Jul 2025 18:04:03 +0200 Subject: [PATCH] spec/posttrans: move grub config stub creation out of spec Resolves: #RHEL-69944 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 966c079..c2d0833 100755 --- a/grub.macros +++ b/grub.macros @@ -522,6 +522,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/%{name}/fonts/unicode.pf2 \ ${RPM_BUILD_ROOT}/%{_bindir}/%{name}-editenv \\\ @@ -633,6 +635,7 @@ ln -s ../boot/%{name}/grub.cfg \\\ %attr(0700,root,root) %verify(not mtime) %{efi_esp_boot}/BOOTARM.EFI \ %endif \ %attr(0700,root,root)/boot/%{name}/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/%{name}/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 2fedb03..f8c4883 100644 --- a/grub2.spec +++ b/grub2.spec @@ -16,7 +16,7 @@ Name: grub2 Epoch: 1 Version: 2.06 -Release: 110%{?dist} +Release: 111%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -34,6 +34,7 @@ Source9: strtoull_test.c Source10: 20-grub.install Source11: grub.patches Source12: sbat.csv.in +Source13: gen_grub_cfgstub %include %{SOURCE1} @@ -361,23 +362,13 @@ if test -f ${EFI_HOME}/grub.cfg; then fi # create a stub grub2 config in EFI -BOOT_UUID=$(%{name}-probe --target=fs_uuid ${GRUB_HOME}) -GRUB_DIR=$(%{name}-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/ @@ -547,6 +538,10 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %endif %changelog +* Tue Jul 29 2025 Nicolas Frayer 2.06-111 +- spec/posttrans: move grub config stub creation out of spec +- Resolves: #RHEL-69944 + * Fri Jun 6 2025 Nicolas Frayer - 2.06-110 - osdep/linux/getroot: Detect DDF container similar to IMSM - Resolves: #RHEL-44336