VirtualBox

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

Last change on this file since 106199 was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 12.9 KB
Line 
1# $Id: VirtualBox.tmpl.spec 106061 2024-09-16 14:03:52Z vboxsync $
2## @file
3# Spec file for creating VirtualBox rpm packages
4#
5
6#
7# Copyright (C) 2006-2024 Oracle and/or its affiliates.
8#
9# This file is part of VirtualBox base platform packages, as
10# available from https://www.virtualbox.org.
11#
12# This program is free software; you can redistribute it and/or
13# modify it under the terms of the GNU General Public License
14# as published by the Free Software Foundation, in version 3 of the
15# License.
16#
17# This program is distributed in the hope that it will be useful, but
18# WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20# General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, see <https://www.gnu.org/licenses>.
24#
25# SPDX-License-Identifier: GPL-3.0-only
26#
27
28%define %SPEC% 1
29%define %OSE% 1
30%define %PYTHON% 1
31%define VBOXDOCDIR %{_defaultdocdir}/%NAME%
32%global __requires_exclude_from ^/usr/lib/virtualbox/VBoxPython.*$|^/usr/lib/python.*$|^.*\\.py$
33%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
34
35Summary: Oracle VirtualBox
36Name: %NAME%
37Version: %BUILDVER%_%BUILDREL%
38Release: 1
39URL: http://www.virtualbox.org/
40Source: VirtualBox.tar
41License: GPLv3
42Group: Applications/System
43Vendor: Oracle Corporation
44BuildRoot: %BUILDROOT%
45Requires: %INITSCRIPTS% %LIBASOUND% %NETTOOLS% %LIBVULKAN%
46
47%if %{?rpm_suse:1}%{!?rpm_suse:0}
48%debug_package
49%endif
50
51%MACROSPYTHON%
52%if %{?__python3:1}%{!?__python3:0}
53%define vbox_python %{__python3}
54%define vbox_python_sitelib %{python3_sitelib}
55%else
56%define vbox_python %{__python}
57%{?rpm_suse: %define vbox_python_sitelib %{py_sitedir}}
58%{!?rpm_suse: %define vbox_python_sitelib %{python_sitelib}}
59%endif
60
61# Remove source code from debuginfo package, needed for Fedora 27 and later
62# as we build the binaries before creating the RPMs.
63%if 0%{?fedora} >= 27
64%undefine _debugsource_packages
65%undefine _debuginfo_subpackages
66%endif
67%if 0%{?rhel} >= 8
68%undefine _debugsource_packages
69%undefine _debuginfo_subpackages
70%endif
71
72%description
73VirtualBox is a powerful PC virtualization solution allowing
74you to run a wide range of PC operating systems on your Linux
75system. This includes Windows, Linux, FreeBSD, DOS, OpenBSD
76and others. VirtualBox comes with a broad feature set and
77excellent performance, making it the premier virtualization
78software solution on the market.
79
80
81%prep
82%setup -q
83DESTDIR=""
84unset DESTDIR
85
86
87%build
88
89
90%install
91# Mandriva: prevent replacing 'echo' by 'gprintf'
92export DONT_GPRINTIFY=1
93rm -rf $RPM_BUILD_ROOT
94install -m 755 -d $RPM_BUILD_ROOT/sbin
95install -m 755 -d $RPM_BUILD_ROOT%{_initrddir}
96install -m 755 -d $RPM_BUILD_ROOT/lib/modules
97install -m 755 -d $RPM_BUILD_ROOT/etc/vbox
98install -m 755 -d $RPM_BUILD_ROOT/usr/bin
99install -m 755 -d $RPM_BUILD_ROOT/usr/src
100install -m 755 -d $RPM_BUILD_ROOT/usr/share/applications
101install -m 755 -d $RPM_BUILD_ROOT/usr/share/pixmaps
102install -m 755 -d $RPM_BUILD_ROOT/usr/share/icons/hicolor
103install -m 755 -d $RPM_BUILD_ROOT%{VBOXDOCDIR}
104install -m 755 -d $RPM_BUILD_ROOT/usr/lib/virtualbox
105install -m 755 -d $RPM_BUILD_ROOT/usr/share/virtualbox
106install -m 755 -d $RPM_BUILD_ROOT/usr/share/mime/packages
107%if %{?with_python:1}%{!?with_python:0}
108(export VBOX_INSTALL_PATH=/usr/lib/virtualbox && \
109 cd ./sdk/installer/python && \
110 %{vbox_python} ./vboxapisetup.py install --prefix %{_prefix} --root $RPM_BUILD_ROOT)
111%endif
112rm -rf sdk/installer
113mv UnattendedTemplates $RPM_BUILD_ROOT/usr/share/virtualbox
114mv nls $RPM_BUILD_ROOT/usr/share/virtualbox
115cp -a src $RPM_BUILD_ROOT/usr/share/virtualbox
116mv VBox.sh $RPM_BUILD_ROOT/usr/bin/VBox
117mv VBoxSysInfo.sh $RPM_BUILD_ROOT/usr/share/virtualbox
118cp icons/128x128/virtualbox.png $RPM_BUILD_ROOT/usr/share/pixmaps/virtualbox.png
119cd icons
120 for i in *; do
121 if [ -f $i/virtualbox.* ]; then
122 install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/apps
123 mv $i/virtualbox.* $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/apps
124 fi
125 install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes
126 mv $i/* $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes || true
127 rmdir $i
128 done
129cd -
130rmdir icons
131mv virtualbox.xml $RPM_BUILD_ROOT/usr/share/mime/packages
132%if %{?is_ose:0}%{!?is_ose:1}
133%if "%BUILDREL%" == "el7"
134# For el7 we use gcc from devtoolset-4, which is not suitable for kernel work.
135# See the PATH trickery in src/VBox/Installer/linux/rpm/rules.
136old_path="$PATH"
137PATH=${PATH#/opt/rh/devtoolset-4/root/usr/bin:}
138%endif
139for d in /lib/modules/*; do
140 if [ -L $d/build ]; then
141 rm -f /tmp/vboxdrv-Module.symvers
142 ./src/vboxhost/build_in_tmp \
143 --save-module-symvers /tmp/vboxdrv-Module.symvers \
144 --module-source `pwd`/src/vboxhost/vboxdrv \
145 KBUILD_VERBOSE= KERN_VER=$(basename $d) INSTALL_MODULE_PATH=$RPM_BUILD_ROOT -j4 \
146 %INSTMOD%
147 ./src/vboxhost/build_in_tmp \
148 --use-module-symvers /tmp/vboxdrv-Module.symvers \
149 --module-source `pwd`/src/vboxhost/vboxnetflt \
150 KBUILD_VERBOSE= KERN_VER=$(basename $d) INSTALL_MODULE_PATH=$RPM_BUILD_ROOT -j4 \
151 %INSTMOD%
152 ./src/vboxhost/build_in_tmp \
153 --use-module-symvers /tmp/vboxdrv-Module.symvers \
154 --module-source `pwd`/src/vboxhost/vboxnetadp \
155 KBUILD_VERBOSE= KERN_VER=$(basename $d) INSTALL_MODULE_PATH=$RPM_BUILD_ROOT -j4 \
156 %INSTMOD%
157 if [ -e `pwd`/src/vboxhost/vboxpci ]; then
158 ./src/vboxhost/build_in_tmp \
159 --use-module-symvers /tmp/vboxdrv-Module.symvers \
160 --module-source `pwd`/src/vboxhost/vboxpci \
161 KBUILD_VERBOSE= KERN_VER=$(basename $d) INSTALL_MODULE_PATH=$RPM_BUILD_ROOT -j4 \
162 %INSTMOD%
163 fi
164 fi
165done
166%if "%BUILDREL%" == "el7"
167# For el7 restore PATH, see above.
168PATH="$old_path"
169unset old_path
170%endif
171rm -r src
172%endif
173for i in additions/VBoxGuestAdditions.iso; do
174 mv $i $RPM_BUILD_ROOT/usr/share/virtualbox; done
175ln -s VBox $RPM_BUILD_ROOT/usr/bin/VirtualBox
176ln -s VBox $RPM_BUILD_ROOT/usr/bin/virtualbox
177ln -s VBox $RPM_BUILD_ROOT/usr/bin/VirtualBoxVM
178ln -s VBox $RPM_BUILD_ROOT/usr/bin/virtualboxvm
179ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxManage
180ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxmanage
181test -f VBoxSDL && ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxSDL
182test -f VBoxSDL && ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxsdl
183ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxVRDP
184ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxHeadless
185ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxheadless
186ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxDTrace
187ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxAudioTest
188ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxdtrace
189ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxaudiotest
190test -f VBoxBugReport && ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxBugReport
191test -f VBoxBugReport && ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxbugreport
192test -f VBoxBalloonCtrl && ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxBalloonCtrl
193test -f VBoxBalloonCtrl && ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxballoonctrl
194test -f VBoxAutostart && ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxAutostart
195test -f VBoxAutostart && ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxautostart
196test -f vboxwebsrv && ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxwebsrv
197ln -s /usr/lib/virtualbox/vbox-img $RPM_BUILD_ROOT/usr/bin/vbox-img
198ln -s /usr/lib/virtualbox/vboximg-mount $RPM_BUILD_ROOT/usr/bin/vboximg-mount
199ln -s /usr/share/virtualbox/src/vboxhost $RPM_BUILD_ROOT/usr/src/vboxhost-%VER%
200mv virtualbox.desktop $RPM_BUILD_ROOT/usr/share/applications/virtualbox.desktop
201mv VBox.png $RPM_BUILD_ROOT/usr/share/pixmaps/VBox.png
202%{!?is_ose: mv LICENSE $RPM_BUILD_ROOT%{VBOXDOCDIR}}
203mv UserManual*.pdf UserManual*.qch UserManual*.qhc $RPM_BUILD_ROOT%{VBOXDOCDIR}
204install -m 755 -d $RPM_BUILD_ROOT/usr/lib/debug/usr/lib/virtualbox
205%if %{?rpm_suse:1}%{!?rpm_suse:0}
206rm *.debug
207%else
208mv *.debug $RPM_BUILD_ROOT/usr/lib/debug/usr/lib/virtualbox
209%endif
210mv * $RPM_BUILD_ROOT/usr/lib/virtualbox
211if [ -f $RPM_BUILD_ROOT/usr/lib/virtualbox/libQt6CoreVBox.so.6 ]; then
212 $RPM_BUILD_ROOT/usr/lib/virtualbox/chrpath --keepgoing --replace /usr/lib/virtualbox \
213 $RPM_BUILD_ROOT/usr/lib/virtualbox/*.so.6 \
214 $RPM_BUILD_ROOT/usr/lib/virtualbox/plugins/platforms/*.so \
215 $RPM_BUILD_ROOT/usr/lib/virtualbox/plugins/platformthemes/*.so \
216 $RPM_BUILD_ROOT/usr/lib/virtualbox/plugins/sqldrivers/*.so \
217 $RPM_BUILD_ROOT/usr/lib/virtualbox/plugins/styles/*.so || true
218 echo "[Paths]" > $RPM_BUILD_ROOT/usr/lib/virtualbox/qt.conf
219 echo "Plugins = /usr/lib/virtualbox/plugins" >> $RPM_BUILD_ROOT/usr/lib/virtualbox/qt.conf
220fi
221rm -f $RPM_BUILD_ROOT/usr/lib/virtualbox/chrpath
222ln -s ../VBoxVMM.so $RPM_BUILD_ROOT/usr/lib/virtualbox/components/VBoxVMM.so
223for i in VirtualBoxVM VBoxHeadless VBoxNetDHCP VBoxNetNAT VBoxNetAdpCtl; do
224 chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/$i; done
225if [ -f $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxVolInfo ]; then
226 chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxVolInfo
227fi
228test -f $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxSDL && \
229 chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxSDL
230%if %{?with_python:1}%{!?with_python:0}
231if [ -x /usr/bin/pathfix.py ]; then
232 /usr/bin/pathfix.py -pni "%{__python3} %{py3_shbang_opts}" $RPM_BUILD_ROOT/usr/lib/virtualbox/vboxshell.py
233fi
234%endif
235
236
237%pre
238# defaults
239[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
240
241# check for old installation
242if [ -r /etc/vbox/vbox.cfg ]; then
243 . /etc/vbox/vbox.cfg
244 if [ "x$INSTALL_DIR" != "x" -a -d "$INSTALL_DIR" ]; then
245 echo "An old installation of VirtualBox was found. To install this package the"
246 echo "old package has to be removed first. Have a look at /etc/vbox/vbox.cfg to"
247 echo "determine the installation directory of the previous installation. After"
248 echo "uninstalling the old package remove the file /etc/vbox/vbox.cfg."
249 exit 1
250 fi
251fi
252
253# check for active VMs of the installed (old) package
254# Execute the installed packages pre-uninstaller if present.
255/usr/lib/virtualbox/prerm-common.sh 2>/dev/null
256# Stop services from older versions without pre-uninstaller.
257/etc/init.d/vboxballoonctrl-service stop 2>/dev/null
258/etc/init.d/vboxautostart-service stop 2>/dev/null
259/etc/init.d/vboxweb-service stop 2>/dev/null
260VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null || true`
261if [ -n "$VBOXSVC_PID" ]; then
262 # ask the daemon to terminate immediately
263 kill -USR1 $VBOXSVC_PID
264 sleep 1
265 if pidof VBoxSVC > /dev/null 2>&1; then
266 echo "A copy of VirtualBox is currently running. Please close it and try again."
267 echo "Please note that it can take up to ten seconds for VirtualBox (in particular"
268 echo "the VBoxSVC daemon) to finish running."
269 exit 1
270 fi
271fi
272
273
274%post
275LOG="/var/log/vbox-install.log"
276
277# defaults
278[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
279
280# remove old cruft
281if [ -f /etc/init.d/vboxdrv.sh ]; then
282 echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
283 rm /etc/init.d/vboxdrv.sh
284fi
285if [ -f /etc/vbox/vbox.cfg ]; then
286 echo "Found old version of /etc/vbox/vbox.cfg, removing."
287 rm /etc/vbox/vbox.cfg
288fi
289rm -f /etc/vbox/module_not_compiled
290
291# create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
292if [ "$INSTALL_NO_GROUP" != "1" ]; then
293 echo
294 echo "Creating group 'vboxusers'. VM users must be member of that group!"
295 echo
296 groupadd -r -f vboxusers 2> /dev/null
297fi
298
299%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
300/sbin/ldconfig
301%update_menus
302%endif
303update-mime-database /usr/share/mime &> /dev/null || :
304update-desktop-database -q > /dev/null 2>&1 || :
305touch --no-create /usr/share/icons/hicolor
306gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
307
308# Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
309if test "${INSTALL_NO_VBOXDRV}" = 1; then
310 POSTINST_START=--nostart
311else
312 POSTINST_START=
313fi
314# Install and start the new service scripts.
315/usr/lib/virtualbox/prerm-common.sh || true
316/usr/lib/virtualbox/postinst-common.sh ${POSTINST_START} > /dev/null || true
317
318
319%preun
320# Called before the package is removed, or during upgrade after (not before)
321# the new version's "post" scriptlet.
322# $1==0: remove the last version of the package
323# $1>=1: upgrade
324if [ "$1" = 0 ]; then
325 /usr/lib/virtualbox/prerm-common.sh || exit 1
326 rm -f /etc/udev/rules.d/60-vboxdrv.rules
327 rm -f /etc/vbox/license_agreed
328 rm -f /etc/vbox/module_not_compiled
329fi
330
331%postun
332%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
333/sbin/ldconfig
334%{clean_desktop_database}
335%clean_menus
336%endif
337update-mime-database /usr/share/mime &> /dev/null || :
338update-desktop-database -q > /dev/null 2>&1 || :
339touch --no-create /usr/share/icons/hicolor
340gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
341rm -rf /usr/lib/virtualbox/ExtensionPacks
342
343
344%clean
345rm -rf $RPM_BUILD_ROOT
346
347
348%changelog
349* %DATE% Oracle Corporation <info@virtualbox.org>
350- rebuild RPM package, see https://www.virtualbox.org/wiki/Changelog
351
352
353%files
354%defattr(-,root,root)
355%doc %{VBOXDOCDIR}/*
356%if %{?with_python:1}%{!?with_python:0}
357%{vbox_python_sitelib}/*
358%endif
359/etc/vbox
360/usr/bin/*
361/usr/src/vbox*
362/usr/lib/virtualbox
363/usr/share/applications/*
364/usr/share/icons/hicolor/*/apps/*
365/usr/share/icons/hicolor/*/mimetypes/*
366/usr/share/mime/packages/*
367/usr/share/pixmaps/*
368/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