OSDN Git Service

initial import
[android-x86/device-viliv-s5.git] / psb-kernel-source-4.41.1 / debian / postinst
1 #!/bin/sh
2
3 set -e
4
5 NAME=psb-kernel-source
6 VERSION=$(dpkg-query -W -f='${Version}' $NAME | awk -F "-" '{print $1}' | cut -d\: -f2)
7
8 case "$1" in
9     configure)
10       # Determine current arch / kernel
11       c_arch=`uname -m`
12       c_kern=`uname -r`
13
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
17       fi
18
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
24       fi
25
26       echo "Installing prebuilt kernel module binaries (if any)"
27       set +e
28       IFS='
29 '
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
36
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
46             fi
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."
57          fi
58       fi
59     ;;
60
61     abort-upgrade|abort-remove|abort-deconfigure)
62     ;;
63
64     *)
65         echo "postinst called with unknown argument \`$1'" >&2
66         exit 1
67     ;;
68 esac
69
70 #DEBHELPER#
71
72 exit 0
73