From 27273a8d31de8a8c7e66275ba78869a2a765baf4 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 15 Jun 2021 15:50:14 +0200 Subject: [PATCH] Only try to generate a config if the ESP is mounted The posttran scriptlet attempts to generate a GRUB configuration if there isn't one in the EFI System Partition. But this leads to a failure if the grub2 package is installed in a container. To avoid this issue, only attempt to generate a GRUB config if the ESP is mounted in /boot/efi. Signed-off-by: Javier Martinez Canillas --- grub2.spec | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/grub2.spec b/grub2.spec index e9cfcf6..10fe8e4 100644 --- a/grub2.spec +++ b/grub2.spec @@ -14,7 +14,7 @@ Name: grub2 Epoch: 1 Version: 2.06 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -81,6 +81,7 @@ hardware devices.\ Summary: grub2 common layout BuildArch: noarch Conflicts: grubby < 8.40-18 +Requires(post): util-linux %description common This package provides some directories which are required by various grub2 @@ -352,9 +353,15 @@ set -eu EFI_HOME=%{efi_esp_dir} GRUB_HOME=/boot/grub2 +ESP_PATH=/boot/efi + +if ! mountpoint -q ${ESP_PATH}; then + exit 0 # no ESP mounted, nothing to do +fi if test ! -f ${EFI_HOME}/grub.cfg; then - grub2-mkconfig -o ${EFI_HOME}/grub.cfg + # there's no config in ESP, create one + grub2-mkconfig -o ${EFI_HOME}/grub.cfg fi if grep -q "configfile" ${EFI_HOME}/grub.cfg; then @@ -555,6 +562,9 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %endif %changelog +* Tue Jun 15 2021 Javier Martinez Canillas - 2.06-2 +- Only try to generate a config if the ESP is mounted + * Mon Jun 14 2021 Javier Martinez Canillas - 2.06-1 - Update to 2.06 final release and ton of fixes