X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=debian%2Fpostinst.in;fp=debian%2Fpostinst.in;h=04bba6bfff5e41d4ae3b01de1ecb7e3d52c20211;hb=74e64be8b45a7ff22f994552a95c797575dbe384;hp=0000000000000000000000000000000000000000;hpb=2ae34928adb5da51a66170a52678bb4a7d2d212a;p=cp210x.git diff --git a/debian/postinst.in b/debian/postinst.in new file mode 100755 index 0000000..04bba6b --- /dev/null +++ b/debian/postinst.in @@ -0,0 +1,84 @@ +#! /bin/sh + +set -e + +PACKAGE=xxPACKAGExx +VERSION=xxDEBVERxx + +case "$1" in + configure) + # Use a distro-specific source file, if present + c_src=/usr/src/$PACKAGE-$VERSION/cp210x.c + c_dist=$(lsb_release -cs) + if [ -f "$c_src.$c_dist" ]; then + mv $c_src.$c_dist $c_src + fi + + # 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/$PACKAGE/$VERSION" ]; then + echo "Removing old $PACKAGE-$VERSION DKMS files..." + dkms remove -m $PACKAGE -v $VERSION --all + fi + + echo "Loading new $PACKAGE-$VERSION DKMS files..." + if [ -f "/usr/src/$PACKAGE-$VERSION.dkms.tar.gz" ]; then + dkms ldtarball --archive "/usr/src/$PACKAGE-$VERSION.dkms.tar.gz" + else + dkms add -m $PACKAGE -v $VERSION + fi + + echo "Installing prebuilt kernel module binaries (if any)" + set +e + IFS=' +' + for kern in `dkms status -m $PACKAGE -v $VERSION -a $c_arch | grep ": built" | awk {'print $3'} | sed 's/,$//'`; do + echo "Trying kernel: $kern" + dkms install --force -m $PACKAGE -v $VERSION -k $kern -a $c_arch + done + unset IFS + set -e + + # If none installed, install. + ##if [ `dkms status -m $PACKAGE -v $VERSION -k $c_kern -a $c_arch | grep -c ": installed"` -eq 0 ]; then + dkms_status=`dkms status -m $PACKAGE -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 $PACKAGE -v $VERSION + fi + echo "Installing module..." + dkms install -m $PACKAGE -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 +