a3bfe3
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
a3bfe3
From: Javier Martinez Canillas <javierm@redhat.com>
a3bfe3
Date: Fri, 28 Sep 2018 10:35:38 +0200
a3bfe3
Subject: [PATCH] grub-switch-to-blscfg: copy blscfg module for legacy BIOS and
a3bfe3
 ppc ieee1275
a3bfe3
a3bfe3
On platforms that load the blscfg module the latest version should be used,
a3bfe3
so copy the module to the boot directory to make sure that the grub2 kernel
a3bfe3
will load the latest version of the BLS parsing code.
a3bfe3
a3bfe3
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
a3bfe3
---
a3bfe3
 util/grub-switch-to-blscfg.in | 13 ++++++++++++-
a3bfe3
 1 file changed, 12 insertions(+), 1 deletion(-)
a3bfe3
a3bfe3
diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in
a3bfe3
index 9cf64f8e725..1c6bd1882a7 100644
a3bfe3
--- a/util/grub-switch-to-blscfg.in
a3bfe3
+++ b/util/grub-switch-to-blscfg.in
a3bfe3
@@ -53,6 +53,8 @@ blsdir=`echo "/@bootdirname@/loader/entries" | sed 's,//*,/,g'`
a3bfe3
 
a3bfe3
 backupsuffix=.bak
a3bfe3
 
a3bfe3
+arch="$(uname -m)"
a3bfe3
+
a3bfe3
 export TEXTDOMAIN=@PACKAGE@
a3bfe3
 export TEXTDOMAINDIR="@localedir@"
a3bfe3
 
a3bfe3
@@ -248,7 +250,6 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
a3bfe3
     fi
a3bfe3
 
a3bfe3
     if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then
a3bfe3
-        arch="$(uname -m)"
a3bfe3
         bls_debug="$(echo ${bls_target} | sed -e "s/\.${arch}/-debug.${arch}/")"
a3bfe3
         cp -aT  "${bls_target}" "${bls_debug}"
a3bfe3
         title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')"
a3bfe3
@@ -282,6 +283,16 @@ elif ! grep -q '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" ; then
a3bfe3
 fi
a3bfe3
 
a3bfe3
 if [ "${GENERATE}" -eq 1 ] ; then
a3bfe3
+    if [ $arch = "x86_64" ] && [ ! -d /sys/firmware/efi ]; then
a3bfe3
+	if ! cp ${prefix}/lib/grub//i386-pc/blscfg.mod ${grubdir}/i386-pc/ ; then
a3bfe3
+	    exit 1
a3bfe3
+	fi
a3bfe3
+    elif [ $arch = "ppc64" -o $arch = "ppc64le" ] && [ ! -d /sys/firmware/opal ]; then
a3bfe3
+	if ! cp ${prefix}/lib/grub/powerpc-ieee1275/blscfg.mod ${grubdir}/powerpc-ieee1275/ ; then
a3bfe3
+	    exit 1
a3bfe3
+	fi
a3bfe3
+    fi
a3bfe3
+
a3bfe3
     cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}"
a3bfe3
     if ! grub2-mkconfig -o "${GRUB_CONFIG_FILE}" ; then
a3bfe3
         cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}"