VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxUSB/darwin/loadusb.sh@ 31896

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

export the VBoxUSB host driver to OSE

  • 屬性 svn:eol-style 設為 LF
  • 屬性 svn:executable 設為 *
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 2.7 KB
 
1#!/bin/bash
2## @file
3# For development.
4#
5
6#
7# Copyright (C) 2006-2010 Oracle Corporation
8#
9# Oracle Corporation confidential
10# All rights reserved
11#
12
13SCRIPT_NAME="loadusb"
14XNU_VERSION=`LC_ALL=C uname -r | LC_ALL=C cut -d . -f 1`
15
16DRVNAME="VBoxUSB.kext"
17BUNDLE="org.virtualbox.kext.VBoxUSB"
18
19DEP_DRVNAME="VBoxDrv.kext"
20DEP_BUNDLE="org.virtualbox.kext.VBoxDrv"
21
22
23DIR=`dirname "$0"`
24DIR=`cd "$DIR" && pwd`
25DEP_DIR="$DIR/$DEP_DRVNAME"
26DIR="$DIR/$DRVNAME"
27if [ ! -d "$DIR" ]; then
28 echo "Cannot find $DIR or it's not a directory..."
29 exit 1;
30fi
31if [ ! -d "$DEP_DIR" ]; then
32 echo "Cannot find $DEP_DIR or it's not a directory... (dependency)"
33 exit 1;
34fi
35if [ -n "$*" ]; then
36 OPTS="$*"
37else
38 OPTS="-t"
39fi
40
41trap "sudo chown -R `whoami` $DIR $DEP_DIR; exit 1" INT
42
43# Try unload any existing instance first.
44LOADED=`kextstat -b $BUNDLE -l`
45if test -n "$LOADED"; then
46 echo "${SCRIPT_NAME}.sh: Unloading $BUNDLE..."
47 sudo kextunload -v 6 -b $BUNDLE
48 LOADED=`kextstat -b $BUNDLE -l`
49 if test -n "$LOADED"; then
50 echo "${SCRIPT_NAME}.sh: failed to unload $BUNDLE, see above..."
51 exit 1;
52 fi
53 echo "${SCRIPT_NAME}.sh: Successfully unloaded $BUNDLE"
54fi
55
56set -e
57
58# Copy the .kext to the symbols directory and tweak the kextload options.
59if test -n "$VBOX_DARWIN_SYMS"; then
60 echo "${SCRIPT_NAME}.sh: copying the extension the symbol area..."
61 rm -Rf "$VBOX_DARWIN_SYMS/$DRVNAME"
62 mkdir -p "$VBOX_DARWIN_SYMS"
63 cp -R "$DIR" "$VBOX_DARWIN_SYMS/"
64 OPTS="$OPTS -s $VBOX_DARWIN_SYMS/ "
65 sync
66fi
67
68# On smbfs, this might succeed just fine but make no actual changes,
69# so we might have to temporarily copy the driver to a local directory.
70if sudo chown -R root:wheel "$DIR" "$DEP_DIR"; then
71 OWNER=`/usr/bin/stat -f "%u" "$DIR"`
72else
73 OWNER=1000
74fi
75if test "$OWNER" -ne 0; then
76 TMP_DIR=/tmp/${SCRIPT_NAME}.tmp
77 echo "${SCRIPT_NAME}.sh: chown didn't work on $DIR, using temp location $TMP_DIR/$DRVNAME"
78
79 # clean up first (no sudo rm)
80 if test -e "$TMP_DIR"; then
81 sudo chown -R `whoami` "$TMP_DIR"
82 rm -Rf "$TMP_DIR"
83 fi
84
85 # make a copy and switch over DIR
86 mkdir -p "$TMP_DIR/"
87 sudo cp -Rp "$DIR" "$TMP_DIR/"
88 DIR="$TMP_DIR/$DRVNAME"
89
90 # load.sh puts it here.
91 DEP_DIR="/tmp/loaddrv.tmp/$DEP_DRVNAME"
92
93 # retry
94 sudo chown -R root:wheel "$DIR" "$DEP_DIR"
95fi
96
97sudo chmod -R o-rwx "$DIR"
98sync
99if [ "$XNU_VERSION" -ge "10" ]; then
100 echo "${SCRIPT_NAME}.sh: loading $DIR... (kextutil $OPTS -d \"$DEP_DIR\" \"$DIR\")"
101 sudo kextutil $OPTS -d "$DEP_DIR" "$DIR"
102else
103 echo "${SCRIPT_NAME}.sh: loading $DIR... (kextload $OPTS -d \"$DEP_DIR\" \"$DIR\")"
104 sudo kextload $OPTS -d "$DEP_DIR" "$DIR"
105fi
106sync
107sudo chown -R `whoami` "$DIR" "$DEP_DIR"
108kextstat | grep org.virtualbox.kext
109
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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