4
# Script to register/build/unregister a kernel module with DKMS.
6
# Copyright (C) 2010 Oracle Corporation
8
# This file is part of VirtualBox Open Source Edition (OSE), as
9
# available from http://www.virtualbox.org. This file is free software;
10
# you can redistribute it and/or modify it under the terms of the GNU
11
# General Public License (GPL) as published by the Free Software
12
# Foundation, in version 2 as it comes in the "COPYING" file of the
13
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17
DKMS=`which dkms 2>/dev/null`
20
if [ "$1" = "uninstall" ]; then
22
echo "Uninstalling modules from DKMS"
25
$DKMS status -m $m | while read line
26
# first, remove _any_ old module
28
if echo "$line" | grep -q added > /dev/null ||
29
echo "$line" | grep -q built > /dev/null ||
30
echo "$line" | grep -q installed > /dev/null; then
31
# either 'vboxvideo, <version>: added'
32
# or 'vboxvideo, <version>, ...: installed'
33
version=`echo "$line" | sed "s/$m,\([^,]*\)[,:].*/\1/;t;d"`
34
echo " removing old DKMS module $m version $version"
35
$DKMS remove -m $m -v $version --all
39
# there should not be any more matches
40
status=`$DKMS status -m _MODULE_ -v _VERSION_`
41
if echo $status | grep added > /dev/null ||
42
echo $status | grep built > /dev/null ||
43
echo $status | grep installed > /dev/null
45
$DKMS remove -m _MODULE_ -v _VERSION_ --all
49
elif [ "$1" = "install" ]; then
51
echo "Attempting to install using DKMS"
52
if $DKMS add -m _MODULE_ -v _VERSION_ &&
53
$DKMS build -m _MODULE_ -v _VERSION_ &&
54
$DKMS install -m _MODULE_ -v _VERSION_ --force
58
echo "Failed to install using DKMS, attempting to install without"