VirtualBox

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

Last change on this file since 58090 was 58090, checked in by vboxsync, 9 years ago

Installers/linux: provide clean-up mechanism for upgrade hiccups from 5.0.4 and earlier to later versions.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.1 KB
Line 
1#
2# Spec file for creating VirtualBox rpm packages
3#
4
5#
6# Copyright (C) 2006-2015 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
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 *.rc $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 VBoxNetNAT $RPM_BUILD_ROOT/usr/lib/virtualbox
83mv VBoxNetAdpCtl $RPM_BUILD_ROOT/usr/lib/virtualbox
84if [ -f VBoxVolInfo ]; then
85 mv VBoxVolInfo $RPM_BUILD_ROOT/usr/lib/virtualbox
86fi
87mv VBoxXPCOMIPCD $RPM_BUILD_ROOT/usr/lib/virtualbox
88mv components $RPM_BUILD_ROOT/usr/lib/virtualbox/components
89mv *.so $RPM_BUILD_ROOT/usr/lib/virtualbox
90mv *.so.4 $RPM_BUILD_ROOT/usr/lib/virtualbox || true
91ln -s ../VBoxVMM.so $RPM_BUILD_ROOT/usr/lib/virtualbox/components/VBoxVMM.so
92mv VBoxTestOGL $RPM_BUILD_ROOT/usr/lib/virtualbox
93mv vboxshell.py $RPM_BUILD_ROOT/usr/lib/virtualbox
94(export VBOX_INSTALL_PATH=/usr/lib/virtualbox && \
95 cd ./sdk/installer && \
96 %{__python} ./vboxapisetup.py install --prefix %{_prefix} --root $RPM_BUILD_ROOT)
97rm -rf sdk/installer
98mv sdk $RPM_BUILD_ROOT/usr/lib/virtualbox
99mv nls $RPM_BUILD_ROOT/usr/share/virtualbox
100cp -a src $RPM_BUILD_ROOT/usr/share/virtualbox
101mv VBox.sh $RPM_BUILD_ROOT/usr/bin/VBox
102mv VBoxSysInfo.sh $RPM_BUILD_ROOT/usr/share/virtualbox
103mv VBoxCreateUSBNode.sh $RPM_BUILD_ROOT/usr/share/virtualbox
104cp icons/128x128/virtualbox.png $RPM_BUILD_ROOT/usr/share/pixmaps/virtualbox.png
105cd icons
106 for i in *; do
107 if [ -f $i/virtualbox.* ]; then
108 install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/apps
109 mv $i/virtualbox.* $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/apps
110 fi
111 install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes
112 mv $i/* $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes || true
113 rmdir $i
114 done
115cd -
116rmdir icons
117mv virtualbox.xml $RPM_BUILD_ROOT/usr/share/mime/packages
118for i in VBoxManage VBoxSVC VirtualBox VBoxHeadless VBoxDTrace VBoxExtPackHelperApp VBoxBalloonCtrl VBoxAutostart vbox-img; do
119 mv $i $RPM_BUILD_ROOT/usr/lib/virtualbox; done
120if %WEBSVC%; then
121 for i in vboxwebsrv webtest; do
122 mv $i $RPM_BUILD_ROOT/usr/lib/virtualbox; done
123fi
124test -f VBoxSDL && mv VBoxSDL $RPM_BUILD_ROOT/usr/lib/virtualbox
125for i in VirtualBox VBoxHeadless VBoxNetDHCP VBoxNetNAT VBoxNetAdpCtl; do
126 chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/$i; done
127if [ -f $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxVolInfo ]; then
128 chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxVolInfo
129fi
130test -f VBoxSDL && chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxSDL
131if [ -d ExtensionPacks/VNC ]; then
132 mv ExtensionPacks/VNC $RPM_BUILD_ROOT/usr/lib/virtualbox/ExtensionPacks
133fi
134mv VBoxTunctl $RPM_BUILD_ROOT/usr/bin
135%if %{?is_ose:0}%{!?is_ose:1}
136for d in /lib/modules/*; do
137 if [ -L $d/build ]; then
138 rm -f /tmp/vboxdrv-Module.symvers
139 ./src/vboxhost/build_in_tmp \
140 --save-module-symvers /tmp/vboxdrv-Module.symvers \
141 --module-source `pwd`/src/vboxhost/vboxdrv \
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/vboxnetflt \
147 KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
148 %INSTMOD%
149 ./src/vboxhost/build_in_tmp \
150 --use-module-symvers /tmp/vboxdrv-Module.symvers \
151 --module-source `pwd`/src/vboxhost/vboxnetadp \
152 KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
153 %INSTMOD%
154 ./src/vboxhost/build_in_tmp \
155 --use-module-symvers /tmp/vboxdrv-Module.symvers \
156 --module-source `pwd`/src/vboxhost/vboxpci \
157 KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
158 %INSTMOD%
159 fi
160done
161%endif
162%if %{?is_ose:0}%{!?is_ose:1}
163 mv kchmviewer $RPM_BUILD_ROOT/usr/lib/virtualbox
164 for i in rdesktop-vrdp.tar.gz rdesktop-vrdp-keymaps; do
165 mv $i $RPM_BUILD_ROOT/usr/share/virtualbox; done
166 mv rdesktop-vrdp $RPM_BUILD_ROOT/usr/bin
167%endif
168for i in additions/VBoxGuestAdditions.iso; do
169 mv $i $RPM_BUILD_ROOT/usr/share/virtualbox; done
170if [ -d accessible ]; then
171 mv accessible $RPM_BUILD_ROOT/usr/lib/virtualbox
172fi
173mv vboxdrv.sh $RPM_BUILD_ROOT/usr/lib/virtualbox
174mv vboxballoonctrl-service.sh $RPM_BUILD_ROOT/usr/lib/virtualbox
175mv vboxautostart-service.sh $RPM_BUILD_ROOT/usr/lib/virtualbox
176mv vboxweb-service.sh $RPM_BUILD_ROOT/usr/lib/virtualbox
177mv postinst-common.sh $RPM_BUILD_ROOT/usr/lib/virtualbox
178mv prerm-common.sh $RPM_BUILD_ROOT/usr/lib/virtualbox
179mv routines.sh $RPM_BUILD_ROOT/usr/lib/virtualbox
180ln -s VBox $RPM_BUILD_ROOT/usr/bin/VirtualBox
181ln -s VBox $RPM_BUILD_ROOT/usr/bin/virtualbox
182ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxManage
183ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxmanage
184test -f VBoxSDL && ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxSDL
185test -f VBoxSDL && ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxsdl
186ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxVRDP
187ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxHeadless
188ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxheadless
189ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxDTrace
190ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxdtrace
191ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxBalloonCtrl
192ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxballoonctrl
193ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxAutostart
194ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxautostart
195ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxwebsrv
196ln -s /usr/lib/virtualbox/vbox-img $RPM_BUILD_ROOT/usr/bin/vbox-img
197ln -s /usr/share/virtualbox/src/vboxhost $RPM_BUILD_ROOT/usr/src/vboxhost-%VER%
198mv virtualbox.desktop $RPM_BUILD_ROOT/usr/share/applications/virtualbox.desktop
199mv VBox.png $RPM_BUILD_ROOT/usr/share/pixmaps/VBox.png
200
201
202%pre
203# defaults
204[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
205
206# check for old installation
207if [ -r /etc/vbox/vbox.cfg ]; then
208 . /etc/vbox/vbox.cfg
209 if [ "x$INSTALL_DIR" != "x" -a -d "$INSTALL_DIR" ]; then
210 echo "An old installation of VirtualBox was found. To install this package the"
211 echo "old package has to be removed first. Have a look at /etc/vbox/vbox.cfg to"
212 echo "determine the installation directory of the previous installation. After"
213 echo "uninstalling the old package remove the file /etc/vbox/vbox.cfg."
214 exit 1
215 fi
216fi
217
218# check for active VMs of the installed (old) package
219# Execute the installed packages pre-uninstaller if present.
220/usr/lib/virtualbox/prerm-common.sh 2>/dev/null
221# Stop services from older versions without pre-uninstaller.
222/etc/init.d/vboxballoonctrl-service stop 2>/dev/null
223/etc/init.d/vboxautostart-service stop 2>/dev/null
224/etc/init.d/vboxweb-service stop 2>/dev/null
225VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null || true`
226if [ -n "$VBOXSVC_PID" ]; then
227 # ask the daemon to terminate immediately
228 kill -USR1 $VBOXSVC_PID
229 sleep 1
230 if pidof VBoxSVC > /dev/null 2>&1; then
231 echo "A copy of VirtualBox is currently running. Please close it and try again."
232 echo "Please note that it can take up to ten seconds for VirtualBox (in particular"
233 echo "the VBoxSVC daemon) to finish running."
234 exit 1
235 fi
236fi
237
238# XXX remove old modules from previous versions (disable with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox)
239if [ "$INSTALL_NO_VBOXDRV" != "1" ]; then
240 find /lib/modules -name "vboxdrv\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
241 find /lib/modules -name "vboxnetflt\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
242 find /lib/modules -name "vboxnetadp\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
243 find /lib/modules -name "vboxpci\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
244fi
245
246
247%post
248#include installer-common.sh
249
250LOG="/var/log/vbox-install.log"
251
252# defaults
253[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
254
255# remove old cruft
256if [ -f /etc/init.d/vboxdrv.sh ]; then
257 echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
258 rm /etc/init.d/vboxdrv.sh
259fi
260if [ -f /etc/vbox/vbox.cfg ]; then
261 echo "Found old version of /etc/vbox/vbox.cfg, removing."
262 rm /etc/vbox/vbox.cfg
263fi
264rm -f /etc/vbox/module_not_compiled
265
266# XXX SELinux: allow text relocation entries
267%if %{?rpm_redhat:1}%{!?rpm_redhat:0}
268set_selinux_permissions /usr/lib/virtualbox /usr/share/virtualbox
269%endif
270
271# create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
272if [ "$INSTALL_NO_GROUP" != "1" ]; then
273 echo
274 echo "Creating group 'vboxusers'. VM users must be member of that group!"
275 echo
276 groupadd -r -f vboxusers 2> /dev/null
277fi
278
279# install udev rule (disable with INSTALL_NO_UDEV=1 in /etc/default/virtualbox)
280# and /dev/vboxdrv and /dev/vboxusb/*/* device nodes
281install_device_node_setup root 0600 /usr/share/virtualbox "${usb_group}"
282%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
283/sbin/ldconfig
284%update_menus
285%endif
286update-mime-database /usr/share/mime &> /dev/null || :
287update-desktop-database -q > /dev/null 2>&1 || :
288touch --no-create /usr/share/icons/hicolor
289gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
290
291# Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
292if test "${INSTALL_NO_VBOXDRV}" = 1; then
293 POSTINST_START=--nostart
294 if lsmod | grep -q "vboxdrv[^_-]"; then
295 /usr/lib/virtualbox/vboxdrv.sh stop || true
296 fi
297 # if INSTALL_NO_VBOXDRV is set to 1, remove all shipped modules
298 rm -f /lib/modules/*/misc/vboxdrv.ko
299 rm -f /lib/modules/*/misc/vboxnetflt.ko
300 rm -f /lib/modules/*/misc/vboxnetadp.ko
301 rm -f /lib/modules/*/misc/vboxpci.ko
302else
303 POSTINST_START=
304 if [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko ]; then
305 # compile problem
306 cat << EOF
307No precompiled module for this kernel found -- trying to build one. If this
308fails, check the messages logged to $LOG during module compilation.
309
310EOF
311 fi
312fi
313# Install and start the new service scripts.
314/usr/lib/virtualbox/prerm-common.sh || true
315/usr/lib/virtualbox/postinst-common.sh ${POSTINST_START} > /dev/null || true
316
317
318%preun
319# Called before the package is removed, or during upgrade after (not before)
320# the new version's "post" scriptlet.
321# $1==0: remove the last version of the package
322# $1>=1: upgrade
323if [ "$1" = 0 ]; then
324 /usr/lib/virtualbox/prerm-common.sh || exit 1
325 rm -f /etc/udev/rules.d/60-vboxdrv.rules
326 rm -f /etc/vbox/license_agreed
327 rm -f /etc/vbox/module_not_compiled
328fi
329
330%postun
331%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
332/sbin/ldconfig
333%{clean_desktop_database}
334%clean_menus
335%endif
336update-mime-database /usr/share/mime &> /dev/null || :
337update-desktop-database -q > /dev/null 2>&1 || :
338touch --no-create /usr/share/icons/hicolor
339gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
340rm -rf /usr/lib/virtualbox/ExtensionPacks
341
342
343%clean
344rm -rf $RPM_BUILD_ROOT
345
346
347%files
348%defattr(-,root,root)
349%doc %{!?is_ose: LICENSE}
350%doc UserManual*.pdf
351%doc %{!?is_ose: VirtualBox*.chm}
352%{?rpm_suse: %{py_sitedir}/*}
353%{!?rpm_suse: %{python_sitelib}/*}
354/etc/vbox
355/usr/bin/*
356/usr/src/vbox*
357/usr/lib/virtualbox
358/usr/share/applications/*
359/usr/share/icons/hicolor/*/apps/*
360/usr/share/icons/hicolor/*/mimetypes/*
361/usr/share/mime/packages/*
362/usr/share/pixmaps/*
363/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