VirtualBox

source: vbox/trunk/debian/postinst.in@ 32015

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

deb: sync

檔案大小: 8.2 KB
 
1#!/bin/sh
2#
3# Copyright (C) 2006-2010 Oracle Corporation
4#
5# This file is part of VirtualBox Open Source Edition (OSE), as
6# available from http://www.alldomusa.eu.org. This file is free software;
7# you can redistribute it and/or modify it under the terms of the GNU
8# General Public License as published by the Free Software Foundation,
9# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
10# distribution. VirtualBox OSE is distributed in the hope that it will
11# be useful, but WITHOUT ANY WARRANTY of any kind.
12#
13
14# we can be called with the following arguments (6.5 of Debian policy):
15# configure: (our version): installing/configuring new version
16# abort-upgrade: (old version): upgrading to a new version failed
17# abort-remove: (our version): removing this package failed
18# abort-deconfigure: (our version): error during resolving conflicts
19
20LOG="/var/log/vbox-install.log"
21
22# defaults
23[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
24
25if [ "$1" = "configure" ]; then
26
27 # for debconf
28 . /usr/share/debconf/confmodule
29 db_version 2.0
30
31 # remove old cruft
32 if [ -f /etc/init.d/vboxdrv.sh ]; then
33 echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
34 rm /etc/init.d/vboxdrv.sh
35 update-rc.d vboxdrv.sh remove >/dev/null
36 fi
37 if [ -f /etc/vbox/vbox.cfg ]; then
38 echo "Found old version of /etc/vbox/vbox.cfg, removing."
39 rm /etc/vbox/vbox.cfg
40 fi
41
42 # install udev rule (disable with INSTALL_NO_UDEV=1 in /etc/default/virtualbox)
43 if [ -d /etc/udev/rules.d -a "$INSTALL_NO_UDEV" != "1" ]; then
44 udev_call=""
45 udev_app=`which udevadm 2> /dev/null`
46 if [ $? -eq 0 ]; then
47 udev_call="${udev_app} version 2> /dev/null"
48 else
49 udev_app=`which udevinfo 2> /dev/null`
50 if [ $? -eq 0 ]; then
51 udev_call="${udev_app} -V 2> /dev/null"
52 fi
53 fi
54 udev_fix="="
55 if [ "${udev_call}" != "" ]; then
56 udev_out=`${udev_call}`
57 udev_ver=`expr "$udev_out" : '[^0-9]*\([0-9]*\)'`
58 if [ "$udev_ver" = "" -o "$udev_ver" -lt 55 ]; then
59 udev_fix=""
60 fi
61 fi
62 echo "KERNEL=${udev_fix}\"vboxdrv\", NAME=\"vboxdrv\", OWNER=\"root\", GROUP=\"root\", MODE=\"0600\"" \
63 > /etc/udev/rules.d/10-vboxdrv.rules
64 if [ "$INSTALL_NO_GROUP" != "1" ]; then
65 echo "SUBSYSTEM=${udev_fix}\"usb_device\", GROUP=\"vboxusers\", MODE=\"0664\"" \
66 >> /etc/udev/rules.d/10-vboxdrv.rules
67 echo "SUBSYSTEM=${udev_fix}\"usb\", ENV{DEVTYPE}==\"usb_device\", GROUP=\"vboxusers\", MODE=\"0664\"" \
68 >> /etc/udev/rules.d/10-vboxdrv.rules
69 else
70 echo "SUBSYSTEM=${udev_fix}\"usb_device\", GROUP=\"root\", MODE=\"0664\"" \
71 >> /etc/udev/rules.d/10-vboxdrv.rules
72 echo "SUBSYSTEM=${udev_fix}\"usb\", ENV{DEVTYPE}==\"usb_device\", GROUP=\"root\", MODE=\"0664\"" \
73 >> /etc/udev/rules.d/10-vboxdrv.rules
74 fi
75 fi
76 # Remove old udev description file
77 if [ -f /etc/udev/rules.d/60-vboxdrv.rules ]; then
78 rm -f /etc/udev/rules.d/60-vboxdrv.rules 2> /dev/null
79 fi
80 # Push the permissions to the USB device nodes. One of these should match.
81 # Rather nasty to use udevadm trigger for this, but I don't know of any
82 # better way.
83 udevadm trigger --subsystem-match=usb > /dev/null 2>&1
84 udevtrigger --subsystem-match=usb > /dev/null 2>&1
85 udevtrigger --subsystem-match=usb_device > /dev/null 2>&1
86 udevplug -Busb > /dev/null 2>&1
87
88 # create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
89 if [ "$INSTALL_NO_GROUP" != "1" ]; then
90 db_input low virtualbox/group-vboxusers || true
91 db_go || true
92 addgroup --system vboxusers || true
93 fi
94
95 # try to build a kernel module (disable with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox)
96 REGISTER_DKMS=1
97 if [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko -a "$INSTALL_NO_VBOXDRV" != "1" ]; then
98 db_get virtualbox/module-compilation-allowed
99 if [ "$RET" = "false" ]; then
100 cat << EOF
101Unable to find a precompiled module for the current kernel
102though module compilation denied by debconf setting.
103EOF
104 else
105 db_input low virtualbox/module-compilation-allowed || true
106 db_go || true
107 db_get virtualbox/module-compilation-allowed
108 if [ "$RET" = "true" ]; then
109 # Compile module. Don't show a message box here if everything works well.
110 cat << EOF
111Messages emitted during module compilation will be logged to $LOG.
112EOF
113 rm -f /etc/vbox/module_not_compiled
114 echo "** Compiling vboxdrv" > /var/log/vbox-install.log
115 if ! /usr/share/virtualbox/src/vboxdrv/build_in_tmp \
116 --save-module-symvers /tmp/vboxdrv-Module.symvers \
117 --no-print-directory KBUILD_VERBOSE= \
118 install >> /var/log/vbox-install.log 2>&1; then
119 db_fset virtualbox/module-compilation-failed seen false
120 db_input critical virtualbox/module-compilation-failed || true
121 db_go || true
122 touch /etc/vbox/module_not_compiled
123 # don't abort the installation!
124 else
125 echo "** Compiling vboxnetflt" >> /var/log/vbox-install.log
126 if ! /usr/share/virtualbox/src/vboxnetflt/build_in_tmp \
127 --use-module-symvers /tmp/vboxdrv-Module.symvers \
128 --no-print-directory KBUILD_VERBOSE= \
129 install >> /var/log/vbox-install.log 2>&1; then
130 db_fset virtualbox/module-compilation-failed seen false
131 db_input critical virtualbox/module-compilation-failed || true
132 db_go || true
133 touch /etc/vbox/module_not_compiled
134 # don't abort the installation!
135 else
136 echo "** Compiling vboxnetadp" >> /var/log/vbox-install.log
137 if ! /usr/share/virtualbox/src/vboxnetadp/build_in_tmp \
138 --use-module-symvers /tmp/vboxdrv-Module.symvers \
139 --no-print-directory KBUILD_VERBOSE= \
140 install >> /var/log/vbox-install.log 2>&1; then
141 db_fset virtualbox/module-compilation-failed seen false
142 db_input critical virtualbox/module-compilation-failed || true
143 db_go || true
144 touch /etc/vbox/module_not_compiled
145 # don't abort the installation!
146 fi
147 fi
148 fi
149 # cleanup
150 rm -f /tmp/vboxdrv-Module.symvers
151 if [ ! -f /etc/vbox/module_not_compiled ]; then
152 # success
153 cat << EOF
154Success!
155EOF
156 REGISTER_DKMS=
157 fi
158 fi
159 fi
160 fi
161
162 # Register at DKMS. If the modules were built above, they are already registered
163 if [ -n "$REGISTER_DKMS" ]; then
164 DKMS=`which dkms 2>/dev/null`
165 if [ -n "$DKMS" ]; then
166 for m in vboxdrv vboxnetflt vboxnetadp; do
167 $DKMS status -m $m | while read line; do
168 if echo "$line" | grep -q added > /dev/null ||
169 echo "$line" | grep -q built > /dev/null ||
170 echo "$line" | grep -q installed > /dev/null; then
171 v=`echo "$line" | sed "s/$m,\([^,]*\)[,:].*/\1/;t;d"`
172 $DKMS remove -m $m -v $v --all > /dev/null 2>&1
173 fi
174 done
175 $DKMS add -m $m -v %VER% > /dev/null 2>&1
176 done
177 fi
178 fi
179
180 # There might be an old module active (e.g. manually loaded)
181 if lsmod | grep -q "vboxdrv[^_-]"; then
182 /etc/init.d/vboxdrv stop || true
183 fi
184
185 # The starters need to be Suid root. They drop the privileges before starting
186 # the real frontend.
187 if ! dpkg-statoverride --list /usr/lib/virtualbox/VirtualBox > /dev/null 2>&1; then
188 chmod 4511 /usr/lib/virtualbox/VirtualBox
189 fi
190 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxHeadless > /dev/null 2>&1; then
191 chmod 4511 /usr/lib/virtualbox/VBoxHeadless
192 fi
193 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxSDL > /dev/null 2>&1; then
194 chmod 4511 /usr/lib/virtualbox/VBoxSDL
195 fi
196 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxNetDHCP > /dev/null 2>&1; then
197 chmod 4511 /usr/lib/virtualbox/VBoxNetDHCP
198 fi
199 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxNetAdpCtl > /dev/null 2>&1; then
200 chmod 4511 /usr/lib/virtualbox/VBoxNetAdpCtl
201 fi
202
203 # if INSTALL_NO_VBOXDRV is set to 1, remove all shipped modules
204 if [ "$INSTALL_NO_VBOXDRV" = "1" ]; then
205 rm -f /lib/modules/*/misc/vboxdrv.ko
206 rm -f /lib/modules/*/misc/vboxnetflt.ko
207 rm -f /lib/modules/*/misc/vboxnetadp.ko
208 fi
209
210fi # $1 = "configure"
211
212#DEBHELPER#
213
214exit 0
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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