VirtualBox

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

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

Linux installer: properly handle VBoxExtPackHelperApp

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.2 KB
Line 
1#
2# Spec file for creating VirtualBox rpm packages
3#
4
5#
6# Copyright (C) 2006-2010 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: VirtualBox Personal Use and Evaluation License (PUEL)
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/share/virtualbox
73install -m 755 -d $RPM_BUILD_ROOT/usr/share/mime/packages
74mv VBoxEFI32.fd $RPM_BUILD_ROOT/usr/lib/virtualbox || true
75mv VBoxEFI64.fd $RPM_BUILD_ROOT/usr/lib/virtualbox || true
76mv *.gc $RPM_BUILD_ROOT/usr/lib/virtualbox
77mv *.r0 $RPM_BUILD_ROOT/usr/lib/virtualbox
78mv *.rel $RPM_BUILD_ROOT/usr/lib/virtualbox || true
79mv VBoxNetDHCP $RPM_BUILD_ROOT/usr/lib/virtualbox
80mv VBoxNetAdpCtl $RPM_BUILD_ROOT/usr/lib/virtualbox
81mv VBoxXPCOMIPCD $RPM_BUILD_ROOT/usr/lib/virtualbox
82mv components $RPM_BUILD_ROOT/usr/lib/virtualbox/components
83mv *.so $RPM_BUILD_ROOT/usr/lib/virtualbox
84mv *.so.4 $RPM_BUILD_ROOT/usr/lib/virtualbox || true
85mv VBoxTestOGL $RPM_BUILD_ROOT/usr/lib/virtualbox
86mv vboxshell.py $RPM_BUILD_ROOT/usr/lib/virtualbox
87(export VBOX_INSTALL_PATH=/usr/lib/virtualbox && \
88 cd ./sdk/installer && \
89 %{__python} ./vboxapisetup.py install --prefix %{_prefix} --root $RPM_BUILD_ROOT)
90rm -rf sdk/installer
91mv sdk $RPM_BUILD_ROOT/usr/lib/virtualbox
92mv nls $RPM_BUILD_ROOT/usr/share/virtualbox
93cp -a src $RPM_BUILD_ROOT/usr/share/virtualbox
94mv VBox.sh $RPM_BUILD_ROOT/usr/bin/VBox
95mv VBoxSysInfo.sh $RPM_BUILD_ROOT/usr/share/virtualbox
96mv VBoxCreateUSBNode.sh $RPM_BUILD_ROOT/usr/share/virtualbox
97cd icons
98 for i in *; do
99 install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes
100 mv $i/* $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes
101 rmdir $i
102 done
103cd -
104rmdir icons
105mv virtualbox.xml $RPM_BUILD_ROOT/usr/share/mime/packages
106for i in VBoxManage VBoxSVC VBoxSDL VirtualBox VBoxHeadless VBoxExtPackHelperApp vboxwebsrv webtest; do
107 mv $i $RPM_BUILD_ROOT/usr/lib/virtualbox; done
108for i in VBoxSDL VirtualBox VBoxHeadless VBoxNetDHCP VBoxNetAdpCtl VBoxExtPackHelperApp; do
109 chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/$i; done
110mv VBoxTunctl $RPM_BUILD_ROOT/usr/bin
111for d in /lib/modules/*; do
112 if [ -L $d/build ]; then
113 rm -f /tmp/vboxdrv-Module.symvers
114 ./src/vboxhost/vboxdrv/build_in_tmp \
115 --save-module-symvers /tmp/vboxdrv-Module.symvers \
116 KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
117 %INSTMOD%
118 ./src/vboxhost/vboxnetflt/build_in_tmp \
119 --use-module-symvers /tmp/vboxdrv-Module.symvers \
120 KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
121 %INSTMOD%
122 ./src/vboxhost/vboxnetadp/build_in_tmp \
123 --use-module-symvers /tmp/vboxdrv-Module.symvers \
124 KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
125 %INSTMOD%
126 fi
127done
128mv kchmviewer $RPM_BUILD_ROOT/usr/lib/virtualbox
129for i in rdesktop-vrdp.tar.gz rdesktop-vrdp-keymaps additions/VBoxGuestAdditions.iso; do
130 mv $i $RPM_BUILD_ROOT/usr/share/virtualbox; done
131if [ -d accessible ]; then
132 mv accessible $RPM_BUILD_ROOT/usr/lib/virtualbox
133fi
134mv rdesktop-vrdp $RPM_BUILD_ROOT/usr/bin
135install -D -m 755 vboxdrv.init $RPM_BUILD_ROOT%{_initrddir}/vboxdrv
136%if %{?rpm_suse:1}%{!?rpm_suse:0}
137ln -sf ../etc/init.d/vboxdrv $RPM_BUILD_ROOT/sbin/rcvboxdrv
138%endif
139install -D -m 755 vboxweb-service.init $RPM_BUILD_ROOT%{_initrddir}/vboxweb-service
140%if %{?rpm_suse:1}%{!?rpm_suse:0}
141ln -sf ../etc/init.d/vboxweb-service $RPM_BUILD_ROOT/sbin/rcvboxweb-service
142%endif
143ln -s VBox $RPM_BUILD_ROOT/usr/bin/VirtualBox
144ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxManage
145ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxSDL
146ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxVRDP
147ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxHeadless
148ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxwebsrv
149ln -s VirtualBox $RPM_BUILD_ROOT/usr/bin/virtualbox
150ln -s VBoxManage $RPM_BUILD_ROOT/usr/bin/vboxmanage
151ln -s VBoxSDL $RPM_BUILD_ROOT/usr/bin/vboxsdl
152ln -s VBoxHeadless $RPM_BUILD_ROOT/usr/bin/vboxheadless
153ln -s /usr/share/virtualbox/src/vboxhost $RPM_BUILD_ROOT/usr/src/vboxhost-%VER%
154mv virtualbox.desktop $RPM_BUILD_ROOT/usr/share/applications/virtualbox.desktop
155mv VBox.png $RPM_BUILD_ROOT/usr/share/pixmaps/VBox.png
156
157
158%pre
159# defaults
160[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
161
162# check for active VMs of the installed (old) package
163VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null || true`
164if [ -n "$VBOXSVC_PID" ]; then
165 # executed before the new package is installed!
166 if [ -f /etc/init.d/vboxweb-service ]; then
167 # try graceful termination; terminate the webservice first
168 /etc/init.d/vboxweb-service stop 2>/dev/null || true
169 # ask the daemon to terminate immediately
170 kill -USR1 $VBOXSVC_PID
171 fi
172 sleep 1
173 if pidof VBoxSVC > /dev/null 2>&1; then
174 echo "A copy of VirtualBox is currently running. Please close it and try again."
175 echo "Please note that it can take up to ten seconds for VirtualBox (in particular"
176 echo "the VBoxSVC daemon) to finish running."
177 exit 1
178 fi
179fi
180
181# check for old installation
182if [ -r /etc/vbox/vbox.cfg ]; then
183 . /etc/vbox/vbox.cfg
184 if [ "x$INSTALL_DIR" != "x" -a -d "$INSTALL_DIR" ]; then
185 echo "An old installation of VirtualBox was found. To install this package the"
186 echo "old package has to be removed first. Have a look at /etc/vbox/vbox.cfg to"
187 echo "determine the installation directory of the previous installation. After"
188 echo "uninstalling the old package remove the file /etc/vbox/vbox.cfg."
189 exit 1
190 fi
191fi
192
193# XXX remove old modules from previous versions (disable with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox)
194if [ "$INSTALL_NO_VBOXDRV" != "1" ]; then
195 find /lib/modules -name "vboxdrv\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
196 find /lib/modules -name "vboxnetflt\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
197 find /lib/modules -name "vboxnetadp\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
198fi
199
200
201%post
202LOG="/var/log/vbox-install.log"
203
204# defaults
205[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
206
207# remove old cruft
208if [ -f /etc/init.d/vboxdrv.sh ]; then
209 echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
210 rm /etc/init.d/vboxdrv.sh
211fi
212if [ -f /etc/vbox/vbox.cfg ]; then
213 echo "Found old version of /etc/vbox/vbox.cfg, removing."
214 rm /etc/vbox/vbox.cfg
215fi
216rm -f /etc/vbox/module_not_compiled
217
218# install udev rule (disable with INSTALL_NO_UDEV=1 in /etc/default/virtualbox)
219if [ -d /etc/udev/rules.d -a "$INSTALL_NO_UDEV" != "1" ]; then
220 udev_call=""
221 udev_app=`which udevadm 2> /dev/null`
222 if [ $? -eq 0 ]; then
223 udev_call="${udev_app} version 2> /dev/null"
224 else
225 udev_app=`which udevinfo 2> /dev/null`
226 if [ $? -eq 0 ]; then
227 udev_call="${udev_app} -V 2> /dev/null"
228 fi
229 fi
230 udev_fix="="
231 if [ "${udev_call}" != "" ]; then
232 udev_out=`${udev_call}`
233 udev_ver=`expr "$udev_out" : '[^0-9]*\([0-9]*\)'`
234 if [ "$udev_ver" = "" -o "$udev_ver" -lt 55 ]; then
235 udev_fix=""
236 fi
237 fi
238 usb_createnode="/usr/share/virtualbox/VBoxCreateUSBNode.sh"
239 echo "KERNEL=${udev_fix}\"vboxdrv\", NAME=\"vboxdrv\", OWNER=\"root\", GROUP=\"root\", MODE=\"0600\"" \
240 > /etc/udev/rules.d/10-vboxdrv.rules
241 echo "SUBSYSTEM=${udev_fix}\"usb_device\", ACTION=${udev_fix}\"add\", RUN=${usb_createnode} \$major \$minor \$attr{bDeviceClass}\"" \
242 >> /etc/udev/rules.d/10-vboxdrv.rules
243 echo "SUBSYSTEM=${udev_fix}\"usb\", ACTION=${udev_fix}\"add\", ENV{DEVTYPE}==\"usb_device\", RUN=${usb_createnode} \$major \$minor \$attr{bDeviceClass}\"" \
244 >> /etc/udev/rules.d/10-vboxdrv.rules
245 echo "SUBSYSTEM=${udev_fix}\"usb_device\", ACTION=${udev_fix}\"remove\", RUN=${usb_createnode} --remove \$major \$minor\"" \
246 >> /etc/udev/rules.d/10-vboxdrv.rules
247 echo "SUBSYSTEM=${udev_fix}\"usb\", ACTION=${udev_fix}\"remove\", ENV{DEVTYPE}==\"usb_device\", RUN=${usb_createnode} --remove \$major \$minor\"" \
248 >> /etc/udev/rules.d/10-vboxdrv.rules
249fi
250# Remove old udev description file
251if [ -f /etc/udev/rules.d/60-vboxdrv.rules ]; then
252 rm -f /etc/udev/rules.d/60-vboxdrv.rules 2> /dev/null
253fi
254# Build our device tree
255for i in /sys/bus/usb/devices/*; do
256 if test -r "$i/dev"; then
257 dev="`cat "$i/dev" 2> /dev/null`"
258 major="`expr "$dev" : '\(.*\):' 2> /dev/null`"
259 minor="`expr "$dev" : '.*:\(.*\)' 2> /dev/null`"
260 class="`cat $i/bDeviceClass 2> /dev/null`"
261 sh ${usb_createnode} "$major" "$minor" "$class" ${usb_group} 2>/dev/null
262 fi
263done
264
265# XXX SELinux: allow text relocation entries
266%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
267if [ -x /usr/bin/chcon ]; then
268 chcon -t texrel_shlib_t /usr/lib/virtualbox/*VBox* > /dev/null 2>&1
269 chcon -t texrel_shlib_t /usr/lib/virtualbox/VirtualBox.so > /dev/null 2>&1
270 chcon -t texrel_shlib_t /usr/lib/virtualbox/VBoxAuth.so > /dev/null 2>&1
271 chcon -t texrel_shlib_t /usr/lib/virtualbox/components/VBox*.so > /dev/null 2>&1
272 chcon -t java_exec_t /usr/lib/virtualbox/VirtualBox > /dev/null 2>&1
273 chcon -t java_exec_t /usr/lib/virtualbox/VBoxSDL > /dev/null 2>&1
274 chcon -t java_exec_t /usr/lib/virtualbox/VBoxHeadless > /dev/null 2>&1
275 chcon -t java_exec_t /usr/lib/virtualbox/VBoxExtPackHelperApp > /dev/null 2>&1
276 chcon -t java_exec_t /usr/lib/virtualbox/vboxwebsrv > /dev/null 2>&1
277fi
278%endif
279
280# create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
281if [ "$INSTALL_NO_GROUP" != "1" ]; then
282 echo
283 echo "Creating group 'vboxusers'. VM users must be member of that group!"
284 echo
285 groupadd -f vboxusers 2> /dev/null
286fi
287%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
288/sbin/chkconfig --add vboxdrv
289/sbin/chkconfig --add vboxweb-service
290%endif
291%if %{?rpm_suse:1}%{!?rpm_suse:0}
292%{fillup_and_insserv -f -y -Y vboxdrv vboxweb-service}
293%endif
294%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
295/sbin/ldconfig
296%_post_service vboxdrv
297%_post_service vboxweb-service
298%update_menus
299%endif
300update-mime-database /usr/share/mime &> /dev/null || :
301update-desktop-database -q > /dev/null 2>&1 || :
302touch --no-create /usr/share/icons/hicolor
303gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
304
305# Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
306BUILD_MODULES=0
307REGISTER_MODULES=1
308if [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko ]; then
309 REGISTER_MODULES=0
310 if [ "$INSTALL_NO_VBOXDRV" != "1" ]; then
311 # compile problem
312 cat << EOF
313No precompiled module for this kernel found -- trying to build one. Messages
314emitted during module compilation will be logged to $LOG.
315
316EOF
317 BUILD_MODULES=1
318 fi
319fi
320# if INSTALL_NO_VBOXDRV is set to 1, remove all shipped modules
321if [ "$INSTALL_NO_VBOXDRV" = "1" ]; then
322 rm -f /lib/modules/*/misc/vboxdrv.ko
323 rm -f /lib/modules/*/misc/vboxnetflt.ko
324 rm -f /lib/modules/*/misc/vboxnetadp.ko
325fi
326if [ $BUILD_MODULES -eq 1 ]; then
327 /etc/init.d/vboxdrv setup || true
328else
329 if lsmod | grep -q "vboxdrv[^_-]"; then
330 /etc/init.d/vboxdrv stop || true
331 fi
332 if [ $REGISTER_MODULES -eq 1 ]; then
333 DKMS=`which dkms 2>/dev/null`
334 if [ -n "$DKMS" ]; then
335 $DKMS remove -m vboxhost -v %VER% --all > /dev/null 2>&1 || true
336 fi
337 fi
338 /etc/init.d/vboxdrv start > /dev/null
339fi
340/etc/init.d/vboxweb-service start > /dev/null
341
342
343%preun
344# $1==0: remove the last version of the package
345# $1==1: install the first time
346# $1>=2: upgrade
347%if %{?rpm_suse:1}%{!?rpm_suse:0}
348%stop_on_removal vboxweb-service
349%endif
350%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
351%_preun_service vboxweb-service
352%endif
353%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
354if [ "$1" = 0 ]; then
355 /sbin/service vboxweb-service stop > /dev/null
356 /sbin/chkconfig --del vboxweb-service
357fi
358%endif
359
360if [ "$1" = 0 ]; then
361 # check for active VMs
362 VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null || true`
363 if [ -n "$VBOXSVC_PID" ]; then
364 kill -USR1 $VBOXSVC_PID
365 sleep 1
366 if pidof VBoxSVC > /dev/null 2>&1; then
367 echo "A copy of VirtualBox is currently running. Please close it and try again."
368 echo "Please note that it can take up to ten seconds for VirtualBox (in particular"
369 echo "the VBoxSVC daemon) to finish running."
370 exit 1
371 fi
372 fi
373fi
374%if %{?rpm_suse:1}%{!?rpm_suse:0}
375%stop_on_removal vboxdrv
376%endif
377%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
378%_preun_service vboxdrv
379%endif
380if [ "$1" = 0 ]; then
381%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
382 /sbin/service vboxdrv stop > /dev/null
383 /sbin/chkconfig --del vboxdrv
384%endif
385 rm -f /etc/udev/rules.d/10-vboxdrv.rules
386 rm -f /etc/vbox/license_agreed
387 rm -f /etc/vbox/module_not_compiled
388 # remove our USB device tree
389 rm -rf /dev/vboxusb 2> /dev/null
390fi
391DKMS=`which dkms 2>/dev/null`
392if [ -n "$DKMS" ]; then
393 $DKMS remove -m vboxhost -v %VER% --all > /dev/null 2>&1 || true
394fi
395
396
397%postun
398%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
399if [ "$1" -ge 1 ]; then
400 /sbin/service vboxdrv restart > /dev/null 2>&1
401 /sbin/service vboxweb-service restart > /dev/null 2>&1
402fi
403%endif
404%if %{?rpm_suse:1}%{!?rpm_suse:0}
405%restart_on_update vboxdrv vboxweb-service
406%insserv_cleanup
407%endif
408%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
409/sbin/ldconfig
410%{clean_desktop_database}
411%clean_menus
412%endif
413update-mime-database /usr/share/mime &> /dev/null || :
414update-desktop-database -q > /dev/null 2>&1 || :
415touch --no-create /usr/share/icons/hicolor
416gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
417
418
419%clean
420rm -rf $RPM_BUILD_ROOT
421
422
423%files
424%defattr(-,root,root)
425%doc LICENSE
426%doc %LICENSE%
427%doc UserManual*.pdf
428%doc VirtualBox*.chm
429%{_initrddir}/vboxdrv
430%{_initrddir}/vboxweb-service
431%{?rpm_suse: %{py_sitedir}/*}
432%{!?rpm_suse: %{python_sitelib}/*}
433%{?rpm_suse: /sbin/rcvboxdrv}
434%{?rpm_suse: /sbin/rcvboxweb-service}
435/lib/modules
436/etc/vbox
437/usr/bin
438/usr/src/vbox*
439/usr/lib/virtualbox
440/usr/share/applications
441/usr/share/icons
442/usr/share/mime/packages
443/usr/share/pixmaps
444/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