VirtualBox

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

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

rpm/deb: add the .debug variants of .r0 and .rc modules to the respective debug packages

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.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%define VBOXDOCDIR %{_defaultdocdir}/%NAME%-%VER%
20%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
21
22Summary: Oracle VM VirtualBox
23Name: %NAME%
24Version: %BUILDVER%_%BUILDREL%
25Release: 1
26URL: http://www.virtualbox.org/
27Source: VirtualBox.tar
28License: GPLv2
29Group: Applications/System
30Vendor: Oracle Corporation
31BuildRoot: %BUILDROOT%
32Requires: %INITSCRIPTS% %LIBASOUND% net-tools
33
34%if %{?rpm_suse:1}%{!?rpm_suse:0}
35%debug_package
36%endif
37
38%MACROSPYTHON%
39
40
41%description
42VirtualBox is a powerful PC virtualization solution allowing
43you to run a wide range of PC operating systems on your Linux
44system. This includes Windows, Linux, FreeBSD, DOS, OpenBSD
45and others. VirtualBox comes with a broad feature set and
46excellent performance, making it the premier virtualization
47software solution on the market.
48
49
50%prep
51%setup -q
52DESTDIR=""
53unset DESTDIR
54
55
56%build
57
58
59%install
60# Mandriva: prevent replacing 'echo' by 'gprintf'
61export DONT_GPRINTIFY=1
62rm -rf $RPM_BUILD_ROOT
63install -m 755 -d $RPM_BUILD_ROOT/sbin
64install -m 755 -d $RPM_BUILD_ROOT%{_initrddir}
65install -m 755 -d $RPM_BUILD_ROOT/lib/modules
66install -m 755 -d $RPM_BUILD_ROOT/etc/vbox
67install -m 755 -d $RPM_BUILD_ROOT/usr/bin
68install -m 755 -d $RPM_BUILD_ROOT/usr/src
69install -m 755 -d $RPM_BUILD_ROOT/usr/share/applications
70install -m 755 -d $RPM_BUILD_ROOT/usr/share/pixmaps
71install -m 755 -d $RPM_BUILD_ROOT/usr/share/icons/hicolor
72install -m 755 -d $RPM_BUILD_ROOT%{VBOXDOCDIR}
73install -m 755 -d $RPM_BUILD_ROOT/usr/lib/virtualbox
74install -m 755 -d $RPM_BUILD_ROOT/usr/share/virtualbox
75install -m 755 -d $RPM_BUILD_ROOT/usr/share/mime/packages
76(export VBOX_INSTALL_PATH=/usr/lib/virtualbox && \
77 cd ./sdk/installer && \
78 %{__python} ./vboxapisetup.py install --prefix %{_prefix} --root $RPM_BUILD_ROOT)
79rm -rf sdk/installer
80mv nls $RPM_BUILD_ROOT/usr/share/virtualbox
81cp -a src $RPM_BUILD_ROOT/usr/share/virtualbox
82mv VBox.sh $RPM_BUILD_ROOT/usr/bin/VBox
83mv VBoxSysInfo.sh $RPM_BUILD_ROOT/usr/share/virtualbox
84cp icons/128x128/virtualbox.png $RPM_BUILD_ROOT/usr/share/pixmaps/virtualbox.png
85cd icons
86 for i in *; do
87 if [ -f $i/virtualbox.* ]; then
88 install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/apps
89 mv $i/virtualbox.* $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/apps
90 fi
91 install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes
92 mv $i/* $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes || true
93 rmdir $i
94 done
95cd -
96rmdir icons
97mv virtualbox.xml $RPM_BUILD_ROOT/usr/share/mime/packages
98mv VBoxTunctl $RPM_BUILD_ROOT/usr/bin
99%if %{?is_ose:0}%{!?is_ose:1}
100for d in /lib/modules/*; do
101 if [ -L $d/build ]; then
102 rm -f /tmp/vboxdrv-Module.symvers
103 ./src/vboxhost/build_in_tmp \
104 --save-module-symvers /tmp/vboxdrv-Module.symvers \
105 --module-source `pwd`/src/vboxhost/vboxdrv \
106 KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
107 %INSTMOD%
108 ./src/vboxhost/build_in_tmp \
109 --use-module-symvers /tmp/vboxdrv-Module.symvers \
110 --module-source `pwd`/src/vboxhost/vboxnetflt \
111 KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
112 %INSTMOD%
113 ./src/vboxhost/build_in_tmp \
114 --use-module-symvers /tmp/vboxdrv-Module.symvers \
115 --module-source `pwd`/src/vboxhost/vboxnetadp \
116 KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
117 %INSTMOD%
118 ./src/vboxhost/build_in_tmp \
119 --use-module-symvers /tmp/vboxdrv-Module.symvers \
120 --module-source `pwd`/src/vboxhost/vboxpci \
121 KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
122 %INSTMOD%
123 fi
124done
125rm -r src
126%endif
127%if %{?is_ose:0}%{!?is_ose:1}
128 for i in rdesktop-vrdp.tar.gz rdesktop-vrdp-keymaps; do
129 mv $i $RPM_BUILD_ROOT/usr/share/virtualbox; done
130 mv rdesktop-vrdp $RPM_BUILD_ROOT/usr/bin
131%endif
132for i in additions/VBoxGuestAdditions.iso; do
133 mv $i $RPM_BUILD_ROOT/usr/share/virtualbox; done
134ln -s VBox $RPM_BUILD_ROOT/usr/bin/VirtualBox
135ln -s VBox $RPM_BUILD_ROOT/usr/bin/virtualbox
136ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxManage
137ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxmanage
138test -f VBoxSDL && ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxSDL
139test -f VBoxSDL && ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxsdl
140ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxVRDP
141ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxHeadless
142ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxheadless
143ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxDTrace
144ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxdtrace
145ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxBalloonCtrl
146ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxballoonctrl
147ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxAutostart
148ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxautostart
149ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxwebsrv
150ln -s /usr/lib/virtualbox/vbox-img $RPM_BUILD_ROOT/usr/bin/vbox-img
151ln -s /usr/share/virtualbox/src/vboxhost $RPM_BUILD_ROOT/usr/src/vboxhost-%VER%
152mv virtualbox.desktop $RPM_BUILD_ROOT/usr/share/applications/virtualbox.desktop
153mv VBox.png $RPM_BUILD_ROOT/usr/share/pixmaps/VBox.png
154%{!?is_ose: mv LICENSE $RPM_BUILD_ROOT%{VBOXDOCDIR}}
155mv UserManual*.pdf $RPM_BUILD_ROOT%{VBOXDOCDIR}
156%{!?is_ose: mv VirtualBox*.chm $RPM_BUILD_ROOT%{VBOXDOCDIR}}
157install -m 755 -d $RPM_BUILD_ROOT/usr/lib/debug/usr/lib/virtualbox
158mv *.debug $RPM_BUILD_ROOT/usr/lib/debug/usr/lib/virtualbox
159mv * $RPM_BUILD_ROOT/usr/lib/virtualbox
160ln -s ../VBoxVMM.so $RPM_BUILD_ROOT/usr/lib/virtualbox/components/VBoxVMM.so
161for i in VirtualBox VBoxHeadless VBoxNetDHCP VBoxNetNAT VBoxNetAdpCtl; do
162 chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/$i; done
163if [ -f $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxVolInfo ]; then
164 chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxVolInfo
165fi
166test -f $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxSDL && \
167 chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxSDL
168
169
170%pre
171# defaults
172[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
173
174# check for old installation
175if [ -r /etc/vbox/vbox.cfg ]; then
176 . /etc/vbox/vbox.cfg
177 if [ "x$INSTALL_DIR" != "x" -a -d "$INSTALL_DIR" ]; then
178 echo "An old installation of VirtualBox was found. To install this package the"
179 echo "old package has to be removed first. Have a look at /etc/vbox/vbox.cfg to"
180 echo "determine the installation directory of the previous installation. After"
181 echo "uninstalling the old package remove the file /etc/vbox/vbox.cfg."
182 exit 1
183 fi
184fi
185
186# check for active VMs of the installed (old) package
187# Execute the installed packages pre-uninstaller if present.
188/usr/lib/virtualbox/prerm-common.sh 2>/dev/null
189# Stop services from older versions without pre-uninstaller.
190/etc/init.d/vboxballoonctrl-service stop 2>/dev/null
191/etc/init.d/vboxautostart-service stop 2>/dev/null
192/etc/init.d/vboxweb-service stop 2>/dev/null
193VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null || true`
194if [ -n "$VBOXSVC_PID" ]; then
195 # ask the daemon to terminate immediately
196 kill -USR1 $VBOXSVC_PID
197 sleep 1
198 if pidof VBoxSVC > /dev/null 2>&1; then
199 echo "A copy of VirtualBox is currently running. Please close it and try again."
200 echo "Please note that it can take up to ten seconds for VirtualBox (in particular"
201 echo "the VBoxSVC daemon) to finish running."
202 exit 1
203 fi
204fi
205
206
207%post
208LOG="/var/log/vbox-install.log"
209
210# defaults
211[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
212
213# remove old cruft
214if [ -f /etc/init.d/vboxdrv.sh ]; then
215 echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
216 rm /etc/init.d/vboxdrv.sh
217fi
218if [ -f /etc/vbox/vbox.cfg ]; then
219 echo "Found old version of /etc/vbox/vbox.cfg, removing."
220 rm /etc/vbox/vbox.cfg
221fi
222rm -f /etc/vbox/module_not_compiled
223
224# create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
225if [ "$INSTALL_NO_GROUP" != "1" ]; then
226 echo
227 echo "Creating group 'vboxusers'. VM users must be member of that group!"
228 echo
229 groupadd -r -f vboxusers 2> /dev/null
230fi
231
232%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
233/sbin/ldconfig
234%update_menus
235%endif
236update-mime-database /usr/share/mime &> /dev/null || :
237update-desktop-database -q > /dev/null 2>&1 || :
238touch --no-create /usr/share/icons/hicolor
239gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
240
241# Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
242if test "${INSTALL_NO_VBOXDRV}" = 1; then
243 POSTINST_START=--nostart
244else
245 POSTINST_START=
246fi
247# Install and start the new service scripts.
248/usr/lib/virtualbox/prerm-common.sh || true
249/usr/lib/virtualbox/postinst-common.sh ${POSTINST_START} > /dev/null || true
250
251
252%preun
253# Called before the package is removed, or during upgrade after (not before)
254# the new version's "post" scriptlet.
255# $1==0: remove the last version of the package
256# $1>=1: upgrade
257if [ "$1" = 0 ]; then
258 /usr/lib/virtualbox/prerm-common.sh || exit 1
259 rm -f /etc/udev/rules.d/60-vboxdrv.rules
260 rm -f /etc/vbox/license_agreed
261 rm -f /etc/vbox/module_not_compiled
262fi
263
264%postun
265%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
266/sbin/ldconfig
267%{clean_desktop_database}
268%clean_menus
269%endif
270update-mime-database /usr/share/mime &> /dev/null || :
271update-desktop-database -q > /dev/null 2>&1 || :
272touch --no-create /usr/share/icons/hicolor
273gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
274rm -rf /usr/lib/virtualbox/ExtensionPacks
275
276
277%clean
278rm -rf $RPM_BUILD_ROOT
279
280
281%files
282%defattr(-,root,root)
283%doc %{VBOXDOCDIR}/*
284%{?rpm_suse: %{py_sitedir}/*}
285%{!?rpm_suse: %{python_sitelib}/*}
286/etc/vbox
287/usr/bin/*
288/usr/src/vbox*
289/usr/lib/virtualbox
290/usr/share/applications/*
291/usr/share/icons/hicolor/*/apps/*
292/usr/share/icons/hicolor/*/mimetypes/*
293/usr/share/mime/packages/*
294/usr/share/pixmaps/*
295/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