VirtualBox

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

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

rpm: openSUSE fix (do insserv even on upgrade)

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