VirtualBox

source: vbox/trunk/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec@ 37216

Last change on this file since 37216 was 37124, checked in by vboxsync, 14 years ago

Installer/linux: refactored udev rule installation

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.3 KB
Line 
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
20Summary: Oracle VM VirtualBox
21Name: %NAME%
22Version: %BUILDVER%_%BUILDREL%
23Release: 1
24URL: http://www.virtualbox.org/
25Source: VirtualBox.tar.bz2
26License: GPLv2
27Group: Applications/System
28Vendor: Oracle Corporation
29BuildRoot: %BUILDROOT%
30Requires: %LIBASOUND%
31
32%if %{?rpm_suse:1}%{!?rpm_suse:0}
33%debug_package
34%endif
35
36%MACROSPYTHON%
37
38
39%description
40VirtualBox is a powerful PC virtualization solution allowing
41you to run a wide range of PC operating systems on your Linux
42system. This includes Windows, Linux, FreeBSD, DOS, OpenBSD
43and others. VirtualBox comes with a broad feature set and
44excellent performance, making it the premier virtualization
45software solution on the market.
46
47
48%prep
49%setup -q
50DESTDIR=""
51unset DESTDIR
52
53
54%build
55
56
57%install
58# Mandriva: prevent replacing 'echo' by 'gprintf'
59export DONT_GPRINTIFY=1
60rm -rf $RPM_BUILD_ROOT
61install -m 755 -d $RPM_BUILD_ROOT/sbin
62install -m 755 -d $RPM_BUILD_ROOT%{_initrddir}
63install -m 755 -d $RPM_BUILD_ROOT/lib/modules
64install -m 755 -d $RPM_BUILD_ROOT/etc/vbox
65install -m 755 -d $RPM_BUILD_ROOT/usr/bin
66install -m 755 -d $RPM_BUILD_ROOT/usr/src
67install -m 755 -d $RPM_BUILD_ROOT/usr/share/applications
68install -m 755 -d $RPM_BUILD_ROOT/usr/share/pixmaps
69install -m 755 -d $RPM_BUILD_ROOT/usr/share/icons/hicolor
70install -m 755 -d $RPM_BUILD_ROOT%{_defaultdocdir}/virtualbox
71install -m 755 -d $RPM_BUILD_ROOT/usr/lib/virtualbox
72install -m 755 -d $RPM_BUILD_ROOT/usr/lib/virtualbox/ExtensionPacks
73install -m 755 -d $RPM_BUILD_ROOT/usr/share/virtualbox
74install -m 755 -d $RPM_BUILD_ROOT/usr/share/mime/packages
75mv VBoxEFI32.fd $RPM_BUILD_ROOT/usr/lib/virtualbox || true
76mv VBoxEFI64.fd $RPM_BUILD_ROOT/usr/lib/virtualbox || true
77mv *.gc $RPM_BUILD_ROOT/usr/lib/virtualbox
78mv *.r0 $RPM_BUILD_ROOT/usr/lib/virtualbox
79mv *.rel $RPM_BUILD_ROOT/usr/lib/virtualbox || true
80mv VBoxNetDHCP $RPM_BUILD_ROOT/usr/lib/virtualbox
81mv VBoxNetAdpCtl $RPM_BUILD_ROOT/usr/lib/virtualbox
82mv VBoxXPCOMIPCD $RPM_BUILD_ROOT/usr/lib/virtualbox
83mv components $RPM_BUILD_ROOT/usr/lib/virtualbox/components
84mv *.so $RPM_BUILD_ROOT/usr/lib/virtualbox
85mv *.so.4 $RPM_BUILD_ROOT/usr/lib/virtualbox || true
86mv VBoxTestOGL $RPM_BUILD_ROOT/usr/lib/virtualbox
87mv 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)
91rm -rf sdk/installer
92mv sdk $RPM_BUILD_ROOT/usr/lib/virtualbox
93mv nls $RPM_BUILD_ROOT/usr/share/virtualbox
94cp -a src $RPM_BUILD_ROOT/usr/share/virtualbox
95mv VBox.sh $RPM_BUILD_ROOT/usr/bin/VBox
96mv VBoxSysInfo.sh $RPM_BUILD_ROOT/usr/share/virtualbox
97mv VBoxCreateUSBNode.sh $RPM_BUILD_ROOT/usr/share/virtualbox
98cp icons/128x128/virtualbox.png $RPM_BUILD_ROOT/usr/share/pixmaps/virtualbox.png
99cd 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
109cd -
110rmdir icons
111mv virtualbox.xml $RPM_BUILD_ROOT/usr/share/mime/packages
112for i in VBoxManage VBoxSVC VBoxSDL VirtualBox VBoxHeadless VBoxExtPackHelperApp VBoxBalloonCtrl vboxwebsrv webtest; do
113 mv $i $RPM_BUILD_ROOT/usr/lib/virtualbox; done
114for i in VBoxSDL VirtualBox VBoxHeadless VBoxNetDHCP VBoxNetAdpCtl; do
115 chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/$i; done
116mv VBoxTunctl $RPM_BUILD_ROOT/usr/bin
117for 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
137done
138mv kchmviewer $RPM_BUILD_ROOT/usr/lib/virtualbox
139for i in rdesktop-vrdp.tar.gz rdesktop-vrdp-keymaps additions/VBoxGuestAdditions.iso; do
140 mv $i $RPM_BUILD_ROOT/usr/share/virtualbox; done
141if [ -d accessible ]; then
142 mv accessible $RPM_BUILD_ROOT/usr/lib/virtualbox
143fi
144mv rdesktop-vrdp $RPM_BUILD_ROOT/usr/bin
145install -D -m 755 vboxdrv.init $RPM_BUILD_ROOT%{_initrddir}/vboxdrv
146%if %{?rpm_suse:1}%{!?rpm_suse:0}
147ln -sf ../etc/init.d/vboxdrv $RPM_BUILD_ROOT/sbin/rcvboxdrv
148%endif
149install -D -m 755 vboxballoonctrl-service.init $RPM_BUILD_ROOT%{_initrddir}/vboxballoonctrl-service
150install -D -m 755 vboxweb-service.init $RPM_BUILD_ROOT%{_initrddir}/vboxweb-service
151%if %{?rpm_suse:1}%{!?rpm_suse:0}
152ln -sf ../etc/init.d/vboxballoonctrl-service $RPM_BUILD_ROOT/sbin/rcvboxballoonctrl-service
153ln -sf ../etc/init.d/vboxweb-service $RPM_BUILD_ROOT/sbin/rcvboxweb-service
154%endif
155ln -s VBox $RPM_BUILD_ROOT/usr/bin/VirtualBox
156ln -s VBox $RPM_BUILD_ROOT/usr/bin/virtualbox
157ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxManage
158ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxmanage
159ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxSDL
160ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxsdl
161ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxVRDP
162ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxHeadless
163ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxheadless
164ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxBalloonCtrl
165ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxballoonctrl
166ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxwebsrv
167ln -s /usr/share/virtualbox/src/vboxhost $RPM_BUILD_ROOT/usr/src/vboxhost-%VER%
168mv virtualbox.desktop $RPM_BUILD_ROOT/usr/share/applications/virtualbox.desktop
169mv 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
177VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null || true`
178if [ -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
197fi
198
199# check for old installation
200if [ -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
209fi
210
211# XXX remove old modules from previous versions (disable with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox)
212if [ "$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
217fi
218
219
220%post
221#include installer-utils.sh
222
223LOG="/var/log/vbox-install.log"
224
225# defaults
226[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
227
228# remove old cruft
229if [ -f /etc/init.d/vboxdrv.sh ]; then
230 echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
231 rm /etc/init.d/vboxdrv.sh
232fi
233if [ -f /etc/vbox/vbox.cfg ]; then
234 echo "Found old version of /etc/vbox/vbox.cfg, removing."
235 rm /etc/vbox/vbox.cfg
236fi
237rm -f /etc/vbox/module_not_compiled
238
239# install udev rule (disable with INSTALL_NO_UDEV=1 in /etc/default/virtualbox)
240install_udev root 0600 /usr/share/virtualbox vboxusers "$INSTALL_NO_UDEV" \
241 > /etc/udev/rules.d/10-vboxdrv.rules
242
243# Build our device tree
244for i in /sys/bus/usb/devices/*; do
245 if test -r "$i/dev"; then
246 dev="`cat "$i/dev" 2> /dev/null`"
247 major="`expr "$dev" : '\(.*\):' 2> /dev/null`"
248 minor="`expr "$dev" : '.*:\(.*\)' 2> /dev/null`"
249 class="`cat $i/bDeviceClass 2> /dev/null`"
250 sh ${usb_createnode} "$major" "$minor" "$class" ${usb_group} 2>/dev/null
251 fi
252done
253
254# XXX SELinux: allow text relocation entries
255%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
256if [ -x /usr/bin/chcon ]; then
257 chcon -t texrel_shlib_t /usr/lib/virtualbox/*VBox* > /dev/null 2>&1
258 chcon -t texrel_shlib_t /usr/lib/virtualbox/VirtualBox.so > /dev/null 2>&1
259 chcon -t texrel_shlib_t /usr/lib/virtualbox/VBoxAuth.so > /dev/null 2>&1
260 chcon -t texrel_shlib_t /usr/lib/virtualbox/components/VBox*.so > /dev/null 2>&1
261 chcon -t java_exec_t /usr/lib/virtualbox/VirtualBox > /dev/null 2>&1
262 chcon -t java_exec_t /usr/lib/virtualbox/VBoxSDL > /dev/null 2>&1
263 chcon -t java_exec_t /usr/lib/virtualbox/VBoxHeadless > /dev/null 2>&1
264 chcon -t java_exec_t /usr/lib/virtualbox/VBoxExtPackHelperApp > /dev/null 2>&1
265 chcon -t java_exec_t /usr/lib/virtualbox/VBoxBalloonCtrl > /dev/null 2>&1
266 chcon -t java_exec_t /usr/lib/virtualbox/vboxwebsrv > /dev/null 2>&1
267fi
268%endif
269
270# create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
271if [ "$INSTALL_NO_GROUP" != "1" ]; then
272 echo
273 echo "Creating group 'vboxusers'. VM users must be member of that group!"
274 echo
275 groupadd -f vboxusers 2> /dev/null
276fi
277%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
278/sbin/chkconfig --add vboxdrv
279/sbin/chkconfig --add vboxballoonctrl-service
280/sbin/chkconfig --add vboxweb-service
281%endif
282%if %{?rpm_suse:1}%{!?rpm_suse:0}
283%{fillup_and_insserv -f -y -Y vboxdrv vboxballoonctrl-service vboxweb-service}
284%endif
285%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
286/sbin/ldconfig
287%_post_service vboxdrv
288%_post_service vboxballoonctrl-service
289%_post_service vboxweb-service
290%update_menus
291%endif
292update-mime-database /usr/share/mime &> /dev/null || :
293update-desktop-database -q > /dev/null 2>&1 || :
294touch --no-create /usr/share/icons/hicolor
295gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
296
297# Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
298BUILD_MODULES=0
299REGISTER_MODULES=1
300if [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko ]; then
301 REGISTER_MODULES=0
302 if [ "$INSTALL_NO_VBOXDRV" != "1" ]; then
303 # compile problem
304 cat << EOF
305No precompiled module for this kernel found -- trying to build one. Messages
306emitted during module compilation will be logged to $LOG.
307
308EOF
309 BUILD_MODULES=1
310 fi
311fi
312# if INSTALL_NO_VBOXDRV is set to 1, remove all shipped modules
313if [ "$INSTALL_NO_VBOXDRV" = "1" ]; then
314 rm -f /lib/modules/*/misc/vboxdrv.ko
315 rm -f /lib/modules/*/misc/vboxnetflt.ko
316 rm -f /lib/modules/*/misc/vboxnetadp.ko
317 rm -f /lib/modules/*/misc/vboxpci.ko
318fi
319if [ $BUILD_MODULES -eq 1 ]; then
320 /etc/init.d/vboxdrv setup || true
321else
322 if lsmod | grep -q "vboxdrv[^_-]"; then
323 /etc/init.d/vboxdrv stop || true
324 fi
325 if [ $REGISTER_MODULES -eq 1 ]; then
326 DKMS=`which dkms 2>/dev/null`
327 if [ -n "$DKMS" ]; then
328 $DKMS remove -m vboxhost -v %VER% --all > /dev/null 2>&1 || true
329 fi
330 fi
331 /etc/init.d/vboxdrv start > /dev/null
332fi
333/etc/init.d/vboxballoonctrl-service start > /dev/null
334/etc/init.d/vboxweb-service start > /dev/null
335
336
337%preun
338# $1==0: remove the last version of the package
339# $1==1: install the first time
340# $1>=2: upgrade
341%if %{?rpm_suse:1}%{!?rpm_suse:0}
342%stop_on_removal vboxballoonctrl-service
343%stop_on_removal vboxweb-service
344%endif
345%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
346%_preun_service vboxballoonctrl-service
347%_preun_service vboxweb-service
348%endif
349%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
350if [ "$1" = 0 ]; then
351 /sbin/service vboxballoonctrl-service stop > /dev/null
352 /sbin/chkconfig --del vboxballoonctrl-service
353 /sbin/service vboxweb-service stop > /dev/null
354 /sbin/chkconfig --del vboxweb-service
355fi
356%endif
357
358if [ "$1" = 0 ]; then
359 # check for active VMs
360 VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null || true`
361 if [ -n "$VBOXSVC_PID" ]; then
362 kill -USR1 $VBOXSVC_PID
363 sleep 1
364 if pidof VBoxSVC > /dev/null 2>&1; then
365 echo "A copy of VirtualBox is currently running. Please close it and try again."
366 echo "Please note that it can take up to ten seconds for VirtualBox (in particular"
367 echo "the VBoxSVC daemon) to finish running."
368 exit 1
369 fi
370 fi
371fi
372%if %{?rpm_suse:1}%{!?rpm_suse:0}
373%stop_on_removal vboxdrv
374%endif
375%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
376%_preun_service vboxdrv
377%endif
378if [ "$1" = 0 ]; then
379%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
380 /sbin/service vboxdrv stop > /dev/null
381 /sbin/chkconfig --del vboxdrv
382%endif
383 rm -f /etc/udev/rules.d/10-vboxdrv.rules
384 rm -f /etc/vbox/license_agreed
385 rm -f /etc/vbox/module_not_compiled
386fi
387DKMS=`which dkms 2>/dev/null`
388if [ -n "$DKMS" ]; then
389 $DKMS remove -m vboxhost -v %VER% --all > /dev/null 2>&1 || true
390fi
391
392
393%postun
394%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
395if [ "$1" -ge 1 ]; then
396 /sbin/service vboxdrv restart > /dev/null 2>&1
397 /sbin/service vboxballoonctrl-service restart > /dev/null 2>&1
398 /sbin/service vboxweb-service restart > /dev/null 2>&1
399fi
400%endif
401%if %{?rpm_suse:1}%{!?rpm_suse:0}
402%restart_on_update vboxdrv vboxballoonctrl-service vboxweb-service
403%insserv_cleanup
404%endif
405%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
406/sbin/ldconfig
407%{clean_desktop_database}
408%clean_menus
409%endif
410update-mime-database /usr/share/mime &> /dev/null || :
411update-desktop-database -q > /dev/null 2>&1 || :
412touch --no-create /usr/share/icons/hicolor
413gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
414
415
416%clean
417rm -rf $RPM_BUILD_ROOT
418
419
420%files
421%defattr(-,root,root)
422%doc LICENSE
423%doc UserManual*.pdf
424%doc VirtualBox*.chm
425%{_initrddir}/vboxdrv
426%{_initrddir}/vboxballoonctrl-service
427%{_initrddir}/vboxweb-service
428%{?rpm_suse: %{py_sitedir}/*}
429%{!?rpm_suse: %{python_sitelib}/*}
430%{?rpm_suse: /sbin/rcvboxdrv}
431%{?rpm_suse: /sbin/rcvboxballoonctrl-service}
432%{?rpm_suse: /sbin/rcvboxweb-service}
433/lib/modules
434/etc/vbox
435/usr/bin
436/usr/src/vbox*
437/usr/lib/virtualbox
438/usr/share/applications
439/usr/share/icons
440/usr/share/mime/packages
441/usr/share/pixmaps
442/usr/share/virtualbox
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