VirtualBox

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

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

rpm: fix for openSUSE

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