Adding ubuntu dkms source module packaging scripts for microdia driver
[pkgmicrodia.git] / ubuntu / debian / postinst.dpkg-dist
blob1e9ce6def75c40d1e64b7bfceec0ccc08cf4d034
1 #!/bin/sh
3 set -e
5 NAME=microdia
6 VERSION=2008.10
8 case "$1" in
9 configure)
10 # Determine current arch / kernel
11 c_arch=`uname -m`
12 c_kern=`uname -r`
14 if [ -e "/var/lib/dkms/$NAME/$VERSION" ]; then
15 echo "Removing old $NAME-$VERSION DKMS files..."
16 dkms remove -m $NAME -v $VERSION --all
19 echo "Loading new $NAME-$VERSION DKMS files..."
20 if [ -f "/usr/src/$NAME-$VERSION.dkms.tar.gz" ]; then
21 dkms ldtarball --archive "/usr/src/$NAME-$VERSION.dkms.tar.gz"
22 else
23 dkms add -m $NAME -v $VERSION
26 echo "Installing prebuilt kernel module binaries (if any)"
27 set +e
28 IFS='
30 for kern in `dkms status -m $NAME -v $VERSION -a $c_arch | grep ": built" | awk {'print $3'} | sed 's/,$//'`; do
31 echo "Trying kernel: $kern"
32 dkms install --force -m $NAME -v $VERSION -k $kern -a $c_arch
33 done
34 unset IFS
35 set -e
37 # If none installed, install.
38 ##if [ `dkms status -m $NAME -v $VERSION -k $c_kern -a $c_arch | grep -c ": installed"` -eq 0 ]; then
39 dkms_status=`dkms status -m $NAME -v $VERSION -k $c_kern -a $c_arch`
40 if [ `echo $dkms_status | grep -c ": installed"` -eq 0 ]; then
41 if [ `echo $c_kern | grep -c "BOOT"` -eq 0 ] && [ -e "/lib/modules/$c_kern/build/include" ]; then
42 # Only build if we need to.
43 if [ `echo $dkms_status | grep -c ": built"` -eq 0 ]; then
44 echo "Building module..."
45 dkms build -m $NAME -v $VERSION
47 echo "Installing module..."
48 dkms install -m $NAME -v $VERSION
49 elif [ `echo $c_kern | grep -c "BOOT"` -gt 0 ]; then
50 echo ""
51 echo "Module build for the currently running kernel was skipped since you"
52 echo "are running a BOOT variant of the kernel."
53 else
54 echo ""
55 echo "Module build for the currently running kernel was skipped since the"
56 echo "kernel source for this kernel does not seem to be installed."
61 abort-upgrade|abort-remove|abort-deconfigure)
65 echo "postinst called with unknown argument \`$1'" >&2
66 exit 1
68 esac
70 #DEBHELPER#
72 exit 0