#! /bin/sh
# preinst script for sg-utils
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <new-preinst> `install'
#        * <new-preinst> `install' <old-version>
#        * <new-preinst> `upgrade' <old-version>
#        * <old-preinst> `abort-upgrade' <new-version>
#
# For details see /usr/share/doc/packaging-manual/

case "$1" in
    install|upgrade)
      kernel_version=`/bin/uname -r`;
      major_version=`echo $kernel_version | sed 's/\.[0-9]\+$//'`;
      minor_version=`echo $kernel_version | sed 's/.*\.\([0-9]\+\)/\1/'`;

      case $major_version in
	2.[0-3])
	    echo "You are running linux kernel version $kernel_version."
	    echo "sg3_utils will not work on kernels older than 2.4."
	    echo "If you want to run code with older kernels, please"
	    echo "install sg_utils instead."
	    exit 0;
        ;;
	*)
      esac
    ;;

    abort-upgrade)
    ;;

    *)
        echo "preinst called with unknown argument \`$1'" >&2
        exit 0
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
