VirtualBox

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

Last change on this file since 43257 was 43122, checked in by vboxsync, 12 years ago

use standard wording

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