VirtualBox

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

Last change on this file since 40894 was 40717, checked in by vboxsync, 13 years ago

rpm: another OSE build fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.9 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 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%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; 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 vboxweb-service.init $RPM_BUILD_ROOT%{_initrddir}/vboxweb-service
169%if %{?rpm_suse:1}%{!?rpm_suse:0}
170ln -sf ../etc/init.d/vboxballoonctrl-service $RPM_BUILD_ROOT/sbin/rcvboxballoonctrl-service
171ln -sf ../etc/init.d/vboxweb-service $RPM_BUILD_ROOT/sbin/rcvboxweb-service
172%endif
173ln -s VBox $RPM_BUILD_ROOT/usr/bin/VirtualBox
174ln -s VBox $RPM_BUILD_ROOT/usr/bin/virtualbox
175ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxManage
176ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxmanage
177ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxSDL
178ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxsdl
179ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxVRDP
180ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxHeadless
181ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxheadless
182ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxBalloonCtrl
183ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxballoonctrl
184ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxwebsrv
185ln -s /usr/share/virtualbox/src/vboxhost $RPM_BUILD_ROOT/usr/src/vboxhost-%VER%
186mv virtualbox.desktop $RPM_BUILD_ROOT/usr/share/applications/virtualbox.desktop
187mv VBox.png $RPM_BUILD_ROOT/usr/share/pixmaps/VBox.png
188
189
190%pre
191# defaults
192[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
193
194# check for active VMs of the installed (old) package
195VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null || true`
196if [ -n "$VBOXSVC_PID" ]; then
197 # executed before the new package is installed!
198 if [ -f /etc/init.d/vboxballoonctrl-service ]; then
199 # try graceful termination; terminate the balloon control service first
200 /etc/init.d/vboxballoonctrl-service stop 2>/dev/null || true
201 fi
202 if [ -f /etc/init.d/vboxweb-service ]; then
203 # try graceful termination; terminate the webservice first
204 /etc/init.d/vboxweb-service stop 2>/dev/null || true
205 fi
206 # ask the daemon to terminate immediately
207 kill -USR1 $VBOXSVC_PID
208 sleep 1
209 if pidof VBoxSVC > /dev/null 2>&1; then
210 echo "A copy of VirtualBox is currently running. Please close it and try again."
211 echo "Please note that it can take up to ten seconds for VirtualBox (in particular"
212 echo "the VBoxSVC daemon) to finish running."
213 exit 1
214 fi
215fi
216
217# check for old installation
218if [ -r /etc/vbox/vbox.cfg ]; then
219 . /etc/vbox/vbox.cfg
220 if [ "x$INSTALL_DIR" != "x" -a -d "$INSTALL_DIR" ]; then
221 echo "An old installation of VirtualBox was found. To install this package the"
222 echo "old package has to be removed first. Have a look at /etc/vbox/vbox.cfg to"
223 echo "determine the installation directory of the previous installation. After"
224 echo "uninstalling the old package remove the file /etc/vbox/vbox.cfg."
225 exit 1
226 fi
227fi
228
229# XXX remove old modules from previous versions (disable with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox)
230if [ "$INSTALL_NO_VBOXDRV" != "1" ]; then
231 find /lib/modules -name "vboxdrv\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
232 find /lib/modules -name "vboxnetflt\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
233 find /lib/modules -name "vboxnetadp\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
234 find /lib/modules -name "vboxpci\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
235fi
236
237
238%post
239#include installer-common.sh
240
241LOG="/var/log/vbox-install.log"
242
243# defaults
244[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
245
246# remove old cruft
247if [ -f /etc/init.d/vboxdrv.sh ]; then
248 echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
249 rm /etc/init.d/vboxdrv.sh
250fi
251if [ -f /etc/vbox/vbox.cfg ]; then
252 echo "Found old version of /etc/vbox/vbox.cfg, removing."
253 rm /etc/vbox/vbox.cfg
254fi
255rm -f /etc/vbox/module_not_compiled
256
257# XXX SELinux: allow text relocation entries
258%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
259set_selinux_permissions /usr/lib/virtualbox /usr/share/virtualbox
260%endif
261
262# create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
263if [ "$INSTALL_NO_GROUP" != "1" ]; then
264 echo
265 echo "Creating group 'vboxusers'. VM users must be member of that group!"
266 echo
267 groupadd -f vboxusers 2> /dev/null
268fi
269
270# install udev rule (disable with INSTALL_NO_UDEV=1 in /etc/default/virtualbox)
271# and /dev/vboxdrv and /dev/vboxusb/*/* device nodes
272install_device_node_setup root 0600 /usr/share/virtualbox "${usb_group}"
273%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
274/sbin/chkconfig --add vboxdrv
275/sbin/chkconfig --add vboxballoonctrl-service
276/sbin/chkconfig --add vboxweb-service
277%endif
278%if %{?rpm_suse:1}%{!?rpm_suse:0}
279%{fillup_and_insserv -f -y -Y vboxdrv vboxballoonctrl-service vboxweb-service}
280%endif
281%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
282/sbin/ldconfig
283%_post_service vboxdrv
284%_post_service vboxballoonctrl-service
285%_post_service vboxweb-service
286%update_menus
287%endif
288update-mime-database /usr/share/mime &> /dev/null || :
289update-desktop-database -q > /dev/null 2>&1 || :
290touch --no-create /usr/share/icons/hicolor
291gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
292
293# Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
294BUILD_MODULES=0
295REGISTER_MODULES=1
296if [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko ]; then
297 REGISTER_MODULES=0
298 if [ "$INSTALL_NO_VBOXDRV" != "1" ]; then
299 # compile problem
300 cat << EOF
301No precompiled module for this kernel found -- trying to build one. Messages
302emitted during module compilation will be logged to $LOG.
303
304EOF
305 BUILD_MODULES=1
306 fi
307fi
308# if INSTALL_NO_VBOXDRV is set to 1, remove all shipped modules
309if [ "$INSTALL_NO_VBOXDRV" = "1" ]; then
310 rm -f /lib/modules/*/misc/vboxdrv.ko
311 rm -f /lib/modules/*/misc/vboxnetflt.ko
312 rm -f /lib/modules/*/misc/vboxnetadp.ko
313 rm -f /lib/modules/*/misc/vboxpci.ko
314fi
315if [ $BUILD_MODULES -eq 1 ]; then
316 /etc/init.d/vboxdrv setup || true
317else
318 if lsmod | grep -q "vboxdrv[^_-]"; then
319 /etc/init.d/vboxdrv stop || true
320 fi
321 if [ $REGISTER_MODULES -eq 1 ]; then
322 DKMS=`which dkms 2>/dev/null`
323 if [ -n "$DKMS" ]; then
324 $DKMS remove -m vboxhost -v %VER% --all > /dev/null 2>&1 || true
325 fi
326 fi
327 /etc/init.d/vboxdrv start > /dev/null
328fi
329/etc/init.d/vboxballoonctrl-service start > /dev/null
330/etc/init.d/vboxweb-service start > /dev/null
331
332
333%preun
334# $1==0: remove the last version of the package
335# $1==1: install the first time
336# $1>=2: upgrade
337%if %{?rpm_suse:1}%{!?rpm_suse:0}
338%stop_on_removal vboxballoonctrl-service
339%stop_on_removal vboxweb-service
340%endif
341%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
342%_preun_service vboxballoonctrl-service
343%_preun_service vboxweb-service
344%endif
345%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
346if [ "$1" = 0 ]; then
347 /sbin/service vboxballoonctrl-service stop > /dev/null
348 /sbin/chkconfig --del vboxballoonctrl-service
349 /sbin/service vboxweb-service stop > /dev/null
350 /sbin/chkconfig --del vboxweb-service
351fi
352%endif
353
354if [ "$1" = 0 ]; then
355 # check for active VMs
356 VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null || true`
357 if [ -n "$VBOXSVC_PID" ]; then
358 kill -USR1 $VBOXSVC_PID
359 sleep 1
360 if pidof VBoxSVC > /dev/null 2>&1; then
361 echo "A copy of VirtualBox is currently running. Please close it and try again."
362 echo "Please note that it can take up to ten seconds for VirtualBox (in particular"
363 echo "the VBoxSVC daemon) to finish running."
364 exit 1
365 fi
366 fi
367fi
368%if %{?rpm_suse:1}%{!?rpm_suse:0}
369%stop_on_removal vboxdrv
370%endif
371%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
372%_preun_service vboxdrv
373%endif
374if [ "$1" = 0 ]; then
375%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
376 /sbin/service vboxdrv stop > /dev/null
377 /sbin/chkconfig --del vboxdrv
378%endif
379 rm -f /etc/udev/rules.d/10-vboxdrv.rules
380 rm -f /etc/vbox/license_agreed
381 rm -f /etc/vbox/module_not_compiled
382fi
383DKMS=`which dkms 2>/dev/null`
384if [ -n "$DKMS" ]; then
385 $DKMS remove -m vboxhost -v %VER% --all > /dev/null 2>&1 || true
386fi
387
388
389%postun
390%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
391if [ "$1" -ge 1 ]; then
392 /sbin/service vboxdrv restart > /dev/null 2>&1
393 /sbin/service vboxballoonctrl-service restart > /dev/null 2>&1
394 /sbin/service vboxweb-service restart > /dev/null 2>&1
395fi
396%endif
397%if %{?rpm_suse:1}%{!?rpm_suse:0}
398%restart_on_update vboxdrv vboxballoonctrl-service vboxweb-service
399%insserv_cleanup
400%endif
401%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
402/sbin/ldconfig
403%{clean_desktop_database}
404%clean_menus
405%endif
406update-mime-database /usr/share/mime &> /dev/null || :
407update-desktop-database -q > /dev/null 2>&1 || :
408touch --no-create /usr/share/icons/hicolor
409gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
410rm -rf /usr/lib/virtualbox/ExtensionPacks
411
412
413%clean
414rm -rf $RPM_BUILD_ROOT
415
416
417%files
418%defattr(-,root,root)
419%doc %{!?is_ose: LICENSE}
420%doc UserManual*.pdf
421%doc %{!?is_ose: VirtualBox*.chm}
422%{_initrddir}/vboxdrv
423%{_initrddir}/vboxballoonctrl-service
424%{_initrddir}/vboxweb-service
425%{?rpm_suse: %{py_sitedir}/*}
426%{!?rpm_suse: %{python_sitelib}/*}
427%{?rpm_suse: /sbin/rcvboxdrv}
428%{?rpm_suse: /sbin/rcvboxballoonctrl-service}
429%{?rpm_suse: /sbin/rcvboxweb-service}
430/lib/modules
431/etc/vbox
432/usr/bin
433/usr/src/vbox*
434/usr/lib/virtualbox
435/usr/share/applications
436/usr/share/icons
437/usr/share/mime/packages
438/usr/share/pixmaps
439/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