2009-12-11 12:03:21 +01:00
|
|
|
#!/bin/sh -e
|
2009-03-12 11:50:46 +01:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2009-12-11 07:23:49 +01:00
|
|
|
# Arguments: $ACTION = [run/targets]
|
|
|
|
# $TARGET = [post-install/post-remove]
|
|
|
|
# $PKGNAME
|
|
|
|
# $VERSION
|
|
|
|
# $UPDATE = [yes/no]
|
2009-03-12 11:50:46 +01:00
|
|
|
#
|
2009-10-03 08:33:36 +02:00
|
|
|
ACTION="$1"
|
|
|
|
TARGET="$2"
|
|
|
|
PKGNAME="$3"
|
|
|
|
VERSION="$4"
|
2009-12-11 07:23:49 +01:00
|
|
|
UPDATE="$5"
|
2009-10-03 08:33:36 +02:00
|
|
|
|
|
|
|
update_initramfs=usr/sbin/update-initramfs
|
|
|
|
|
|
|
|
case "$ACTION" in
|
2009-03-12 11:50:46 +01:00
|
|
|
targets)
|
2009-10-03 08:58:00 +02:00
|
|
|
echo "post-install post-remove"
|
2009-03-12 11:50:46 +01:00
|
|
|
;;
|
|
|
|
run)
|
2009-10-03 08:33:36 +02:00
|
|
|
[ ! -x ${update_initramfs} ] && exit 0
|
2009-03-12 11:50:46 +01:00
|
|
|
|
2009-10-03 08:33:36 +02:00
|
|
|
initramfs_args="update-initramfs"
|
2009-03-12 11:50:46 +01:00
|
|
|
|
2009-10-03 08:33:36 +02:00
|
|
|
if [ "$PKGNAME" = "kernel" ]; then
|
2009-10-03 08:58:00 +02:00
|
|
|
if [ "$TARGET" = "post-remove" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
2009-10-03 08:33:36 +02:00
|
|
|
if [ ! -f var/lib/initramfs-tools/${VERSION} ]; then
|
|
|
|
# Create new initramfs
|
2009-10-09 03:18:01 +02:00
|
|
|
initramfs_args="-c -t -k ${VERSION}"
|
2009-10-03 08:33:36 +02:00
|
|
|
else
|
|
|
|
# Update existing initramfs
|
2009-10-09 03:18:01 +02:00
|
|
|
initramfs_args="-u -t -k ${VERSION}"
|
2009-10-03 08:33:36 +02:00
|
|
|
fi
|
2009-03-12 11:50:46 +01:00
|
|
|
else
|
2009-10-03 08:33:36 +02:00
|
|
|
# Update initramfs for all kernels
|
2009-10-09 03:18:01 +02:00
|
|
|
initramfs_args="-u -t -k all"
|
2009-03-12 11:50:46 +01:00
|
|
|
fi
|
|
|
|
|
2009-05-06 07:54:56 +02:00
|
|
|
if [ ! -e /proc/filesystems ]; then
|
2009-05-05 05:28:24 +02:00
|
|
|
mount -t proc proc /proc
|
|
|
|
proc_mounted=1
|
|
|
|
fi
|
2009-05-06 07:54:56 +02:00
|
|
|
|
|
|
|
if [ ! -e /sys/kernel/vmcoreinfo ]; then
|
2009-05-05 05:28:24 +02:00
|
|
|
mount -t sysfs sysfs /sys
|
|
|
|
sys_mounted=1
|
|
|
|
fi
|
|
|
|
|
2009-10-03 08:33:36 +02:00
|
|
|
${update_initramfs} ${initramfs_args}
|
2009-05-05 05:28:24 +02:00
|
|
|
|
|
|
|
if [ -n "$proc_mounted" ]; then
|
|
|
|
umount /proc
|
|
|
|
fi
|
|
|
|
if [ -n "$sys_mounted" ]; then
|
|
|
|
umount /sys
|
|
|
|
fi
|
2009-03-12 11:50:46 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|