VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/linux/build_in_tmp@ 26600

Last change on this file since 26600 was 26336, checked in by vboxsync, 15 years ago

Installers/linux: enable debug builds of the Linux installers again

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 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# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18# Clara, CA 95054 USA or visit http://www.sun.com if you need
19# additional information or have any questions.
20#
21
22# Set the build type
23export BUILD_TYPE=_BUILDTYPE_
24
25# Attempt to build using DKMS first
26DKMS=`which dkms 2>/dev/null`
27if [ "$1" = "--no-dkms" ]; then
28 shift
29 DKMS=""
30fi
31if [ -n "$DKMS" ]
32then
33 echo "Attempting to install using DKMS"
34 $DKMS status -m _MODULE_ | while read line
35 # first, remove _any_ old module
36 do
37 if echo "$line" | grep -q added > /dev/null ||
38 echo "$line" | grep -q built > /dev/null ||
39 echo "$line" | grep -q installed > /dev/null; then
40 # either 'vboxvideo, <version>: added' or 'vboxvideo, <version>, ...: installed'
41 version=`echo "$line" | sed "s/_MODULE_,\([^,]*\)[,:].*/\1/;t;d"`
42 echo " removing old DKMS module _MODULE_ version $version"
43 $DKMS remove -m _MODULE_ -v $version --all
44 fi
45 done
46 # there should not be any more matches
47 status=`$DKMS status -m _MODULE_ -v _VERSION_`
48 if echo $status | grep added > /dev/null ||
49 echo $status | grep built > /dev/null ||
50 echo $status | grep installed > /dev/null
51 then
52 $DKMS remove -m _MODULE_ -v _VERSION_ --all
53 fi
54 # finally install the module
55 if $DKMS add -m _MODULE_ -v _VERSION_ &&
56 $DKMS build -m _MODULE_ -v _VERSION_ &&
57 $DKMS install -m _MODULE_ -v _VERSION_ --force
58 then
59 exit 0
60 fi
61 echo "Failed to install using DKMS, attempting to install without"
62fi
63
64# find a unique temp directory
65num=0
66while true; do
67 tmpdir="/tmp/vbox.$num"
68 if mkdir -m 0755 "$tmpdir" 2> /dev/null; then
69 break
70 fi
71 num=`expr $num + 1`
72 if [ $num -gt 200 ]; then
73 echo "Could not find a valid tmp directory"
74 exit 1
75 fi
76done
77
78if [ "$1" = "--save-module-symvers" ]; then
79 shift
80 SAVE_MOD_SYMVERS="$1"
81 shift
82fi
83
84if [ "$1" = "--use-module-symvers" ]; then
85 shift
86 USE_MOD_SYMVERS="$1"
87 shift
88fi
89
90# copy
91cp -a ${0%/*}/* $tmpdir/
92if [ -n "$USE_MOD_SYMVERS" ]; then
93 cp $USE_MOD_SYMVERS $tmpdir/Module.symvers
94fi
95
96# make, cleanup if success
97cd "$tmpdir"
98if make "$@"; then
99 if [ -n "$SAVE_MOD_SYMVERS" ]; then
100 if [ -f Module.symvers ]; then
101 cp -f Module.symvers $SAVE_MOD_SYMVERS
102 else
103 cat /dev/null > $SAVE_MOD_SYMVERS
104 fi
105 fi
106 rm -rf $tmpdir
107 exit 0
108fi
109
110# failure
111rm -rf $tmpdir
112exit 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