VirtualBox

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

Last change on this file since 16050 was 15130, checked in by vboxsync, 16 years ago

VBoxDrvTiger.kext (#3202).

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 4.2 KB
Line 
1#!/bin/bash
2## @file
3# For development.
4#
5
6#
7# Copyright (C) 2006-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
31XNU_VERSION=`LC_ALL=C uname -r | LC_ALL=C cut -d . -f 1`
32if [ "$XNU_VERSION" -ge "9" ]; then
33 DRVNAME="VBoxDrv.kext"
34else
35 DRVNAME="VBoxDrvTiger.kext"
36fi
37BUNDLE="org.virtualbox.kext.VBoxDrv"
38
39DIR=`dirname "$0"`
40DIR=`cd "$DIR" && pwd`
41DIR="$DIR/$DRVNAME"
42if [ ! -d "$DIR" ]; then
43 echo "Cannot find $DIR or it's not a directory..."
44 exit 1;
45fi
46if [ -n "$*" ]; then
47 OPTS="$*"
48else
49 OPTS="-t"
50fi
51
52# Make sure VBoxUSB is unloaded as it might be using symbols from us.
53LOADED=`kextstat -b org.virtualbox.kext.VBoxUSB -l`
54if test -n "$LOADED"; then
55 echo "load.sh: Unloading org.virtualbox.kext.VBoxUSB..."
56 sudo kextunload -v 6 -b org.virtualbox.kext.VBoxUSB
57 LOADED=`kextstat -b org.virtualbox.kext.VBoxUSB -l`
58 if test -n "$LOADED"; then
59 echo "load.sh: failed to unload org.virtualbox.kext.VBoxUSB, see above..."
60 exit 1;
61 fi
62 echo "load.sh: Successfully unloaded org.virtualbox.kext.VBoxUSB"
63fi
64
65# Make sure VBoxNetFlt is unloaded as it might be using symbols from us.
66LOADED=`kextstat -b org.virtualbox.kext.VBoxNetFlt -l`
67if test -n "$LOADED"; then
68 echo "load.sh: Unloading org.virtualbox.kext.VBoxNetFlt..."
69 sudo kextunload -v 6 -b org.virtualbox.kext.VBoxNetFlt
70 LOADED=`kextstat -b org.virtualbox.kext.VBoxNetFlt -l`
71 if test -n "$LOADED"; then
72 echo "load.sh: failed to unload org.virtualbox.kext.VBoxNetFlt, see above..."
73 exit 1;
74 fi
75 echo "load.sh: Successfully unloaded org.virtualbox.kext.VBoxNetFlt"
76fi
77
78# Try unload any existing instance first.
79LOADED=`kextstat -b $BUNDLE -l`
80if test -n "$LOADED"; then
81 echo "load.sh: Unloading $BUNDLE..."
82 sudo kextunload -v 6 -b $BUNDLE
83 LOADED=`kextstat -b $BUNDLE -l`
84 if test -n "$LOADED"; then
85 echo "load.sh: failed to unload $BUNDLE, see above..."
86 exit 1;
87 fi
88 echo "load.sh: Successfully unloaded $BUNDLE"
89fi
90
91set -e
92
93# Copy the .kext to the symbols directory and tweak the kextload options.
94if test -n "$VBOX_DARWIN_SYMS"; then
95 echo "load.sh: copying the extension the symbol area..."
96 rm -Rf "$VBOX_DARWIN_SYMS/$DRVNAME"
97 mkdir -p "$VBOX_DARWIN_SYMS"
98 cp -R "$DIR" "$VBOX_DARWIN_SYMS/"
99 OPTS="$OPTS -s $VBOX_DARWIN_SYMS/ "
100 sync
101fi
102
103trap "sudo chown -R `whoami` $DIR; exit 1" INT
104# On smbfs, this might succeed just fine but make no actual changes,
105# so we might have to temporarily copy the driver to a local directory.
106sudo chown -R root:wheel "$DIR"
107OWNER=`/usr/bin/stat -f "%u" "$DIR"`
108if test "$OWNER" -ne 0; then
109 TMP_DIR=/tmp/loaddrv.tmp
110 echo "load.sh: chown didn't work on $DIR, using temp location $TMP_DIR/$DRVNAME"
111
112 # clean up first (no sudo rm)
113 if test -e "$TMP_DIR"; then
114 sudo chown -R `whoami` "$TMP_DIR"
115 rm -Rf "$TMP_DIR"
116 fi
117
118 # make a copy and switch over DIR
119 mkdir -p "$TMP_DIR/"
120 sudo cp -Rp "$DIR" "$TMP_DIR/"
121 DIR="$TMP_DIR/$DRVNAME"
122
123 # retry
124 sudo chown -R root:wheel "$DIR"
125fi
126sudo chmod -R o-rwx "$DIR"
127sync
128echo "load.sh: loading $DIR..."
129sudo kextload $OPTS "$DIR"
130sync
131sudo chown -R `whoami` "$DIR"
132#sudo chmod 666 /dev/vboxdrv
133kextstat | grep org.virtualbox.kext
134
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