VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/darwin/load.sh@ 27842

Last change on this file since 27842 was 22077, checked in by vboxsync, 16 years ago

HostDrivers/Support: header and svn props cleanup.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1#!/bin/bash
2# $Id: load.sh 22077 2009-08-07 16:01:57Z vboxsync $
3## @file
4# For development.
5#
6
7#
8# Copyright (C) 2006-2007 Sun Microsystems, Inc.
9#
10# This file is part of VirtualBox Open Source Edition (OSE), as
11# available from http://www.virtualbox.org. This file is free software;
12# you can redistribute it and/or modify it under the terms of the GNU
13# General Public License (GPL) as published by the Free Software
14# Foundation, in version 2 as it comes in the "COPYING" file of the
15# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17#
18# The contents of this file may alternatively be used under the terms
19# of the Common Development and Distribution License Version 1.0
20# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
21# VirtualBox OSE distribution, in which case the provisions of the
22# CDDL are applicable instead of those of the GPL.
23#
24# You may elect to license modified versions of this file under the
25# terms and conditions of either the GPL or the CDDL or both.
26#
27# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
28# Clara, CA 95054 USA or visit http://www.sun.com if you need
29# additional information or have any questions.
30#
31
32XNU_VERSION=`LC_ALL=C uname -r | LC_ALL=C cut -d . -f 1`
33if [ "$XNU_VERSION" -ge "9" ]; then
34 DRVNAME="VBoxDrv.kext"
35else
36 DRVNAME="VBoxDrvTiger.kext"
37fi
38BUNDLE="org.virtualbox.kext.VBoxDrv"
39
40DIR=`dirname "$0"`
41DIR=`cd "$DIR" && pwd`
42DIR="$DIR/$DRVNAME"
43if [ ! -d "$DIR" ]; then
44 echo "Cannot find $DIR or it's not a directory..."
45 exit 1;
46fi
47if [ -n "$*" ]; then
48 OPTS="$*"
49else
50 OPTS="-t"
51fi
52
53# Make sure VBoxUSB is unloaded as it might be using symbols from us.
54LOADED=`kextstat -b org.virtualbox.kext.VBoxUSB -l`
55if test -n "$LOADED"; then
56 echo "load.sh: Unloading org.virtualbox.kext.VBoxUSB..."
57 sudo kextunload -v 6 -b org.virtualbox.kext.VBoxUSB
58 LOADED=`kextstat -b org.virtualbox.kext.VBoxUSB -l`
59 if test -n "$LOADED"; then
60 echo "load.sh: failed to unload org.virtualbox.kext.VBoxUSB, see above..."
61 exit 1;
62 fi
63 echo "load.sh: Successfully unloaded org.virtualbox.kext.VBoxUSB"
64fi
65
66# Make sure VBoxNetFlt is unloaded as it might be using symbols from us.
67LOADED=`kextstat -b org.virtualbox.kext.VBoxNetFlt -l`
68if test -n "$LOADED"; then
69 echo "load.sh: Unloading org.virtualbox.kext.VBoxNetFlt..."
70 sudo kextunload -v 6 -b org.virtualbox.kext.VBoxNetFlt
71 LOADED=`kextstat -b org.virtualbox.kext.VBoxNetFlt -l`
72 if test -n "$LOADED"; then
73 echo "load.sh: failed to unload org.virtualbox.kext.VBoxNetFlt, see above..."
74 exit 1;
75 fi
76 echo "load.sh: Successfully unloaded org.virtualbox.kext.VBoxNetFlt"
77fi
78
79# Make sure VBoxNetAdp is unloaded as it might be using symbols from us.
80LOADED=`kextstat -b org.virtualbox.kext.VBoxNetAdp -l`
81if test -n "$LOADED"; then
82 echo "load.sh: Unloading org.virtualbox.kext.VBoxNetAdp..."
83 sudo kextunload -v 6 -b org.virtualbox.kext.VBoxNetAdp
84 LOADED=`kextstat -b org.virtualbox.kext.VBoxNetAdp -l`
85 if test -n "$LOADED"; then
86 echo "load.sh: failed to unload org.virtualbox.kext.VBoxNetAdp, see above..."
87 exit 1;
88 fi
89 echo "load.sh: Successfully unloaded org.virtualbox.kext.VBoxNetAdp"
90fi
91
92# Try unload any existing instance first.
93LOADED=`kextstat -b $BUNDLE -l`
94if test -n "$LOADED"; then
95 echo "load.sh: Unloading $BUNDLE..."
96 sudo kextunload -v 6 -b $BUNDLE
97 LOADED=`kextstat -b $BUNDLE -l`
98 if test -n "$LOADED"; then
99 echo "load.sh: failed to unload $BUNDLE, see above..."
100 exit 1;
101 fi
102 echo "load.sh: Successfully unloaded $BUNDLE"
103fi
104
105set -e
106
107# Copy the .kext to the symbols directory and tweak the kextload options.
108if test -n "$VBOX_DARWIN_SYMS"; then
109 echo "load.sh: copying the extension the symbol area..."
110 rm -Rf "$VBOX_DARWIN_SYMS/$DRVNAME"
111 mkdir -p "$VBOX_DARWIN_SYMS"
112 cp -R "$DIR" "$VBOX_DARWIN_SYMS/"
113 OPTS="$OPTS -s $VBOX_DARWIN_SYMS/ "
114 sync
115fi
116
117trap "sudo chown -R `whoami` $DIR; exit 1" INT
118trap "sudo chown -R `whoami` $DIR; exit 1" ERR
119# On smbfs, this might succeed just fine but make no actual changes,
120# so we might have to temporarily copy the driver to a local directory.
121if sudo chown -R root:wheel "$DIR"; then
122 OWNER=`/usr/bin/stat -f "%u" "$DIR"`
123else
124 OWNER=1000
125fi
126if test "$OWNER" -ne 0; then
127 TMP_DIR=/tmp/loaddrv.tmp
128 echo "load.sh: chown didn't work on $DIR, using temp location $TMP_DIR/$DRVNAME"
129
130 # clean up first (no sudo rm)
131 if test -e "$TMP_DIR"; then
132 sudo chown -R `whoami` "$TMP_DIR"
133 rm -Rf "$TMP_DIR"
134 fi
135
136 # make a copy and switch over DIR
137 mkdir -p "$TMP_DIR/"
138 sudo cp -Rp "$DIR" "$TMP_DIR/"
139 DIR="$TMP_DIR/$DRVNAME"
140
141 # retry
142 sudo chown -R root:wheel "$DIR"
143fi
144sudo chmod -R o-rwx "$DIR"
145sync
146echo "load.sh: loading $DIR..."
147
148if [ "$XNU_VERSION" -ge "10" ]; then
149 echo "${SCRIPT_NAME}.sh: loading $DIR... (kextutil $OPTS \"$DIR\")"
150 sudo kextutil $OPTS "$DIR"
151else
152 sudo kextload $OPTS "$DIR"
153fi
154sync
155sudo chown -R `whoami` "$DIR"
156#sudo chmod 666 /dev/vboxdrv
157kextstat | grep org.virtualbox.kext
158if [ -n "${VBOX_DARWIN_SYMS}" -a "$XNU_VERSION" -ge "10" ]; then
159 dsymutil -o "${VBOX_DARWIN_SYMS}/${DRVNAME}.dSYM" "${DIR}/Contents/MacOS/`basename -s .kext ${DRVNAME}`"
160 sync
161fi
162
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