#!/bin/sh
# Preserve new files
install_file() {
NEW="$1"
OLD="`dirname $NEW`/`basename $NEW .new`"
# If there's no file by that name, mv it over:
if [ ! -r $OLD ]; then
mv $NEW $OLD
elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
rm $NEW
fi
# Otherwise, we leave the .new copy for the admin to consider...
}
# arg 1: the new package version
pre_install() {
/bin/true
}
# arg 1: the new package version
post_install() {
# Notice we use an absolute path below, rather than sbin/depmod. This is because
# we're testing to see if we are on the bootdisk, which will not have /sbin/depmod.
# If we aren't, we will signal init to restart using the new binary.
# The presence of "/etc/system-installer" is under consideration as a better test.
# Also we have to check that we are not in the installer mode on the target system
# ("/etc/system-installer"), and we have to be sure that we are on the working system
# on the target hardware ("proc/sys/kernel/osrelease" - relative path).
if [ -r proc/sys/kernel/osrelease -a ! -r /etc/system-installer -a -x /bin/uname -a -x /sbin/depmod ]; then
# Determine the version of the running kernel:
RELEASE=$(uname -r)
### Update module dependencies ###
# If /usr is mounted and we have 'find', we can try to take a shortcut:
if [ -x /usr/bin/find -a -e /lib/modules/$RELEASE/modules.dep \
-a /lib/modules/$RELEASE/modules.dep -nt /etc/modules.conf ]; then
NEWMODS="$(/usr/bin/find /lib/modules/$RELEASE -mindepth 2 -type f -newer /lib/modules/$RELEASE/modules.dep)"
# Only rebuild dependencies if new module(s) are found:
if [ ! "" = "$NEWMODS" ]; then
echo "Updating module dependencies for Linux $RELEASE:"
/sbin/depmod -a
else
echo "Module dependencies up to date (no new kernel modules found)."
fi
else # we don't have find, or there is no existing modules.dep, or it is out of date.
echo "Updating module dependencies for Linux $RELEASE:"
/sbin/depmod -b / $RELEASE
fi
fi
}
# arg 1: the new package version
# arg 2: the old package version
pre_update() {
/bin/true
}
# arg 1: the new package version
# arg 2: the old package version
post_update() {
post_install
}
# arg 1: the old package version
pre_remove() {
/bin/true
}
# arg 1: the old package version
post_remove() {
/bin/true
}
operation=$1
shift
$operation $*