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