2010-11-04 13:53:46 +01:00
|
|
|
#!/bin/sh -e
|
|
|
|
#
|
|
|
|
# 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: $ACTION = [run/targets]
|
|
|
|
# $TARGET = [post-install/post-remove]
|
|
|
|
# $PKGNAME
|
|
|
|
# $VERSION
|
|
|
|
# $UPDATE = [yes/no]
|
|
|
|
#
|
|
|
|
ACTION="$1"
|
|
|
|
TARGET="$2"
|
|
|
|
PKGNAME="$3"
|
|
|
|
VERSION="$4"
|
|
|
|
UPDATE="$5"
|
|
|
|
|
|
|
|
update_initramfs=usr/sbin/update-initramfs
|
|
|
|
|
|
|
|
case "$ACTION" in
|
|
|
|
targets)
|
|
|
|
echo "post-install post-remove"
|
|
|
|
;;
|
|
|
|
run)
|
|
|
|
# Exit if the command cannot be executed.
|
|
|
|
[ ! -x ${update_initramfs} ] && exit 0
|
|
|
|
|
|
|
|
# Cannot continue if /proc and /sys not mounted!
|
|
|
|
if [ ! -e ./proc/filesystems -a ! -e ./sys/kernel/vmcoreinfo ]; then
|
|
|
|
echo "initramfs-tools trigger:"
|
|
|
|
echo "WARNING: /proc and /sys (relative to cwd) are not mounted"
|
|
|
|
echo "WARNING: cannot continue, exiting..."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Always use relative paths to create the initramfs!
|
|
|
|
initramfs_args="-b ./boot"
|
|
|
|
|
2010-11-04 14:06:49 +01:00
|
|
|
if [ "$PKGNAME" = "kernel" ]; then
|
2010-11-04 13:53:46 +01:00
|
|
|
if [ "$TARGET" = "post-remove" ]; then
|
2010-11-04 14:06:49 +01:00
|
|
|
# Remove the initramfs if removing.
|
|
|
|
initramfs_args="$initramfs_args -d -k ${VERSION}"
|
2010-11-04 13:53:46 +01:00
|
|
|
fi
|
|
|
|
if [ ! -f var/lib/initramfs-tools/${VERSION} ]; then
|
|
|
|
# Create new initramfs
|
|
|
|
initramfs_args="$initramfs_args -c -t -k ${VERSION}"
|
|
|
|
else
|
|
|
|
# Update existing initramfs
|
|
|
|
initramfs_args="$initramfs_args -B -u -t -k ${VERSION}"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# Update initramfs for all kernels
|
|
|
|
initramfs_args="$initramfs_args -B -u -t -k all"
|
|
|
|
fi
|
|
|
|
|
|
|
|
${update_initramfs} ${initramfs_args}
|
|
|
|
exit $?
|
|
|
|
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|