2009-10-03 08:33:36 +02: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.
|
|
|
|
#
|
|
|
|
# Arguments: $1 = action [run/targets]
|
2009-10-03 08:58:00 +02:00
|
|
|
# $2 = target [post-install/post-remove]
|
2009-03-12 11:50:46 +01:00
|
|
|
# $3 = pkgname
|
|
|
|
# $4 = version
|
|
|
|
#
|
2009-10-03 08:33:36 +02:00
|
|
|
ACTION="$1"
|
|
|
|
TARGET="$2"
|
|
|
|
PKGNAME="$3"
|
|
|
|
VERSION="$4"
|
|
|
|
|
|
|
|
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
|
|
|
|
initramfs_args="-c -k ${VERSION}"
|
|
|
|
else
|
|
|
|
# Update existing initramfs
|
|
|
|
initramfs_args="-u -k ${VERSION}"
|
|
|
|
fi
|
2009-03-12 11:50:46 +01:00
|
|
|
else
|
2009-10-03 08:33:36 +02:00
|
|
|
# Update initramfs for all kernels
|
|
|
|
initramfs_args="-u -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
|