Execute grub2-switch-to-blscfg script in %posttrans instead of %post

The GRUB configuration is switched to BLS using the grub2-switch-to-blscfg
script, which is installed by the grub2-tools package. Among other things,
the script copies the blscfg module from the /usr/lib/grub/$arch directory
to /boot/grub2/$arch.

This is done because for non-UEFI installs (i386-pc and powerpc-ieee1275)
the GRUB core and modules aren't updated on package upgrade, so the blscfg
module won't be the latest that contains the current BLS support.

But the grub2-switch-to-blscfg script is currently executed in grub2-tools
%post scritplet, which means that if the grub2-tools package is installed
before the grub2-pc-modules package (that installs the blscfg module), the
grub2-switch-to-blscfg script won't copy the latest version of the module.

This will make systems to fail to populate the GRUB menu, since its config
will already be migrated to BLS but the blscfg module won't be the latest.

So to make sure that the latest blscfg module is copied regardless of the
grub2-tools and grub2-pc-modules packages install order, run the switch
script in a grub2-tools %posttrans so it's executed at the end of the RPM
transaction once all the packages have been installed.

Resolves: rhbz#1652806

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2019-04-15 10:19:18 +02:00
parent 30b139ceba
commit 173fb18386
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
1 changed files with 2 additions and 2 deletions

View File

@ -276,9 +276,9 @@ elif [ -f /etc/grub.d/01_users ] && \
fi
fi
%post tools
%posttrans tools
if [ "$1" = 2 ]; then
if [ -f /etc/default/grub ]; then
! grep -q '^GRUB_ENABLE_BLSCFG=false' /etc/default/grub && \
/sbin/grub2-switch-to-blscfg --backup-suffix=.rpmsave &>/dev/null || :
fi