public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Leo Sandoval <lsandova@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/grub2] rawhide: spec: move all pending EFI logic from common to EFI package
Date: Mon, 15 Jun 2026 20:45:26 GMT	[thread overview]
Message-ID: <178155632682.1.16335617934516146191.rpms-grub2-56915301905b@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/grub2
            Branch : rawhide
            Commit : 56915301905ba74f6452cfb5f43cde6a3cf87518
            Author : Leo Sandoval <lsandova@redhat.com>
            Date   : 2026-06-15T12:55:15-06:00
            Stats  : +37/-26 in 1 file(s)
            URL    : https://src.fedoraproject.org/rpms/grub2/c/56915301905ba74f6452cfb5f43cde6a3cf87518?branch=rawhide

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

Commit 3212759d (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 24c2d89..e6a71f2 100644
--- a/grub2.spec
+++ b/grub2.spec
@@ -17,7 +17,7 @@
 Name:		grub2
 Epoch:		1
 Version:	2.12
-Release:	63%{?dist}
+Release:	64%{?dist}
 Summary:	Bootloader with support for Linux, Multiboot and more
 License:	GPL-3.0-or-later
 URL:		http://www.gnu.org/software/grub/
@@ -400,47 +400,53 @@ 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 -d --preserve=all %{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
 
@@ -621,6 +627,11 @@ fi
 %endif
 
 %changelog
+=======
+* Mon Jun 15 2026 Leo Sandoval <lsandova@redhat.com> - 2.12-64
+- spec: move all pending EFI logic from common to EFI package
+- Related: #2482790
+
 * Mon Jun 15 2026 Rolv Apneseth <rapneset@redhat.com> - 2.12-63
 - mdraid: fix metadata 1.0 detection in userspace utilities on IEEE1275
 - grub-install: use search.fs_uuid for RAID1 on IEEE1275

                 reply	other threads:[~2026-06-15 20:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178155632682.1.16335617934516146191.rpms-grub2-56915301905b@fedoraproject.org \
    --to=lsandova@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox