VirtualBox

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

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

deb/rpm: fix VBoxExtPackHelperApp permissions

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