xbps-triggers: add initramfs-regenerate trigger
This abstracts away the `dracut -f -q --regenerate-all` that appears in nvidia and zfs packages, allowing users to disable global regeneration, use dracut (by default, to preserve existing behavior) or mkinitcpio. Eventually, this can be extended with initramfs-tools if we like. Closes: #31403
This commit is contained in:
parent
326f8ead70
commit
876b6ed3a4
30
Manual.md
30
Manual.md
|
@ -57,6 +57,7 @@ packages for XBPS, the `Void Linux` native packaging system.
|
||||||
* [gtk3-immodules](#triggers_gtk3_immodules)
|
* [gtk3-immodules](#triggers_gtk3_immodules)
|
||||||
* [hwdb.d-dir](#triggers_hwdb.d_dir)
|
* [hwdb.d-dir](#triggers_hwdb.d_dir)
|
||||||
* [info-files](#triggers_info_files)
|
* [info-files](#triggers_info_files)
|
||||||
|
* [initramfs-regenerate](#triggers_initramfs_regenerate)
|
||||||
* [kernel-hooks](#triggers_kernel_hooks)
|
* [kernel-hooks](#triggers_kernel_hooks)
|
||||||
* [mimedb](#triggers_mimedb)
|
* [mimedb](#triggers_mimedb)
|
||||||
* [mkdirs](#triggers_mkdirs)
|
* [mkdirs](#triggers_mkdirs)
|
||||||
|
@ -1881,6 +1882,35 @@ registry located at `usr/share/info`.
|
||||||
If it is running under another architecture it tries to use the host's `install-info`
|
If it is running under another architecture it tries to use the host's `install-info`
|
||||||
utility.
|
utility.
|
||||||
|
|
||||||
|
<a id="triggers_initramfs_regenerate"></a>
|
||||||
|
### initramfs-regenerate
|
||||||
|
|
||||||
|
The initramfs-regenerate trigger will trigger the regeneration of all kernel
|
||||||
|
initramfs images after package installation or removal. The trigger must be
|
||||||
|
manually requested.
|
||||||
|
|
||||||
|
This hook is probably most useful for DKMS packages because it will provide a
|
||||||
|
means to include newly compiled kernel modules in initramfs images for all
|
||||||
|
currently available kernels. When used in a DKMS package, it is recommended to
|
||||||
|
manually include the `dkms` trigger *before* the `initramfs-regenerate` trigger
|
||||||
|
using, for example,
|
||||||
|
|
||||||
|
```
|
||||||
|
triggers="dkms initramfs-regenerate"
|
||||||
|
```
|
||||||
|
|
||||||
|
Although `xbps-src` will automatically include the `dkms` trigger whenever
|
||||||
|
`dkms_modules` is installed, the automatic addition will come *after*
|
||||||
|
`initramfs-regenerate`, which will cause initramfs images to be recreated
|
||||||
|
before the modules are compiled.
|
||||||
|
|
||||||
|
By default, the trigger uses `dracut --regenerate-all` to recreate initramfs
|
||||||
|
images. If `/etc/defalt/initramfs-regenerate` exists and defines
|
||||||
|
`INITRAMFS_GENERATOR=mkinitcpio`, the trigger will instead use `mkinitcpio` and
|
||||||
|
loop over all kernel versions for which modules appear to be installed.
|
||||||
|
Alternatively, setting `INITRAMFS_GENERATOR=none` will disable image
|
||||||
|
regeneration entirely.
|
||||||
|
|
||||||
<a id="triggers_kernel_hooks"></a>
|
<a id="triggers_kernel_hooks"></a>
|
||||||
#### kernel-hooks
|
#### kernel-hooks
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Trigger to regenerate an initramfs for every kernel with a module directory
|
||||||
|
# in lib/modules on package post-install.
|
||||||
|
#
|
||||||
|
# To change the initramfs generator, edit or create the file
|
||||||
|
# etc/default/initramfs-regenerate and add or change the line
|
||||||
|
#
|
||||||
|
# INITRAMFS_GENERATOR=<generator>
|
||||||
|
#
|
||||||
|
# where <generator> is one of "dracut", "mkinitcpio" or "none". By default, a
|
||||||
|
# value of "dracut" is assumed.
|
||||||
|
#
|
||||||
|
# Arguments: $ACTION = [run/targets]
|
||||||
|
# $TARGET = [post-install/post-remove]
|
||||||
|
# $PKGNAME
|
||||||
|
# $VERSION
|
||||||
|
# $UPDATE = [yes/no]
|
||||||
|
|
||||||
|
ACTION="$1"
|
||||||
|
TARGET="$2"
|
||||||
|
PKGNAME="$3"
|
||||||
|
VERSION="$4"
|
||||||
|
UPDATE="$5"
|
||||||
|
|
||||||
|
export PATH="usr/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
|
||||||
|
case "$ACTION" in
|
||||||
|
targets)
|
||||||
|
echo "post-install post-remove"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
run)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Read the configuration, if it exists
|
||||||
|
[ -f etc/default/initramfs-regenerate ] && . etc/default/initramfs-regenerate
|
||||||
|
|
||||||
|
# dracut explicitly sets umask 0077, other generators may not
|
||||||
|
umask 0077
|
||||||
|
|
||||||
|
case "${INITRAMFS_GENERATOR:-dracut}" in
|
||||||
|
dracut)
|
||||||
|
if command -v dracut >/dev/null 2>&1; then
|
||||||
|
echo "Regenerating initramfs with dracut"
|
||||||
|
dracut -f -q --regenerate-all
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
mkinitcpio)
|
||||||
|
if command -v mkinitcpio >dev/null 2>&1; then
|
||||||
|
echo "Regenerating initramfs with mkinitcpio"
|
||||||
|
# Regenerate images for every kernel version with modules
|
||||||
|
for kdir in usr/lib/modules/*; do
|
||||||
|
[ -d "${kdir}/kernel" ] || continue
|
||||||
|
kver="${kdir##*/}"
|
||||||
|
mkinitcpio -g "boot/initramfs-${kver}.img" -k "${kver}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
none)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "unrecognized INITRAMFS_GENERATOR for initramfs-regenerate hook"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
|
@ -1,6 +1,6 @@
|
||||||
# Template file for 'xbps-triggers'
|
# Template file for 'xbps-triggers'
|
||||||
pkgname=xbps-triggers
|
pkgname=xbps-triggers
|
||||||
version=0.120
|
version=0.121
|
||||||
revision=1
|
revision=1
|
||||||
bootstrap=yes
|
bootstrap=yes
|
||||||
short_desc="XBPS triggers for Void Linux"
|
short_desc="XBPS triggers for Void Linux"
|
||||||
|
|
Loading…
Reference in New Issue