From 931f4f0364d09538b54651ab257ecc13c06ba095 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Thu, 25 Feb 2021 18:17:46 +0100 Subject: [PATCH] Don't attempt to unify if there is no grub.cfg on EFI If there is no grub config, for example when installing the system via anaconda, there is no need to attempt a grub configuration unification. It will indeed actually break because it will try to copy a non-existent file. Resolves: rhbz#1933085 --- grub2.spec | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/grub2.spec b/grub2.spec index 4d6d8b5..3e151b1 100644 --- a/grub2.spec +++ b/grub2.spec @@ -350,6 +350,10 @@ set -eu EFI_HOME=/boot/efi/EFI/fedora GRUB_HOME=/boot/grub2 +if test ! -f ${EFI_HOME}/grub.cfg; then + exit 0 # nothing to unify, nothing to do +fi + if grep -q "configfile" ${EFI_HOME}/grub.cfg; then exit 0 # already unified, nothing to do fi @@ -366,11 +370,11 @@ export \$prefix configfile \$prefix/grub.cfg EOF -cp -av ${EFI_HOME}/grubenv ${EFI_HOME}/grubenv.rpmsave +cp -a ${EFI_HOME}/grubenv ${EFI_HOME}/grubenv.rpmsave mv --force ${EFI_HOME}/grubenv ${GRUB_HOME}/grubenv -cp -av ${EFI_HOME}/grub.cfg ${EFI_HOME}/grub.cfg.rpmsave -cp -av ${EFI_HOME}/grub.cfg ${GRUB_HOME}/ +cp -a ${EFI_HOME}/grub.cfg ${EFI_HOME}/grub.cfg.rpmsave +cp -a ${EFI_HOME}/grub.cfg ${GRUB_HOME}/ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %files common -f grub.lang