Possible first-hack at the debian scripts for install-upgrade-configure: preinst
if [ "${1}" = "install" -a -z "${1}" ]
then
# "before install" goes here
elif [ "${1}" = "upgrade" -a -n "${2}" ]
then
upgradeVersion="${2}"
# "before upgrade" goes here