VirtualBox

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

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

#8051: Installers: unify Linux host installers as far as possible: since we stopped inserting the common script code containing set_selinux_permissions() into VirtualBox.tmpl that function was no longer called. Move it to postinst-common.sh instead, and remove it from routines.sh and the .run installer.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.9 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%
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}}
157mv * $RPM_BUILD_ROOT/usr/lib/virtualbox
158ln -s ../VBoxVMM.so $RPM_BUILD_ROOT/usr/lib/virtualbox/components/VBoxVMM.so
159for i in VirtualBox VBoxHeadless VBoxNetDHCP VBoxNetNAT VBoxNetAdpCtl; do
160 chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/$i; done
161if [ -f $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxVolInfo ]; then
162 chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxVolInfo
163fi
164test -f $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxSDL && \
165 chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxSDL
166
167
168%pre
169# defaults
170[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
171
172# check for old installation
173if [ -r /etc/vbox/vbox.cfg ]; then
174 . /etc/vbox/vbox.cfg
175 if [ "x$INSTALL_DIR" != "x" -a -d "$INSTALL_DIR" ]; then
176 echo "An old installation of VirtualBox was found. To install this package the"
177 echo "old package has to be removed first. Have a look at /etc/vbox/vbox.cfg to"
178 echo "determine the installation directory of the previous installation. After"
179 echo "uninstalling the old package remove the file /etc/vbox/vbox.cfg."
180 exit 1
181 fi
182fi
183
184# check for active VMs of the installed (old) package
185# Execute the installed packages pre-uninstaller if present.
186/usr/lib/virtualbox/prerm-common.sh 2>/dev/null
187# Stop services from older versions without pre-uninstaller.
188/etc/init.d/vboxballoonctrl-service stop 2>/dev/null
189/etc/init.d/vboxautostart-service stop 2>/dev/null
190/etc/init.d/vboxweb-service stop 2>/dev/null
191VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null || true`
192if [ -n "$VBOXSVC_PID" ]; then
193 # ask the daemon to terminate immediately
194 kill -USR1 $VBOXSVC_PID
195 sleep 1
196 if pidof VBoxSVC > /dev/null 2>&1; then
197 echo "A copy of VirtualBox is currently running. Please close it and try again."
198 echo "Please note that it can take up to ten seconds for VirtualBox (in particular"
199 echo "the VBoxSVC daemon) to finish running."
200 exit 1
201 fi
202fi
203
204
205%post
206LOG="/var/log/vbox-install.log"
207
208# defaults
209[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
210
211# remove old cruft
212if [ -f /etc/init.d/vboxdrv.sh ]; then
213 echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
214 rm /etc/init.d/vboxdrv.sh
215fi
216if [ -f /etc/vbox/vbox.cfg ]; then
217 echo "Found old version of /etc/vbox/vbox.cfg, removing."
218 rm /etc/vbox/vbox.cfg
219fi
220rm -f /etc/vbox/module_not_compiled
221
222# create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
223if [ "$INSTALL_NO_GROUP" != "1" ]; then
224 echo
225 echo "Creating group 'vboxusers'. VM users must be member of that group!"
226 echo
227 groupadd -r -f vboxusers 2> /dev/null
228fi
229
230%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
231/sbin/ldconfig
232%update_menus
233%endif
234update-mime-database /usr/share/mime &> /dev/null || :
235update-desktop-database -q > /dev/null 2>&1 || :
236touch --no-create /usr/share/icons/hicolor
237gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
238
239# Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
240if test "${INSTALL_NO_VBOXDRV}" = 1; then
241 POSTINST_START=--nostart
242else
243 POSTINST_START=
244fi
245# Install and start the new service scripts.
246/usr/lib/virtualbox/prerm-common.sh || true
247/usr/lib/virtualbox/postinst-common.sh ${POSTINST_START} > /dev/null || true
248
249
250%preun
251# Called before the package is removed, or during upgrade after (not before)
252# the new version's "post" scriptlet.
253# $1==0: remove the last version of the package
254# $1>=1: upgrade
255if [ "$1" = 0 ]; then
256 /usr/lib/virtualbox/prerm-common.sh || exit 1
257 rm -f /etc/udev/rules.d/60-vboxdrv.rules
258 rm -f /etc/vbox/license_agreed
259 rm -f /etc/vbox/module_not_compiled
260fi
261
262%postun
263%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
264/sbin/ldconfig
265%{clean_desktop_database}
266%clean_menus
267%endif
268update-mime-database /usr/share/mime &> /dev/null || :
269update-desktop-database -q > /dev/null 2>&1 || :
270touch --no-create /usr/share/icons/hicolor
271gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
272rm -rf /usr/lib/virtualbox/ExtensionPacks
273
274
275%clean
276rm -rf $RPM_BUILD_ROOT
277
278
279%files
280%defattr(-,root,root)
281%doc %{VBOXDOCDIR}/*
282%{?rpm_suse: %{py_sitedir}/*}
283%{!?rpm_suse: %{python_sitelib}/*}
284/etc/vbox
285/usr/bin/*
286/usr/src/vbox*
287/usr/lib/virtualbox
288/usr/share/applications/*
289/usr/share/icons/hicolor/*/apps/*
290/usr/share/icons/hicolor/*/mimetypes/*
291/usr/share/mime/packages/*
292/usr/share/pixmaps/*
293/usr/share/virtualbox
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette