From 209034da3790e0951cf137119fadc81df88b2a06 Mon Sep 17 00:00:00 2001
From: Peridot Bot <rockyautomation@rockylinux.org>
Date: Fri, 10 Jan 2025 19:55:32 +0000
Subject: [PATCH] import grubby-8.40-80.el10

---
 SOURCES/grubby-bls | 36 +++++++++++++++---------------------
 SPECS/grubby.spec  | 16 ++++++++++++++--
 2 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/SOURCES/grubby-bls b/SOURCES/grubby-bls
index ac82950..0116707 100755
--- a/SOURCES/grubby-bls
+++ b/SOURCES/grubby-bls
@@ -595,33 +595,27 @@ remove_var_prefix() {
 
 update_grubcfg()
 {
-    # Older ppc64le OPAL firmware (petitboot version < 1.8.0) don't have BLS support
-    # so grub2-mkconfig has to be run to generate a config with menuentry commands.
+    # Older ppc64le OPAL firmware don't have BLS support so grub2-mkconfig has to be run
+    # to generate a config with menuentry commands.
     if [ "${arch}" = "ppc64le" ] && [ -d /sys/firmware/opal ]; then
         RUN_MKCONFIG="true"
-        petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot"
-
-        if test -e ${petitboot_path}; then
-            read -r -d '' petitboot_version < ${petitboot_path}
-            petitboot_version="$(echo ${petitboot_version//v})"
-
-            if test -n ${petitboot_version}; then
-                major_version="$(echo ${petitboot_version} | cut -d . -f1)"
-                minor_version="$(echo ${petitboot_version} | cut -d . -f2)"
-
-                re='^[0-9]+$'
-                if [[ $major_version =~ $re ]] && [[ $minor_version =~ $re ]] &&
-                       ([[ ${major_version} -gt 1 ]] ||
-                            [[ ${major_version} -eq 1 &&
-                                 ${minor_version} -ge 8  ]]); then
-                    RUN_MKCONFIG="false"
-                fi
-            fi
+    fi
+
+    # PV and PVH Xen DomU guests boot with pygrub that doesn't have BLS support,
+    # also Xen Dom0 use the menuentries from 20_linux_xen and not the ones from
+    # 10_linux. So grub2-mkconfig has to run for both Xen Dom0 and DomU.
+    if [[ -e /sys/hypervisor/type ]] && grep -q "^xen$" /sys/hypervisor/type; then
+        if [ ! -e /sys/hypervisor/guest_type ] || ! grep -q "^HVM$" /sys/hypervisor/guest_type; then
+            RUN_MKCONFIG=true
         fi
     fi
 
     if [[ $RUN_MKCONFIG = "true" ]]; then
-        grub2-mkconfig --no-grubenv-update -o "${grub_config}" >& /dev/null
+        if [[ $bootloader = "zipl" ]]; then
+            zipl
+        else
+            grub2-mkconfig --no-grubenv-update -o "${grub_config}" &> /dev/null
+        fi
     fi
 }
 
diff --git a/SPECS/grubby.spec b/SPECS/grubby.spec
index 928a3b3..4c92a5a 100644
--- a/SPECS/grubby.spec
+++ b/SPECS/grubby.spec
@@ -3,7 +3,7 @@
 
 Name:                 grubby
 Version:              8.40
-Release:              77%{?dist}
+Release:              80%{?dist}
 Summary:              Command line tool for updating bootloader configs
 License:              GPL-2.0-or-later
 Source1:              grubby-bls
@@ -75,9 +75,21 @@ fi
 %{_mandir}/man8/grubby.8*
 
 %changelog
-* Thu Dec 12 2024 Release Engineering <releng@rockylinux.org> - 8.40-77
+* Fri Jan 10 2025 Release Engineering <releng@rockylinux.org> - 8.40-80
 - Add riscv64 device tree support
 
+* Fri Dec 06 2024 Leo Sandoval <lsandova@redhat.com> - 8.40-80
+- grubby-bls: on PPC systems, remove petiboot's version checks
+  Resolves: #RHEL-70194
+
+* Fri Dec 06 2024 Leo Sandoval <lsandova@redhat.com> - 8.40-79
+- grubby-bls: in s390* systems, run zipl on grub cfg update event
+  Resolves: #RHEL-36092
+
+* Thu Dec 05 2024 Leo Sandoval <lsandova@redhat.com> - 8.40-78
+- On grub cfg updates, run grub2-mkconfig for Xen systems
+  Resolves: #RHEL-70200
+
 * Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 8.40-77
 - Bump release for October 2024 mass rebuild:
   Resolves: RHEL-64018
-- 
GitLab