1 | #
|
---|
2 | # Spec file for creating VirtualBox rpm packages
|
---|
3 | #
|
---|
4 |
|
---|
5 | #
|
---|
6 | # Copyright (C) 2006-2011 Oracle Corporation
|
---|
7 | #
|
---|
8 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | # available from http://www.virtualbox.org. This file is free software;
|
---|
10 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | # General Public License as published by the Free Software Foundation,
|
---|
12 | # in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
13 | # distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
14 | # be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | #
|
---|
16 |
|
---|
17 | %define %SPEC% 1
|
---|
18 | %{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
|
---|
19 |
|
---|
20 | Summary: Oracle VM VirtualBox
|
---|
21 | Name: %NAME%
|
---|
22 | Version: %BUILDVER%_%BUILDREL%
|
---|
23 | Release: 1
|
---|
24 | URL: http://www.virtualbox.org/
|
---|
25 | Source: VirtualBox.tar.bz2
|
---|
26 | License: GPLv2
|
---|
27 | Group: Applications/System
|
---|
28 | Vendor: Oracle Corporation
|
---|
29 | BuildRoot: %BUILDROOT%
|
---|
30 | Requires: %LIBASOUND%
|
---|
31 |
|
---|
32 | %if %{?rpm_suse:1}%{!?rpm_suse:0}
|
---|
33 | %debug_package
|
---|
34 | %endif
|
---|
35 |
|
---|
36 | %MACROSPYTHON%
|
---|
37 |
|
---|
38 |
|
---|
39 | %description
|
---|
40 | VirtualBox is a powerful PC virtualization solution allowing
|
---|
41 | you to run a wide range of PC operating systems on your Linux
|
---|
42 | system. This includes Windows, Linux, FreeBSD, DOS, OpenBSD
|
---|
43 | and others. VirtualBox comes with a broad feature set and
|
---|
44 | excellent performance, making it the premier virtualization
|
---|
45 | software solution on the market.
|
---|
46 |
|
---|
47 |
|
---|
48 | %prep
|
---|
49 | %setup -q
|
---|
50 | DESTDIR=""
|
---|
51 | unset DESTDIR
|
---|
52 |
|
---|
53 |
|
---|
54 | %build
|
---|
55 |
|
---|
56 |
|
---|
57 | %install
|
---|
58 | # Mandriva: prevent replacing 'echo' by 'gprintf'
|
---|
59 | export DONT_GPRINTIFY=1
|
---|
60 | rm -rf $RPM_BUILD_ROOT
|
---|
61 | install -m 755 -d $RPM_BUILD_ROOT/sbin
|
---|
62 | install -m 755 -d $RPM_BUILD_ROOT%{_initrddir}
|
---|
63 | install -m 755 -d $RPM_BUILD_ROOT/lib/modules
|
---|
64 | install -m 755 -d $RPM_BUILD_ROOT/etc/vbox
|
---|
65 | install -m 755 -d $RPM_BUILD_ROOT/usr/bin
|
---|
66 | install -m 755 -d $RPM_BUILD_ROOT/usr/src
|
---|
67 | install -m 755 -d $RPM_BUILD_ROOT/usr/share/applications
|
---|
68 | install -m 755 -d $RPM_BUILD_ROOT/usr/share/pixmaps
|
---|
69 | install -m 755 -d $RPM_BUILD_ROOT/usr/share/icons/hicolor
|
---|
70 | install -m 755 -d $RPM_BUILD_ROOT%{_defaultdocdir}/virtualbox
|
---|
71 | install -m 755 -d $RPM_BUILD_ROOT/usr/lib/virtualbox
|
---|
72 | install -m 755 -d $RPM_BUILD_ROOT/usr/lib/virtualbox/ExtensionPacks
|
---|
73 | install -m 755 -d $RPM_BUILD_ROOT/usr/share/virtualbox
|
---|
74 | install -m 755 -d $RPM_BUILD_ROOT/usr/share/mime/packages
|
---|
75 | mv VBoxEFI32.fd $RPM_BUILD_ROOT/usr/lib/virtualbox || true
|
---|
76 | mv VBoxEFI64.fd $RPM_BUILD_ROOT/usr/lib/virtualbox || true
|
---|
77 | mv *.gc $RPM_BUILD_ROOT/usr/lib/virtualbox
|
---|
78 | mv *.r0 $RPM_BUILD_ROOT/usr/lib/virtualbox
|
---|
79 | mv *.rel $RPM_BUILD_ROOT/usr/lib/virtualbox || true
|
---|
80 | mv VBoxNetDHCP $RPM_BUILD_ROOT/usr/lib/virtualbox
|
---|
81 | mv VBoxNetAdpCtl $RPM_BUILD_ROOT/usr/lib/virtualbox
|
---|
82 | mv VBoxXPCOMIPCD $RPM_BUILD_ROOT/usr/lib/virtualbox
|
---|
83 | mv components $RPM_BUILD_ROOT/usr/lib/virtualbox/components
|
---|
84 | mv *.so $RPM_BUILD_ROOT/usr/lib/virtualbox
|
---|
85 | mv *.so.4 $RPM_BUILD_ROOT/usr/lib/virtualbox || true
|
---|
86 | mv VBoxTestOGL $RPM_BUILD_ROOT/usr/lib/virtualbox
|
---|
87 | mv vboxshell.py $RPM_BUILD_ROOT/usr/lib/virtualbox
|
---|
88 | (export VBOX_INSTALL_PATH=/usr/lib/virtualbox && \
|
---|
89 | cd ./sdk/installer && \
|
---|
90 | %{__python} ./vboxapisetup.py install --prefix %{_prefix} --root $RPM_BUILD_ROOT)
|
---|
91 | rm -rf sdk/installer
|
---|
92 | mv sdk $RPM_BUILD_ROOT/usr/lib/virtualbox
|
---|
93 | mv nls $RPM_BUILD_ROOT/usr/share/virtualbox
|
---|
94 | cp -a src $RPM_BUILD_ROOT/usr/share/virtualbox
|
---|
95 | mv VBox.sh $RPM_BUILD_ROOT/usr/bin/VBox
|
---|
96 | mv VBoxSysInfo.sh $RPM_BUILD_ROOT/usr/share/virtualbox
|
---|
97 | mv VBoxCreateUSBNode.sh $RPM_BUILD_ROOT/usr/share/virtualbox
|
---|
98 | cp icons/128x128/virtualbox.png $RPM_BUILD_ROOT/usr/share/pixmaps/virtualbox.png
|
---|
99 | cd icons
|
---|
100 | for i in *; do
|
---|
101 | if [ -f $i/virtualbox.png ]; then
|
---|
102 | install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/apps
|
---|
103 | mv $i/virtualbox.png $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/apps
|
---|
104 | fi
|
---|
105 | install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes
|
---|
106 | mv $i/* $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes || true
|
---|
107 | rmdir $i
|
---|
108 | done
|
---|
109 | cd -
|
---|
110 | rmdir icons
|
---|
111 | mv virtualbox.xml $RPM_BUILD_ROOT/usr/share/mime/packages
|
---|
112 | for i in VBoxManage VBoxSVC VBoxSDL VirtualBox VBoxHeadless VBoxExtPackHelperApp VBoxBalloonCtrl vboxwebsrv webtest; do
|
---|
113 | mv $i $RPM_BUILD_ROOT/usr/lib/virtualbox; done
|
---|
114 | for i in VBoxSDL VirtualBox VBoxHeadless VBoxNetDHCP VBoxNetAdpCtl; do
|
---|
115 | chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/$i; done
|
---|
116 | mv VBoxTunctl $RPM_BUILD_ROOT/usr/bin
|
---|
117 | for d in /lib/modules/*; do
|
---|
118 | if [ -L $d/build ]; then
|
---|
119 | rm -f /tmp/vboxdrv-Module.symvers
|
---|
120 | ./src/vboxhost/vboxdrv/build_in_tmp \
|
---|
121 | --save-module-symvers /tmp/vboxdrv-Module.symvers \
|
---|
122 | KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
|
---|
123 | %INSTMOD%
|
---|
124 | ./src/vboxhost/vboxnetflt/build_in_tmp \
|
---|
125 | --use-module-symvers /tmp/vboxdrv-Module.symvers \
|
---|
126 | KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
|
---|
127 | %INSTMOD%
|
---|
128 | ./src/vboxhost/vboxnetadp/build_in_tmp \
|
---|
129 | --use-module-symvers /tmp/vboxdrv-Module.symvers \
|
---|
130 | KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
|
---|
131 | %INSTMOD%
|
---|
132 | ./src/vboxhost/vboxpci/build_in_tmp \
|
---|
133 | --use-module-symvers /tmp/vboxdrv-Module.symvers \
|
---|
134 | KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
|
---|
135 | %INSTMOD%
|
---|
136 | fi
|
---|
137 | done
|
---|
138 | mv kchmviewer $RPM_BUILD_ROOT/usr/lib/virtualbox
|
---|
139 | for i in rdesktop-vrdp.tar.gz rdesktop-vrdp-keymaps additions/VBoxGuestAdditions.iso; do
|
---|
140 | mv $i $RPM_BUILD_ROOT/usr/share/virtualbox; done
|
---|
141 | if [ -d accessible ]; then
|
---|
142 | mv accessible $RPM_BUILD_ROOT/usr/lib/virtualbox
|
---|
143 | fi
|
---|
144 | mv rdesktop-vrdp $RPM_BUILD_ROOT/usr/bin
|
---|
145 | install -D -m 755 vboxdrv.init $RPM_BUILD_ROOT%{_initrddir}/vboxdrv
|
---|
146 | %if %{?rpm_suse:1}%{!?rpm_suse:0}
|
---|
147 | ln -sf ../etc/init.d/vboxdrv $RPM_BUILD_ROOT/sbin/rcvboxdrv
|
---|
148 | %endif
|
---|
149 | install -D -m 755 vboxballoonctrl-service.init $RPM_BUILD_ROOT%{_initrddir}/vboxballoonctrl-service
|
---|
150 | install -D -m 755 vboxweb-service.init $RPM_BUILD_ROOT%{_initrddir}/vboxweb-service
|
---|
151 | %if %{?rpm_suse:1}%{!?rpm_suse:0}
|
---|
152 | ln -sf ../etc/init.d/vboxballoonctrl-service $RPM_BUILD_ROOT/sbin/rcvboxballoonctrl-service
|
---|
153 | ln -sf ../etc/init.d/vboxweb-service $RPM_BUILD_ROOT/sbin/rcvboxweb-service
|
---|
154 | %endif
|
---|
155 | ln -s VBox $RPM_BUILD_ROOT/usr/bin/VirtualBox
|
---|
156 | ln -s VBox $RPM_BUILD_ROOT/usr/bin/virtualbox
|
---|
157 | ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxManage
|
---|
158 | ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxmanage
|
---|
159 | ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxSDL
|
---|
160 | ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxsdl
|
---|
161 | ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxVRDP
|
---|
162 | ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxHeadless
|
---|
163 | ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxheadless
|
---|
164 | ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxBalloonCtrl
|
---|
165 | ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxballoonctrl
|
---|
166 | ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxwebsrv
|
---|
167 | ln -s /usr/share/virtualbox/src/vboxhost $RPM_BUILD_ROOT/usr/src/vboxhost-%VER%
|
---|
168 | mv virtualbox.desktop $RPM_BUILD_ROOT/usr/share/applications/virtualbox.desktop
|
---|
169 | mv VBox.png $RPM_BUILD_ROOT/usr/share/pixmaps/VBox.png
|
---|
170 |
|
---|
171 |
|
---|
172 | %pre
|
---|
173 | # defaults
|
---|
174 | [ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
|
---|
175 |
|
---|
176 | # check for active VMs of the installed (old) package
|
---|
177 | VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null || true`
|
---|
178 | if [ -n "$VBOXSVC_PID" ]; then
|
---|
179 | # executed before the new package is installed!
|
---|
180 | if [ -f /etc/init.d/vboxballoonctrl-service ]; then
|
---|
181 | # try graceful termination; terminate the balloon control service first
|
---|
182 | /etc/init.d/vboxballoonctrl-service stop 2>/dev/null || true
|
---|
183 | fi
|
---|
184 | if [ -f /etc/init.d/vboxweb-service ]; then
|
---|
185 | # try graceful termination; terminate the webservice first
|
---|
186 | /etc/init.d/vboxweb-service stop 2>/dev/null || true
|
---|
187 | fi
|
---|
188 | # ask the daemon to terminate immediately
|
---|
189 | kill -USR1 $VBOXSVC_PID
|
---|
190 | sleep 1
|
---|
191 | if pidof VBoxSVC > /dev/null 2>&1; then
|
---|
192 | echo "A copy of VirtualBox is currently running. Please close it and try again."
|
---|
193 | echo "Please note that it can take up to ten seconds for VirtualBox (in particular"
|
---|
194 | echo "the VBoxSVC daemon) to finish running."
|
---|
195 | exit 1
|
---|
196 | fi
|
---|
197 | fi
|
---|
198 |
|
---|
199 | # check for old installation
|
---|
200 | if [ -r /etc/vbox/vbox.cfg ]; then
|
---|
201 | . /etc/vbox/vbox.cfg
|
---|
202 | if [ "x$INSTALL_DIR" != "x" -a -d "$INSTALL_DIR" ]; then
|
---|
203 | echo "An old installation of VirtualBox was found. To install this package the"
|
---|
204 | echo "old package has to be removed first. Have a look at /etc/vbox/vbox.cfg to"
|
---|
205 | echo "determine the installation directory of the previous installation. After"
|
---|
206 | echo "uninstalling the old package remove the file /etc/vbox/vbox.cfg."
|
---|
207 | exit 1
|
---|
208 | fi
|
---|
209 | fi
|
---|
210 |
|
---|
211 | # XXX remove old modules from previous versions (disable with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox)
|
---|
212 | if [ "$INSTALL_NO_VBOXDRV" != "1" ]; then
|
---|
213 | find /lib/modules -name "vboxdrv\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
|
---|
214 | find /lib/modules -name "vboxnetflt\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
|
---|
215 | find /lib/modules -name "vboxnetadp\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
|
---|
216 | find /lib/modules -name "vboxpci\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
|
---|
217 | fi
|
---|
218 |
|
---|
219 |
|
---|
220 | %post
|
---|
221 | LOG="/var/log/vbox-install.log"
|
---|
222 |
|
---|
223 | # defaults
|
---|
224 | [ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
|
---|
225 |
|
---|
226 | # remove old cruft
|
---|
227 | if [ -f /etc/init.d/vboxdrv.sh ]; then
|
---|
228 | echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
|
---|
229 | rm /etc/init.d/vboxdrv.sh
|
---|
230 | fi
|
---|
231 | if [ -f /etc/vbox/vbox.cfg ]; then
|
---|
232 | echo "Found old version of /etc/vbox/vbox.cfg, removing."
|
---|
233 | rm /etc/vbox/vbox.cfg
|
---|
234 | fi
|
---|
235 | rm -f /etc/vbox/module_not_compiled
|
---|
236 |
|
---|
237 | # install udev rule (disable with INSTALL_NO_UDEV=1 in /etc/default/virtualbox)
|
---|
238 | if [ -d /etc/udev/rules.d -a "$INSTALL_NO_UDEV" != "1" ]; then
|
---|
239 | udev_call=""
|
---|
240 | udev_app=`which udevadm 2> /dev/null`
|
---|
241 | if [ $? -eq 0 ]; then
|
---|
242 | udev_call="${udev_app} version 2> /dev/null"
|
---|
243 | else
|
---|
244 | udev_app=`which udevinfo 2> /dev/null`
|
---|
245 | if [ $? -eq 0 ]; then
|
---|
246 | udev_call="${udev_app} -V 2> /dev/null"
|
---|
247 | fi
|
---|
248 | fi
|
---|
249 | udev_fix="="
|
---|
250 | if [ "${udev_call}" != "" ]; then
|
---|
251 | udev_out=`${udev_call}`
|
---|
252 | udev_ver=`expr "$udev_out" : '[^0-9]*\([0-9]*\)'`
|
---|
253 | if [ "$udev_ver" = "" -o "$udev_ver" -lt 55 ]; then
|
---|
254 | udev_fix=""
|
---|
255 | fi
|
---|
256 | fi
|
---|
257 | usb_createnode="/usr/share/virtualbox/VBoxCreateUSBNode.sh"
|
---|
258 | echo "KERNEL=${udev_fix}\"vboxdrv\", NAME=\"vboxdrv\", OWNER=\"root\", GROUP=\"root\", MODE=\"0600\"" \
|
---|
259 | > /etc/udev/rules.d/10-vboxdrv.rules
|
---|
260 | echo "SUBSYSTEM=${udev_fix}\"usb_device\", ACTION=${udev_fix}\"add\", RUN=\"${usb_createnode} \$major \$minor \$attr{bDeviceClass}\"" \
|
---|
261 | >> /etc/udev/rules.d/10-vboxdrv.rules
|
---|
262 | echo "SUBSYSTEM=${udev_fix}\"usb\", ACTION=${udev_fix}\"add\", ENV{DEVTYPE}==\"usb_device\", RUN=\"${usb_createnode} \$major \$minor \$attr{bDeviceClass}\"" \
|
---|
263 | >> /etc/udev/rules.d/10-vboxdrv.rules
|
---|
264 | echo "SUBSYSTEM=${udev_fix}\"usb_device\", ACTION=${udev_fix}\"remove\", RUN=\"${usb_createnode} --remove \$major \$minor\"" \
|
---|
265 | >> /etc/udev/rules.d/10-vboxdrv.rules
|
---|
266 | echo "SUBSYSTEM=${udev_fix}\"usb\", ACTION=${udev_fix}\"remove\", ENV{DEVTYPE}==\"usb_device\", RUN=\"${usb_createnode} --remove \$major \$minor\"" \
|
---|
267 | >> /etc/udev/rules.d/10-vboxdrv.rules
|
---|
268 | fi
|
---|
269 | # Remove old udev description file
|
---|
270 | if [ -f /etc/udev/rules.d/60-vboxdrv.rules ]; then
|
---|
271 | rm -f /etc/udev/rules.d/60-vboxdrv.rules 2> /dev/null
|
---|
272 | fi
|
---|
273 | # Build our device tree
|
---|
274 | for i in /sys/bus/usb/devices/*; do
|
---|
275 | if test -r "$i/dev"; then
|
---|
276 | dev="`cat "$i/dev" 2> /dev/null`"
|
---|
277 | major="`expr "$dev" : '\(.*\):' 2> /dev/null`"
|
---|
278 | minor="`expr "$dev" : '.*:\(.*\)' 2> /dev/null`"
|
---|
279 | class="`cat $i/bDeviceClass 2> /dev/null`"
|
---|
280 | sh ${usb_createnode} "$major" "$minor" "$class" ${usb_group} 2>/dev/null
|
---|
281 | fi
|
---|
282 | done
|
---|
283 |
|
---|
284 | # XXX SELinux: allow text relocation entries
|
---|
285 | %if %{?rpm_redhat:1}%{!?rpm_redhat:0}
|
---|
286 | if [ -x /usr/bin/chcon ]; then
|
---|
287 | chcon -t texrel_shlib_t /usr/lib/virtualbox/*VBox* > /dev/null 2>&1
|
---|
288 | chcon -t texrel_shlib_t /usr/lib/virtualbox/VirtualBox.so > /dev/null 2>&1
|
---|
289 | chcon -t texrel_shlib_t /usr/lib/virtualbox/VBoxAuth.so > /dev/null 2>&1
|
---|
290 | chcon -t texrel_shlib_t /usr/lib/virtualbox/components/VBox*.so > /dev/null 2>&1
|
---|
291 | chcon -t java_exec_t /usr/lib/virtualbox/VirtualBox > /dev/null 2>&1
|
---|
292 | chcon -t java_exec_t /usr/lib/virtualbox/VBoxSDL > /dev/null 2>&1
|
---|
293 | chcon -t java_exec_t /usr/lib/virtualbox/VBoxHeadless > /dev/null 2>&1
|
---|
294 | chcon -t java_exec_t /usr/lib/virtualbox/VBoxExtPackHelperApp > /dev/null 2>&1
|
---|
295 | chcon -t java_exec_t /usr/lib/virtualbox/VBoxBalloonCtrl > /dev/null 2>&1
|
---|
296 | chcon -t java_exec_t /usr/lib/virtualbox/vboxwebsrv > /dev/null 2>&1
|
---|
297 | fi
|
---|
298 | %endif
|
---|
299 |
|
---|
300 | # create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
|
---|
301 | if [ "$INSTALL_NO_GROUP" != "1" ]; then
|
---|
302 | echo
|
---|
303 | echo "Creating group 'vboxusers'. VM users must be member of that group!"
|
---|
304 | echo
|
---|
305 | groupadd -f vboxusers 2> /dev/null
|
---|
306 | fi
|
---|
307 | %if %{?rpm_redhat:1}%{!?rpm_redhat:0}
|
---|
308 | /sbin/chkconfig --add vboxdrv
|
---|
309 | /sbin/chkconfig --add vboxballoonctrl-service
|
---|
310 | /sbin/chkconfig --add vboxweb-service
|
---|
311 | %endif
|
---|
312 | %if %{?rpm_suse:1}%{!?rpm_suse:0}
|
---|
313 | %{fillup_and_insserv -f -y -Y vboxdrv vboxballoonctrl-service vboxweb-service}
|
---|
314 | %endif
|
---|
315 | %if %{?rpm_mdv:1}%{!?rpm_mdv:0}
|
---|
316 | /sbin/ldconfig
|
---|
317 | %_post_service vboxdrv
|
---|
318 | %_post_service vboxballoonctrl-service
|
---|
319 | %_post_service vboxweb-service
|
---|
320 | %update_menus
|
---|
321 | %endif
|
---|
322 | update-mime-database /usr/share/mime &> /dev/null || :
|
---|
323 | update-desktop-database -q > /dev/null 2>&1 || :
|
---|
324 | touch --no-create /usr/share/icons/hicolor
|
---|
325 | gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
|
---|
326 |
|
---|
327 | # Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
|
---|
328 | BUILD_MODULES=0
|
---|
329 | REGISTER_MODULES=1
|
---|
330 | if [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko ]; then
|
---|
331 | REGISTER_MODULES=0
|
---|
332 | if [ "$INSTALL_NO_VBOXDRV" != "1" ]; then
|
---|
333 | # compile problem
|
---|
334 | cat << EOF
|
---|
335 | No precompiled module for this kernel found -- trying to build one. Messages
|
---|
336 | emitted during module compilation will be logged to $LOG.
|
---|
337 |
|
---|
338 | EOF
|
---|
339 | BUILD_MODULES=1
|
---|
340 | fi
|
---|
341 | fi
|
---|
342 | # if INSTALL_NO_VBOXDRV is set to 1, remove all shipped modules
|
---|
343 | if [ "$INSTALL_NO_VBOXDRV" = "1" ]; then
|
---|
344 | rm -f /lib/modules/*/misc/vboxdrv.ko
|
---|
345 | rm -f /lib/modules/*/misc/vboxnetflt.ko
|
---|
346 | rm -f /lib/modules/*/misc/vboxnetadp.ko
|
---|
347 | rm -f /lib/modules/*/misc/vboxpci.ko
|
---|
348 | fi
|
---|
349 | if [ $BUILD_MODULES -eq 1 ]; then
|
---|
350 | /etc/init.d/vboxdrv setup || true
|
---|
351 | else
|
---|
352 | if lsmod | grep -q "vboxdrv[^_-]"; then
|
---|
353 | /etc/init.d/vboxdrv stop || true
|
---|
354 | fi
|
---|
355 | if [ $REGISTER_MODULES -eq 1 ]; then
|
---|
356 | DKMS=`which dkms 2>/dev/null`
|
---|
357 | if [ -n "$DKMS" ]; then
|
---|
358 | $DKMS remove -m vboxhost -v %VER% --all > /dev/null 2>&1 || true
|
---|
359 | fi
|
---|
360 | fi
|
---|
361 | /etc/init.d/vboxdrv start > /dev/null
|
---|
362 | fi
|
---|
363 | /etc/init.d/vboxballoonctrl-service start > /dev/null
|
---|
364 | /etc/init.d/vboxweb-service start > /dev/null
|
---|
365 |
|
---|
366 |
|
---|
367 | %preun
|
---|
368 | # $1==0: remove the last version of the package
|
---|
369 | # $1==1: install the first time
|
---|
370 | # $1>=2: upgrade
|
---|
371 | %if %{?rpm_suse:1}%{!?rpm_suse:0}
|
---|
372 | %stop_on_removal vboxballoonctrl-service
|
---|
373 | %stop_on_removal vboxweb-service
|
---|
374 | %endif
|
---|
375 | %if %{?rpm_mdv:1}%{!?rpm_mdv:0}
|
---|
376 | %_preun_service vboxballoonctrl-service
|
---|
377 | %_preun_service vboxweb-service
|
---|
378 | %endif
|
---|
379 | %if %{?rpm_redhat:1}%{!?rpm_redhat:0}
|
---|
380 | if [ "$1" = 0 ]; then
|
---|
381 | /sbin/service vboxballoonctrl-service stop > /dev/null
|
---|
382 | /sbin/chkconfig --del vboxballoonctrl-service
|
---|
383 | /sbin/service vboxweb-service stop > /dev/null
|
---|
384 | /sbin/chkconfig --del vboxweb-service
|
---|
385 | fi
|
---|
386 | %endif
|
---|
387 |
|
---|
388 | if [ "$1" = 0 ]; then
|
---|
389 | # check for active VMs
|
---|
390 | VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null || true`
|
---|
391 | if [ -n "$VBOXSVC_PID" ]; then
|
---|
392 | kill -USR1 $VBOXSVC_PID
|
---|
393 | sleep 1
|
---|
394 | if pidof VBoxSVC > /dev/null 2>&1; then
|
---|
395 | echo "A copy of VirtualBox is currently running. Please close it and try again."
|
---|
396 | echo "Please note that it can take up to ten seconds for VirtualBox (in particular"
|
---|
397 | echo "the VBoxSVC daemon) to finish running."
|
---|
398 | exit 1
|
---|
399 | fi
|
---|
400 | fi
|
---|
401 | fi
|
---|
402 | %if %{?rpm_suse:1}%{!?rpm_suse:0}
|
---|
403 | %stop_on_removal vboxdrv
|
---|
404 | %endif
|
---|
405 | %if %{?rpm_mdv:1}%{!?rpm_mdv:0}
|
---|
406 | %_preun_service vboxdrv
|
---|
407 | %endif
|
---|
408 | if [ "$1" = 0 ]; then
|
---|
409 | %if %{?rpm_redhat:1}%{!?rpm_redhat:0}
|
---|
410 | /sbin/service vboxdrv stop > /dev/null
|
---|
411 | /sbin/chkconfig --del vboxdrv
|
---|
412 | %endif
|
---|
413 | rm -f /etc/udev/rules.d/10-vboxdrv.rules
|
---|
414 | rm -f /etc/vbox/license_agreed
|
---|
415 | rm -f /etc/vbox/module_not_compiled
|
---|
416 | fi
|
---|
417 | DKMS=`which dkms 2>/dev/null`
|
---|
418 | if [ -n "$DKMS" ]; then
|
---|
419 | $DKMS remove -m vboxhost -v %VER% --all > /dev/null 2>&1 || true
|
---|
420 | fi
|
---|
421 |
|
---|
422 |
|
---|
423 | %postun
|
---|
424 | %if %{?rpm_redhat:1}%{!?rpm_redhat:0}
|
---|
425 | if [ "$1" -ge 1 ]; then
|
---|
426 | /sbin/service vboxdrv restart > /dev/null 2>&1
|
---|
427 | /sbin/service vboxballoonctrl-service restart > /dev/null 2>&1
|
---|
428 | /sbin/service vboxweb-service restart > /dev/null 2>&1
|
---|
429 | fi
|
---|
430 | %endif
|
---|
431 | %if %{?rpm_suse:1}%{!?rpm_suse:0}
|
---|
432 | %restart_on_update vboxdrv vboxballoonctrl-service vboxweb-service
|
---|
433 | %insserv_cleanup
|
---|
434 | %endif
|
---|
435 | %if %{?rpm_mdv:1}%{!?rpm_mdv:0}
|
---|
436 | /sbin/ldconfig
|
---|
437 | %{clean_desktop_database}
|
---|
438 | %clean_menus
|
---|
439 | %endif
|
---|
440 | update-mime-database /usr/share/mime &> /dev/null || :
|
---|
441 | update-desktop-database -q > /dev/null 2>&1 || :
|
---|
442 | touch --no-create /usr/share/icons/hicolor
|
---|
443 | gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
|
---|
444 |
|
---|
445 |
|
---|
446 | %clean
|
---|
447 | rm -rf $RPM_BUILD_ROOT
|
---|
448 |
|
---|
449 |
|
---|
450 | %files
|
---|
451 | %defattr(-,root,root)
|
---|
452 | %doc LICENSE
|
---|
453 | %doc UserManual*.pdf
|
---|
454 | %doc VirtualBox*.chm
|
---|
455 | %{_initrddir}/vboxdrv
|
---|
456 | %{_initrddir}/vboxballoonctrl-service
|
---|
457 | %{_initrddir}/vboxweb-service
|
---|
458 | %{?rpm_suse: %{py_sitedir}/*}
|
---|
459 | %{!?rpm_suse: %{python_sitelib}/*}
|
---|
460 | %{?rpm_suse: /sbin/rcvboxdrv}
|
---|
461 | %{?rpm_suse: /sbin/rcvboxballoonctrl-service}
|
---|
462 | %{?rpm_suse: /sbin/rcvboxweb-service}
|
---|
463 | /lib/modules
|
---|
464 | /etc/vbox
|
---|
465 | /usr/bin
|
---|
466 | /usr/src/vbox*
|
---|
467 | /usr/lib/virtualbox
|
---|
468 | /usr/share/applications
|
---|
469 | /usr/share/icons
|
---|
470 | /usr/share/mime/packages
|
---|
471 | /usr/share/pixmaps
|
---|
472 | /usr/share/virtualbox
|
---|