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