void-packages/triggers/initramfs-tools
Juan RP bbcc9c4b13 Add a trigger for creating/updating the initramfs.
It's activated at post-install time, and only if template uses:
triggers="initramfs-tools". Use it in the kernel package.

Also print a message when a trigger is being run.

--HG--
extra : convert_revision : 3f2a0c113ed523e4b09822665cf6d94e30b7d1e4
2009-03-12 11:50:46 +01:00

57 lines
1.3 KiB
Bash
Executable file

#!/bin/sh
#
# Runs update-initramfs(8) to create/update an initramfs for specified
# version (if the pkg that is triggering it) or for the currently
# installed kernel otherwise.
#
# Arguments: $1 = action [run/targets]
# $2 = target [post-install]
# $3 = pkgname
# $4 = version
#
trigger="initramfs-tools"
case "$1" in
targets)
echo "post-install"
;;
run)
[ ! -x ./usr/sbin/update-initramfs ] && exit 0
[ "$2" != "post-install" ] && exit 1
echo "Running $trigger trigger..."
if [ "$(pwd)" = "/" ]; then
mntproc_cmd="mount -t proc proc /proc"
umntproc_cmd="umount /proc"
mntsys_cmd="mount -t sysfs none /sys"
umntsys_cmd="umount /sys"
initramfs_cmd="update-initramfs"
else
mntproc_cmd="chroot . mount -t proc proc ./proc"
umntproc_cmd="chroot . umount ./proc"
mntsys_cmd="chroot . mount -t sysfs none ./sys"
umntsys_cmd="chroot . umount ./sys"
initramfs_cmd="chroot . update-initramfs"
fi
if [ "$3" = "kernel" -a ! -f ./var/lib/initramfs-tools/$4 ]; then
initramfs_cmd="$initramfs_cmd -c -k $4"
elif [ "$3" != "kernel" -o ! -f ./var/lib/initramfs-tools/$4 ]; then
initramfs_cmd="$initramfs_cmd -c -k $(xbps-pkgdb version kernel)"
else
initramfs_cmd="$initramfs_cmd -u -k $4"
fi
${mntproc_cmd}
${mntsys_cmd}
${initramfs_cmd}
${umntproc_cmd}
${umntsys_cmd}
;;
*)
exit 1
;;
esac
exit 0