VirtualBox

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

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

Installer/linux/rpm: Get rid of all dependencies to python. More recent rpm dependency autodetection creates "python(abi) = X.Y" if there is any file /usr/lib/pythonX.Y, and it also looks carefully at #!.

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

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