openSUSE:Update Bootloader RPM Macros
The update-bootloader-rpm-macros package is used to provide macros for rpm scripts in order to improve the efficiency by leveraging the %posttrans to perform the update at end of transaction instead in each and every package that accumulates time doing the same thing. Also the macros help in making the life easier by hiding the complexity and the result is also less error prone.
You should add :
as Build Requires.
to ensure the needed dependencies are added to your package
Add following macros to your rpm scripts if you want to (re)install any bootloader, that is it will not check currently installed loader type before running update-bootloader or similar agents to update it.
%post %update_bootloader_reinit_post %posttrans %update_bootloader_posttrans
Add following macros to your rpm scripts if you want to (re)install only specified bootloaders, that is it will check currently installed loader type against the specified one, and will only update if they matches.
For example, this will make sure only to update grub2 boot loader
%post %update_bootloader_check_type_reinit_post grub2 %posttrans %update_bootloader_posttrans
You could also specify more than one bootloader type
%post %update_bootloader_check_type_reinit_post grub2 grub2-efi %posttrans %update_bootloader_posttrans
Note, you don't have to bother with updating bootloader config to line up with updated bootloader image, the macro will do that for you to ensure compatibility between version of config and binary.
Update Bootloader Config
Similar to install bootloader, you could also update bootloader config in your rpm script. Add following macro if you want to update any bootloader config.
%post %update_bootloader_refresh_post %posttrans %update_bootloader_posttrans
The following rpm script will update grub2 and grub2-efi config
%post %update_bootloader_check_type_refresh_post grub2 grub2-efi %posttrans %update_bootloader_posttrans