#!/bin/sh -e
# libusb configuration script

# Source debconf library -- we have a Depends line
# to make sure it is there...
. /usr/share/debconf/confmodule
db_version 2.0

if [ "$1" = configure ] || [ "$1" = reconfigure ] ; then
	if [ "`uname -s`" = "Linux" ] ; then
		# if /proc/bus/usb or usbcore.o or usbcore.ko exists
		if [ -d "/proc/bus/usb" ] || \
		   [ -f "/lib/modules/`uname -r`/kernel/drivers/usb/usbcore.o" ] || \
		   [ -f "/lib/modules/`uname -r`/kernel/drivers/usb/core/usbcore.ko" ] ; then
			# USB is functional, but /proc/bus/usb should
			# be mounted or hotplug be installed.
			if ! [ -x /sbin/hotplug ] && ! mount | grep -q "/proc/bus/usb" ; then
				db_input medium libusb-0.1-4/usbfs || true
				db_go
			fi
		else
			# if it doesn't exists, display a warning telling USB
			# is not functional
			db_input medium libusb-0.1-4/nousb || true
			db_go
		fi
	fi
fi

exit 0
