Generate presets for existing kernels on package install/update
Currently the presets for a kernel are only generated when that kernel is
installed, but not when mkinitcpio
is installed. This adds support for
generating all presets for existing kernels when the mkinitcpio
package is
installed or updated. Existing presets are not over-written.
Considering mkinitcpio is responsible for managing the life-cycle of kernel preset files, I thought it would make sense that these should be generated for existing kernels during mkinitcpio install.
While this doesn't affect a wide audience, if a user switches from another initramfs generator, presets may not exist and new images won't be generated.
A summary of changes is as follows:
- Added a trigger in the libalpm install hook for the package itself (so preset generation isn't triggered for every firmware/dkms/etc).
- Move preset generation code from the first part of
install_kernel()
to its own function,install_preset()
. - Added a
generate_presets()
function to enumerate installed kernels and callinstall_preset()
for each. - Renamed function
process_preset()
toremove_preset()
for clarity.