do_dkms revision 7eaaa8a4480370b82ef3735994f986f338fb4df2
417N/A#!/bin/sh
417N/A
417N/A#
417N/A# Script to register/build/unregister a kernel module with DKMS.
417N/A#
417N/A# Copyright (C) 2010 Oracle Corporation
417N/A#
417N/A# This file is part of VirtualBox Open Source Edition (OSE), as
417N/A# available from http://www.virtualbox.org. This file is free software;
417N/A# you can redistribute it and/or modify it under the terms of the GNU
417N/A# General Public License (GPL) as published by the Free Software
417N/A# Foundation, in version 2 as it comes in the "COPYING" file of the
417N/A# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
417N/A# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
417N/A#
417N/A
417N/ADKMS=`which dkms 2>/dev/null`
417N/Aif [ -n "$DKMS" ]
417N/Athen
417N/A if [ "$1" = "uninstall" ]; then
417N/A
417N/A echo "Uninstalling modules from DKMS"
653N/A for m in _OLDMODULES_
417N/A do
417N/A $DKMS status -m $m | while read line
417N/A # first, remove _any_ old module
417N/A do
417N/A if echo "$line" | grep -q added > /dev/null ||
653N/A echo "$line" | grep -q built > /dev/null ||
417N/A echo "$line" | grep -q installed > /dev/null; then
618N/A # either 'vboxvideo, <version>: added'
417N/A # or 'vboxvideo, <version>, ...: installed'
417N/A version=`echo "$line" | sed "s/$m,\([^,]*\)[,:].*/\1/;t;d"`
844N/A echo " removing old DKMS module $m version $version"
844N/A $DKMS remove -m $m -v $version --all
653N/A fi
1258N/A done
1258N/A done
417N/A # there should not be any more matches
417N/A status=`$DKMS status -m _MODULE_ -v _VERSION_`
499N/A if echo $status | grep added > /dev/null ||
499N/A echo $status | grep built > /dev/null ||
499N/A echo $status | grep installed > /dev/null
499N/A then
417N/A $DKMS remove -m _MODULE_ -v _VERSION_ --all
653N/A fi
417N/A exit 0
417N/A
417N/A elif [ "$1" = "install" ]; then
417N/A
417N/A echo "Attempting to install using DKMS"
417N/A if $DKMS add -m _MODULE_ -v _VERSION_ &&
417N/A $DKMS build -m _MODULE_ -v _VERSION_ &&
417N/A $DKMS install -m _MODULE_ -v _VERSION_ --force
417N/A then
417N/A exit 0
417N/A fi
417N/A echo "Failed to install using DKMS, attempting to install without"
417N/A
417N/A fi
417N/Afi
417N/A
417N/Aexit 1
417N/A