]> oss.titaniummirror.com Git - cp210x.git/commitdiff
dkms support in pre/post scripts. Ensure module is rmmod'ed on removal of pkg.
authorsmckown <smckown@986fd584-583e-0410-b54d-b9fe63dff8e5>
Wed, 25 Nov 2009 20:10:52 +0000 (20:10 +0000)
committersmckown <smckown@986fd584-583e-0410-b54d-b9fe63dff8e5>
Wed, 25 Nov 2009 20:10:52 +0000 (20:10 +0000)
Makefile
debian.in/control
debian.in/postinst
debian.in/postrm
debian.in/prerm [new file with mode: 0755]
debian.in/rules
dkms.conf

index ac84c4aa160f61c29d882e259dc72fe36b8573f2..c05566d75e15c9169b7c5c542d7fed1207cc5849 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -51,7 +51,7 @@ $(BUILD)/src-stamp: Makefile.dkms dkms.conf $(wildcard src/*)
        cp -a src $(BUILD)/$(DEBSRC)
        cp Makefile.dkms $(BUILD)/$(DEBSRC)
        cp dkms.conf $(BUILD)/$(DEBSRC)
-       perl -i -pe 's/xxDEBVERxx/$(DEBVER)/g' $(BUILD)/$(DEBSRC)/dkms.conf
+       perl -i -pe 's/xxPKGVERxx/$(PKGVER)/g' $(BUILD)/$(DEBSRC)/dkms.conf
        find $(BUILD)/$(DEBSRC) -name .svn -type d -exec rm -rf "{}" ";" 2>/dev/null || exit 0
        rm -rf $(BUILD)/$(DEBSRC)/.git || exit 0
        tar -C $(BUILD) -czf $(BUILD)/$(TARFILE) $(DEBSRC)
index 9acffae9d2bf63e94ea78368b14de982a9116f17..1f16c500fdd40b92d7fda33e6417ea1b90ca4241 100644 (file)
@@ -9,6 +9,7 @@ Package: xxPACKAGExx
 Architecture: any
 Depends: dkms (>> 2.0.20), linux-headers, linux-image, binutils (>= 2.9.5.0.12), gcc (>= 4:4.2.2), dpatch, file, bzip2, lsb-release
 Conflicts: cp210x-module-2.6.24-19-generic, cp210x-module-2.6.24-21-generic, cp210x-module-2.6.24-22-generic, cp210x-module-2.6.24-23-generic, cp210x-module-2.6.24-24-generic, cp210x-module-2.6.24-25-generic
+Replaces: cp210x-module-2.6.24-19-generic, cp210x-module-2.6.24-21-generic, cp210x-module-2.6.24-22-generic, cp210x-module-2.6.24-23-generic, cp210x-module-2.6.24-24-generic, cp210x-module-2.6.24-25-generic
 Priority: extra
 Description: Enhanced USB/serial kernel module for cp210x based devices.
   This module blacklists the standard cp2101 module installed in the kernel,
index a818525b67f953af3779a9a58d511aefc96d0c5c..accd6fcfd09b3bc4201d7a2a577a5ea9c72e13cf 100755 (executable)
@@ -2,6 +2,76 @@
 
 set -e
 
-if [ "$1" = "configure" ]; then
-       modprobe -rq cp2101 || true
-fi
+NAME=xxPACKAGExx
+VERSION=xxPKGVERxx
+
+case "$1" in
+    configure)
+      # Unload old cp210x modules, if in use
+      modprobe -rq cp2101 || true
+      modprobe -rq cp210x || true
+
+      # Determine current arch / kernel
+      c_arch=`uname -m`
+      c_kern=`uname -r`
+
+      if [ -e "/var/lib/dkms/$NAME/$VERSION" ]; then
+         echo "Removing old $NAME-$VERSION DKMS files..."
+         dkms remove -m $NAME -v $VERSION --all
+      fi
+
+      echo "Loading new $NAME-$VERSION DKMS files..."
+      if [ -f "/usr/src/$NAME-$VERSION.dkms.tar.gz" ]; then
+          dkms ldtarball --archive "/usr/src/$NAME-$VERSION.dkms.tar.gz"
+      else
+          dkms add -m $NAME -v $VERSION
+      fi
+
+      echo "Installing prebuilt kernel module binaries (if any)"
+      set +e
+      IFS='
+'
+      for kern in `dkms status -m $NAME -v $VERSION -a $c_arch | grep ": built" | awk {'print $3'} | sed 's/,$//'`; do
+         echo "Trying kernel: $kern"
+         dkms install --force -m $NAME -v $VERSION -k $kern -a $c_arch
+      done
+      unset IFS
+      set -e
+
+      # If none installed, install.
+      ##if [ `dkms status -m $NAME -v $VERSION -k $c_kern -a $c_arch | grep -c ": installed"` -eq 0 ]; then
+      dkms_status=`dkms status -m $NAME -v $VERSION -k $c_kern -a $c_arch`
+      if [ `echo $dkms_status | grep -c ": installed"` -eq 0 ]; then
+         if [ `echo $c_kern | grep -c "BOOT"` -eq 0 ] && [ -e "/lib/modules/$c_kern/build/include" ]; then
+            # Only build if we need to.
+            if [ `echo $dkms_status | grep -c ": built"` -eq 0 ]; then
+               echo "Building module..."
+               dkms build -m $NAME -v $VERSION
+            fi
+            echo "Installing module..."
+            dkms install -m $NAME -v $VERSION
+         elif [ `echo $c_kern | grep -c "BOOT"` -gt 0 ]; then
+            echo ""
+            echo "Module build for the currently running kernel was skipped since you"
+            echo "are running a BOOT variant of the kernel."
+         else
+            echo ""
+            echo "Module build for the currently running kernel was skipped since the"
+            echo "kernel source for this kernel does not seem to be installed."
+         fi
+      fi
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
+
index fdd7b35af60cda3b7e3fd628394ea0d59b842f52..9bf77b537947070fe2a117b70c5e964420741ed4 100755 (executable)
@@ -1,7 +1,26 @@
-#! /bin/sh
+#!/bin/sh
+
+NAME=xxPACKAGExx
+VERSION=xxPKGVERxx
 
 set -e
 
-if [ "$1" = "remove" ]; then
-       depmod -a
-fi
+case "$1" in
+    purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+      depmod
+      if [ -d "/usr/src/$NAME-$VERSION" ]; then
+         echo "Removing old module source..."
+         rm -rf "/usr/src/$NAME-$VERSION"
+      fi
+    ;;
+
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
+
diff --git a/debian.in/prerm b/debian.in/prerm
new file mode 100755 (executable)
index 0000000..d685190
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+NAME=xxPACKAGExx
+VERSION=xxPKGVERxx
+
+set -e
+
+case "$1" in
+    remove|upgrade|deconfigure)
+      rmmod cp2101 2>/dev/null || true
+      rmmod xxROOTNAMExx 2>/dev/null || true
+      if [  "`dkms status -m $NAME`" ]; then
+         dkms remove -m $NAME -v $VERSION --all
+      fi
+    ;;
+
+    failed-upgrade)
+    ;;
+
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
+
index 57b40bd603b57204b42e7e500ba692839dcfe829..4f324b6f2ac2e0699292ce0232ca4d274ed52c1e 100755 (executable)
@@ -10,7 +10,7 @@
 # This file may have to be extensively modified
 
 package = xxPACKAGExx
-inst_dir = debian/tmp/usr/src/xxPACKAGExx-xxDEBVERxx
+inst_dir = debian/tmp/usr/src/xxPACKAGExx-xxPKGVERxx
 
 install_dir    = install -d -m 755
 install_file   = install -m 644
@@ -52,6 +52,7 @@ binary-arch: checkroot build install
        : # install maintainer scripts
        $(install_dir) debian/tmp/DEBIAN
        $(install_script) debian/postinst debian/tmp/DEBIAN/postinst
+       $(install_script) debian/prerm debian/tmp/DEBIAN/prerm
        $(install_script) debian/postrm debian/tmp/DEBIAN/postrm
        : # install docs
        $(install_dir) debian/tmp/usr/share/doc/$(package)/
index e1c3c4377ac38619c9c49dc9283fdd35eae6a61a..64fed9c3ddd92e52095e55c7615ba1451e896a12 100644 (file)
--- a/dkms.conf
+++ b/dkms.conf
@@ -1,4 +1,4 @@
-PACKAGE_VERSION="xxDEBVERxx"
+PACKAGE_VERSION="xxPKGVERxx"
 PACKAGE_NAME="cp210x-module-dkms"
 CLEAN="make -f Makefile.dkms clean"
 BUILT_MODULE_NAME[0]=cp210x