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