1
0
Fork 0
mirror of https://github.com/xHyroM/void-packages.git synced 2024-12-23 12:41:05 +01:00
void-packages/srcpkgs/xbps-triggers/files/initramfs-regenerate

58 lines
1.4 KiB
Text
Raw Normal View History

2024-03-30 14:09:59 +01:00
#!/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
# Prefer the new alternatives-based initramfs hooks
HOOK="etc/kernel.d/post-install/20-initramfs"
if [ ! -x "${HOOK}" ]; then
# Otherwise, use legacy trigger behavior to find a preferred hook
[ -f etc/default/initramfs-regenerate ] && . etc/default/initramfs-regenerate
HOOK="etc/kernel.d/post-install/20-${INITRAMFS_GENERATOR:-dracut}"
[ -x "${HOOK}" ] || exit 0
fi
echo "Regenerating initramfs images using kernel hook ${HOOK##*/}"
# Regenerate images for every kernel version with modules
for kdir in usr/lib/modules/*; do
[ -d "${kdir}/kernel" ] || continue
kver="${kdir##*/}"
"${HOOK}" "${PKGNAME}" "${kver}"
done
exit 0