7c2bab5
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
7c2bab5
From: Javier Martinez Canillas <javierm@redhat.com>
7c2bab5
Date: Thu, 26 Mar 2020 15:08:30 +0100
7c2bab5
Subject: [PATCH] grub-switch-to-blscfg: Update grub2 binary in ESP for OSTree
7c2bab5
 systems
7c2bab5
7c2bab5
The grub2 EFI binary in the ESP isn't updated as a part of an OSTree update
7c2bab5
transaction. So let's make the script to update this and also create a file
7c2bab5
to indicate that the installed version has support for the blscfg module.
7c2bab5
7c2bab5
Related: rhbz#1751272
7c2bab5
7c2bab5
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
7c2bab5
---
7c2bab5
 util/grub-switch-to-blscfg.in | 9 +++++++++
7c2bab5
 1 file changed, 9 insertions(+)
7c2bab5
7c2bab5
diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in
7c2bab5
index 49b3985fadb..a05a8d98554 100644
7c2bab5
--- a/util/grub-switch-to-blscfg.in
7c2bab5
+++ b/util/grub-switch-to-blscfg.in
7c2bab5
@@ -266,6 +266,15 @@ copy_bls() {
7c2bab5
     fi
7c2bab5
 }
7c2bab5
 
7c2bab5
+# The grub2 EFI binary is not copied to the ESP as a part of an ostree
7c2bab5
+# transaction. Make sure a grub2 version with BLS support is installed.
7c2bab5
+if test -f /run/ostree-booted && test -d /sys/firmware/efi/efivars/; then
7c2bab5
+    grub_binary="$(find /usr/lib/ostree-boot/efi/EFI/${EFIDIR}/ -name grub*.efi)"
7c2bab5
+    cp ${grub_binary} ${grubdir} || exit 1
7c2bab5
+    # Create a hidden file to indicate that grub2 now has BLS support.
7c2bab5
+    touch /boot/grub2/.grub2-blscfg-supported
7c2bab5
+fi
7c2bab5
+
7c2bab5
 GENERATE=0
7c2bab5
 if grep '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" \
7c2bab5
         | grep -vq '^GRUB_ENABLE_BLSCFG="*true"*\s*$' ; then