VirtualBox

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

最後變更 在這個檔案從26163是 26163,由 vboxsync 提交於 15 年 前

PDM: s/pUsbReg/pReg/g (2nd try, backed out r57176)

  • 屬性 svn:eol-style 設為 LF
  • 屬性 svn:executable 設為 *
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 3.0 KB
 
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.alldomusa.eu.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# Attempt to build using DKMS first
23DKMS=`which dkms 2>/dev/null`
24if [ "$1" = "--no-dkms" ]; then
25 shift
26 DKMS=""
27fi
28if [ -n "$DKMS" ]
29then
30 echo "Attempting to install using DKMS"
31 $DKMS status -m _MODULE_ | while read line
32 # first, remove _any_ old module
33 do
34 if echo "$line" | grep -q added > /dev/null ||
35 echo "$line" | grep -q built > /dev/null ||
36 echo "$line" | grep -q installed > /dev/null; then
37 # either 'vboxvideo, <version>: added' or 'vboxvideo, <version>, ...: installed'
38 version=`echo "$line" | sed "s/_MODULE_,\([^,]*\)[,:].*/\1/;t;d"`
39 echo " removing old DKMS module _MODULE_ version $version"
40 $DKMS remove -m _MODULE_ -v $version --all
41 fi
42 done
43 # there should not be any more matches
44 status=`$DKMS status -m _MODULE_ -v _VERSION_`
45 if echo $status | grep added > /dev/null ||
46 echo $status | grep built > /dev/null ||
47 echo $status | grep installed > /dev/null
48 then
49 $DKMS remove -m _MODULE_ -v _VERSION_ --all
50 fi
51 # finally install the module
52 if $DKMS add -m _MODULE_ -v _VERSION_ &&
53 $DKMS build -m _MODULE_ -v _VERSION_ &&
54 $DKMS install -m _MODULE_ -v _VERSION_ --force
55 then
56 exit 0
57 fi
58 echo "Failed to install using DKMS, attempting to install without"
59fi
60
61# find a unique temp directory
62num=0
63while true; do
64 tmpdir="/tmp/vbox.$num"
65 if mkdir -m 0755 "$tmpdir" 2> /dev/null; then
66 break
67 fi
68 num=`expr $num + 1`
69 if [ $num -gt 200 ]; then
70 echo "Could not find a valid tmp directory"
71 exit 1
72 fi
73done
74
75if [ "$1" = "--save-module-symvers" ]; then
76 shift
77 SAVE_MOD_SYMVERS="$1"
78 shift
79fi
80
81if [ "$1" = "--use-module-symvers" ]; then
82 shift
83 USE_MOD_SYMVERS="$1"
84 shift
85fi
86
87# copy
88cp -a ${0%/*}/* $tmpdir/
89if [ -n "$USE_MOD_SYMVERS" ]; then
90 cp $USE_MOD_SYMVERS $tmpdir/Module.symvers
91fi
92
93# make, cleanup if success
94cd "$tmpdir"
95if make "$@"; then
96 if [ -n "$SAVE_MOD_SYMVERS" ]; then
97 if [ -f Module.symvers ]; then
98 cp -f Module.symvers $SAVE_MOD_SYMVERS
99 else
100 cat /dev/null > $SAVE_MOD_SYMVERS
101 fi
102 fi
103 rm -rf $tmpdir
104 exit 0
105fi
106
107# failure
108rm -rf $tmpdir
109exit 1
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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