summarylogtreecommitdiffstats
path: root/dkms.sh.in
blob: ce9d608a3fabf83818b658eb515ef259b3e4dbb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
# Author: Matt Wilder (<me@partcyb.org>)

BASEDIR="$1"
KERNELVER="$(echo $2 | sed 's/\([0-9]\.[0-9]*\).*/\1/')"
PKGVER="%PKGVER%"
NAME="%DKMSNAME%"
DEFAULT_VERSION="15.0.4"

VMWARE_VERSION="$(vmware --version | awk '{print $3}')"
if [[ -n "$VMWARE_VERSION" ]]; then
   echo "WARNING: Could not find vmware application to determine version to build against." \
        " Choosing the latest version as a default"
   VMWARE_VERSION="$DEFAULT_VERSION"
fi

TAG="w${VMWARE_VERSION}-k${KERNELVER}"

git reset --hard HEAD
git pull --rebase origin master
git checkout "$TAG" 2>&1 >/dev/null
RES=$?

if [[ "$RES" -gt 0 ]]; then
   echo "Failed to switch to the correct tag ($TAG)  This build will likely fail"
   exit $RES
fi
echo "Switched $NAME repo to tag $TAG"