public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/grub2] f44: spec: move all pending EFI logic from common to EFI package
@ 2026-06-15 18:52 Leo Sandoval
  0 siblings, 0 replies; only message in thread
From: Leo Sandoval @ 2026-06-15 18:52 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/grub2
            Branch : f44
            Commit : 74d3caf030b6e2bfd9ae2cb4cd9c174550c7071b
            Author : Leo Sandoval <lsandova@redhat.com>
            Date   : 2026-06-12T12:30:12-06:00
            Stats  : +35/-26 in 1 file(s)
            URL    : https://src.fedoraproject.org/rpms/grub2/c/74d3caf030b6e2bfd9ae2cb4cd9c174550c7071b?branch=f44

            Log:
            spec: move all pending EFI logic from common to EFI package

Commit f61aeed  (Move the EFI config's stub generation into EFI
posttrans) moved just the stub script generator but not the rest of
the logic related to EFI. Without this change, the EFI config stub was
completely regenerated on every GRUB update, causing cmds to be lost,
e.g. cmds to allow decrypt /boot partition.

Related: #2482790

Signed-off-by: Leo Sandoval <lsandova@redhat.com>

---
diff --git a/grub2.spec b/grub2.spec
index 156f150..c498232 100644
--- a/grub2.spec
+++ b/grub2.spec
@@ -17,7 +17,7 @@
 Name:		grub2
 Epoch:		1
 Version:	2.12
-Release:	60%{?dist}
+Release:	61%{?dist}
 Summary:	Bootloader with support for Linux, Multiboot and more
 License:	GPL-3.0-or-later
 URL:		http://www.gnu.org/software/grub/
@@ -387,49 +387,54 @@ fi
 %posttrans common
 set -eu
 
-EFI_HOME=%{grub_efi_dir}
-GRUB_HOME=/boot/grub2
-ESP_PATH=/boot/efi
-
-if ! mountpoint -q ${ESP_PATH}; then
-    exit 0 # no ESP mounted, nothing to do
-fi
+GRUB_DIR=/boot/grub2
 
-if test ! -f ${GRUB_HOME}/grub.cfg; then
+if test ! -f ${GRUB_DIR}/grub.cfg; then
     # there's no config in GRUB home, create one
-    grub2-mkconfig -o ${GRUB_HOME}/grub.cfg
+    grub2-mkconfig -o ${GRUB_DIR}/grub.cfg
 else
-    GRUB_CFG_MODE=$(stat --format="%a" ${GRUB_HOME}/grub.cfg)
+    GRUB_CFG_MODE=$(stat --format="%a" ${GRUB_DIR}/grub.cfg)
     if ! test "${GRUB_CFG_MODE}" = "600"; then
         # when upgrading from <=2.06-126 to newer versions, the grub config stub
         # may have different mode than 0600, so set the latter if this is the case
-        chmod 0600 ${GRUB_HOME}/grub.cfg
-    fi
-fi
-
-if test -f ${EFI_HOME}/grub.cfg; then
-    if (((grep -q "configfile" ${EFI_HOME}/grub.cfg && grep -q "root-dev-only" ${EFI_HOME}/grub.cfg) || grep -q "source" ${EFI_HOME}/grub.cfg) && ! grep -q "# It is automatically generated by grub2-mkconfig using templates" ${EFI_HOME}/grub.cfg); then
-        exit 0 #Already unified
+        chmod 0600 ${GRUB_DIR}/grub.cfg
     fi
 fi
 
-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
-
 %if 0%{with_efi_arch}
 %posttrans efi-%{efiarch}
 set -eu
 
-# Create the stub config
-gen_grub_cfgstub /boot/grub2 %{grub_efi_dir} || :
+GRUB_DIR=/boot/grub2
+EFI_DIR=%{grub_efi_dir}
+EFI_ESP_DIR=%{efi_esp_dir}
+ESP_PATH=/boot/efi
+
+# Create the EFI stub config in case is not present and with the corresponding cmds
+if test -f ${EFI_DIR}/grub.cfg; then
+    if (((grep -q "configfile" ${EFI_DIR}/grub.cfg && grep -q "root-dev-only" ${EFI_DIR}/grub.cfg) || grep -q "source" ${EFI_DIR}/grub.cfg) && ! grep -q "# It is automatically generated by grub2-mkconfig using templates" ${EFI_DIR}/grub.cfg); then
+        : # Already unified
+    else
+        gen_grub_cfgstub ${GRUB_DIR} ${EFI_DIR} || :
+    fi
+else
+    gen_grub_cfgstub ${GRUB_DIR} ${EFI_DIR} || :
+fi
 
 # On image mode, bootupd takes care of installing bootloader updates to the ESP
 if [[ ! -e "/run/ostree-booted" ]]; then
-    cp -a %{grub_efi_dir}/. %{efi_esp_dir} || :
+   # Check if /boot/efi is actually mounted before cp
+   if ! mountpoint -q ${ESP_PATH}; then
+       : # no ESP mounted, nothing to do
+   else
+     cp -a ${EFI_DIR}/. ${EFI_ESP_DIR} || :
+   fi
 fi
 
+if test -f ${EFI_DIR}/grubenv; then
+    cp -a ${EFI_DIR}/grubenv ${EFI_DIR}/grubenv.rpmsave
+    mv --force ${EFI_DIR}/grubenv ${GRUB_DIR}/grubenv
+fi
 %endif
 
 %files common -f grub.lang
@@ -608,6 +613,10 @@ fi
 %endif
 
 %changelog
+* Mon Jun 08 2026 Leo Sandoval <lsandova@redhat.com> - 2.12-61
+- spec: move all pending EFI logic from common to EFI package
+- Related: #2482790
+
 * Fri Jun 05 2026 Rolv Apneseth <rapneset@redhat.com> - 2.12-60
 - mdraid: fix metadata 1.0 detection in userspace utilities on IEEE1275
 - grub-install: use search.fs_uuid for RAID1 on IEEE1275

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-15 18:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-15 18:52 [rpms/grub2] f44: spec: move all pending EFI logic from common to EFI package Leo Sandoval

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox