VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/linux/build_in_tmp@ 8447

Last change on this file since 8447 was 8447, checked in by vboxsync, 17 years ago

DKMS support for Linux guest kernel modules

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1#!/bin/sh
2
3#
4# Script to build a kernel module in /tmp. Useful if the module sources
5# are installed in read-only directory.
6#
7# Copyright (C) 2007 Sun Microsystems, Inc.
8#
9# This file is part of VirtualBox Open Source Edition (OSE), as
10# available from http://www.virtualbox.org. This file is free software;
11# you can redistribute it and/or modify it under the terms of the GNU
12# General Public License (GPL) as published by the Free Software
13# Foundation, in version 2 as it comes in the "COPYING" file of the
14# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16#
17# The contents of this file may alternatively be used under the terms
18# of the Common Development and Distribution License Version 1.0
19# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20# VirtualBox OSE distribution, in which case the provisions of the
21# CDDL are applicable instead of those of the GPL.
22#
23# You may elect to license modified versions of this file under the
24# terms and conditions of either the GPL or the CDDL or both.
25#
26# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27# Clara, CA 95054 USA or visit http://www.sun.com if you need
28# additional information or have any questions.
29#
30
31# Attempt to build using DKMS first
32DKMS=`which dkms`
33if [ -n "$DKMS" ]
34then
35 echo "Attempting to install using DKMS"
36 status=`$DKMS status -m _MODULE_ -v _VERSION_`
37 if echo $status | grep added > /dev/null ||
38 echo $status | grep built > /dev/null ||
39 echo $status | grep installed > /dev/null
40 then
41 $DKMS remove -m _MODULE_ -v _VERSION_ --all
42 fi
43 if $DKMS add -m _MODULE_ -v _VERSION_ &&
44 $DKMS build -m _MODULE_ -v _VERSION_ &&
45 $DKMS install -m _MODULE_ -v _VERSION_ --force
46 then
47 exit 0
48 fi
49 echo "Failed to install using DKMS, attempting to install without"
50fi
51
52# find a unique temp directory
53num=0
54while true; do
55 tmpdir="/tmp/vbox.$num"
56 if mkdir -m 0755 "$tmpdir" 2> /dev/null; then
57 break
58 fi
59 num=`expr $num + 1`
60 if [ $num -gt 200 ]; then
61 echo "Could not find a valid tmp directory"
62 exit 1
63 fi
64done
65
66if [ "$1" = "--save-module-symvers" ]; then
67 shift
68 SAVE_MOD_SYMVERS="$1"
69 shift
70fi
71
72if [ "$1" = "--use-module-symvers" ]; then
73 shift
74 USE_MOD_SYMVERS="$1"
75 shift
76fi
77
78# copy
79cp -a ${0%/*}/* $tmpdir/
80if [ -n "$USE_MOD_SYMVERS" ]; then
81 cp $USE_MOD_SYMVERS $tmpdir/Module.symvers
82fi
83
84# make, cleanup if success
85cd "$tmpdir"
86if make "$@"; then
87 if [ -n "$SAVE_MOD_SYMVERS" ]; then
88 if [ -f Module.symvers ]; then
89 cp -f Module.symvers $SAVE_MOD_SYMVERS
90 else
91 cat /dev/null > $SAVE_MOD_SYMVERS
92 fi
93 fi
94 rm -rf $tmpdir
95 exit 0
96fi
97
98# failure
99exit 1
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette