VirtualBox

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

最後變更 在這個檔案從87446是 87446,由 vboxsync 提交於 4 年 前

Installer/linux/rpm: try to get python dependencies under control

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

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