summaryrefslogtreecommitdiffstats
path: root/src/VBox/Installer/linux/rpm
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:17:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:17:27 +0000
commitf215e02bf85f68d3a6106c2a1f4f7f063f819064 (patch)
tree6bb5b92c046312c4e95ac2620b10ddf482d3fa8b /src/VBox/Installer/linux/rpm
parentInitial commit. (diff)
downloadvirtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.tar.xz
virtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.zip
Adding upstream version 7.0.14-dfsg.upstream/7.0.14-dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Installer/linux/rpm')
-rw-r--r--src/VBox/Installer/linux/rpm/LocalConfig.kmk44
-rw-r--r--src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec371
-rwxr-xr-xsrc/VBox/Installer/linux/rpm/rules282
3 files changed, 697 insertions, 0 deletions
diff --git a/src/VBox/Installer/linux/rpm/LocalConfig.kmk b/src/VBox/Installer/linux/rpm/LocalConfig.kmk
new file mode 100644
index 00000000..161684f4
--- /dev/null
+++ b/src/VBox/Installer/linux/rpm/LocalConfig.kmk
@@ -0,0 +1,44 @@
+# -*- Makefile -*-
+#
+# Overwrite some default kBuild settings
+#
+
+#
+# Copyright (C) 2006-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# don't build testcases to save time, they are not needed for the package
+VBOX_WITH_TESTCASES :=
+VBOX_WITH_VALIDATIONKIT :=
+
+# required for VBOX_WITH_RUNPATH
+VBOX_WITH_ORIGIN :=
+
+KBUILD_MSG_STYLE := brief
+VBOX_PATH_APP_PRIVATE_ARCH := /usr/lib/virtualbox
+VBOX_PATH_SHARED_LIBS := $(VBOX_PATH_APP_PRIVATE_ARCH)
+VBOX_WITH_RUNPATH := $(VBOX_PATH_APP_PRIVATE_ARCH)
+VBOX_PATH_APP_PRIVATE := /usr/share/virtualbox
+VBOX_PATH_APP_DOCS = $(VBOX_PATH_PACKAGE_DOCS)
+VBOX_WITH_VBOX_IMG := 1
+
+# gcc 4.5 produces some more false positives
+VBOX_WITH_WARNINGS_AS_ERRORS :=
diff --git a/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec b/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
new file mode 100644
index 00000000..829322aa
--- /dev/null
+++ b/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
@@ -0,0 +1,371 @@
+# $Id: VirtualBox.tmpl.spec $
+## @file
+# Spec file for creating VirtualBox rpm packages
+#
+
+#
+# Copyright (C) 2006-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+%define %SPEC% 1
+%define %OSE% 1
+%define %PYTHON% 1
+%define %QHELP% 1
+%define VBOXDOCDIR %{_defaultdocdir}/%NAME%
+%global __requires_exclude_from ^/usr/lib/virtualbox/VBoxPython.*$|^/usr/lib/python.*$|^.*\\.py$
+%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
+
+Summary: Oracle VM VirtualBox
+Name: %NAME%
+Version: %BUILDVER%_%BUILDREL%
+Release: 1
+URL: http://www.virtualbox.org/
+Source: VirtualBox.tar
+License: GPLv3
+Group: Applications/System
+Vendor: Oracle Corporation
+BuildRoot: %BUILDROOT%
+Requires: %INITSCRIPTS% %LIBASOUND% %NETTOOLS% %LIBVULKAN%
+
+%if %{?rpm_suse:1}%{!?rpm_suse:0}
+%debug_package
+%endif
+
+%MACROSPYTHON%
+%if %{?__python3:1}%{!?__python3:0}
+%define vbox_python %{__python3}
+%define vbox_python_sitelib %{python3_sitelib}
+%else
+%define vbox_python %{__python}
+%{?rpm_suse: %define vbox_python_sitelib %{py_sitedir}}
+%{!?rpm_suse: %define vbox_python_sitelib %{python_sitelib}}
+%endif
+
+# Remove source code from debuginfo package, needed for Fedora 27 and later
+# as we build the binaries before creating the RPMs.
+%if 0%{?fedora} >= 27
+%undefine _debugsource_packages
+%undefine _debuginfo_subpackages
+%endif
+%if 0%{?rhel} >= 8
+%undefine _debugsource_packages
+%undefine _debuginfo_subpackages
+%endif
+
+%description
+VirtualBox is a powerful PC virtualization solution allowing
+you to run a wide range of PC operating systems on your Linux
+system. This includes Windows, Linux, FreeBSD, DOS, OpenBSD
+and others. VirtualBox comes with a broad feature set and
+excellent performance, making it the premier virtualization
+software solution on the market.
+
+
+%prep
+%setup -q
+DESTDIR=""
+unset DESTDIR
+
+
+%build
+
+
+%install
+# Mandriva: prevent replacing 'echo' by 'gprintf'
+export DONT_GPRINTIFY=1
+rm -rf $RPM_BUILD_ROOT
+install -m 755 -d $RPM_BUILD_ROOT/sbin
+install -m 755 -d $RPM_BUILD_ROOT%{_initrddir}
+install -m 755 -d $RPM_BUILD_ROOT/lib/modules
+install -m 755 -d $RPM_BUILD_ROOT/etc/vbox
+install -m 755 -d $RPM_BUILD_ROOT/usr/bin
+install -m 755 -d $RPM_BUILD_ROOT/usr/src
+install -m 755 -d $RPM_BUILD_ROOT/usr/share/applications
+install -m 755 -d $RPM_BUILD_ROOT/usr/share/pixmaps
+install -m 755 -d $RPM_BUILD_ROOT/usr/share/icons/hicolor
+install -m 755 -d $RPM_BUILD_ROOT%{VBOXDOCDIR}
+install -m 755 -d $RPM_BUILD_ROOT/usr/lib/virtualbox
+install -m 755 -d $RPM_BUILD_ROOT/usr/share/virtualbox
+install -m 755 -d $RPM_BUILD_ROOT/usr/share/mime/packages
+%if %{?with_python:1}%{!?with_python:0}
+(export VBOX_INSTALL_PATH=/usr/lib/virtualbox && \
+ cd ./sdk/installer && \
+ %{vbox_python} ./vboxapisetup.py install --prefix %{_prefix} --root $RPM_BUILD_ROOT)
+%endif
+rm -rf sdk/installer
+mv UnattendedTemplates $RPM_BUILD_ROOT/usr/share/virtualbox
+mv nls $RPM_BUILD_ROOT/usr/share/virtualbox
+cp -a src $RPM_BUILD_ROOT/usr/share/virtualbox
+mv VBox.sh $RPM_BUILD_ROOT/usr/bin/VBox
+mv VBoxSysInfo.sh $RPM_BUILD_ROOT/usr/share/virtualbox
+cp icons/128x128/virtualbox.png $RPM_BUILD_ROOT/usr/share/pixmaps/virtualbox.png
+cd icons
+ for i in *; do
+ if [ -f $i/virtualbox.* ]; then
+ install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/apps
+ mv $i/virtualbox.* $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/apps
+ fi
+ install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes
+ mv $i/* $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes || true
+ rmdir $i
+ done
+cd -
+rmdir icons
+mv virtualbox.xml $RPM_BUILD_ROOT/usr/share/mime/packages
+%if %{?is_ose:0}%{!?is_ose:1}
+%if "%BUILDREL%" == "el7"
+# For el7 we use gcc from devtoolset-4, which is not suitable for kernel work.
+# See the PATH trickery in src/VBox/Installer/linux/rpm/rules.
+old_path="$PATH"
+PATH=${PATH#/opt/rh/devtoolset-4/root/usr/bin:}
+%endif
+for d in /lib/modules/*; do
+ if [ -L $d/build ]; then
+ rm -f /tmp/vboxdrv-Module.symvers
+ ./src/vboxhost/build_in_tmp \
+ --save-module-symvers /tmp/vboxdrv-Module.symvers \
+ --module-source `pwd`/src/vboxhost/vboxdrv \
+ KBUILD_VERBOSE= KERN_VER=$(basename $d) INSTALL_MODULE_PATH=$RPM_BUILD_ROOT -j4 \
+ %INSTMOD%
+ ./src/vboxhost/build_in_tmp \
+ --use-module-symvers /tmp/vboxdrv-Module.symvers \
+ --module-source `pwd`/src/vboxhost/vboxnetflt \
+ KBUILD_VERBOSE= KERN_VER=$(basename $d) INSTALL_MODULE_PATH=$RPM_BUILD_ROOT -j4 \
+ %INSTMOD%
+ ./src/vboxhost/build_in_tmp \
+ --use-module-symvers /tmp/vboxdrv-Module.symvers \
+ --module-source `pwd`/src/vboxhost/vboxnetadp \
+ KBUILD_VERBOSE= KERN_VER=$(basename $d) INSTALL_MODULE_PATH=$RPM_BUILD_ROOT -j4 \
+ %INSTMOD%
+ if [ -e `pwd`/src/vboxhost/vboxpci ]; then
+ ./src/vboxhost/build_in_tmp \
+ --use-module-symvers /tmp/vboxdrv-Module.symvers \
+ --module-source `pwd`/src/vboxhost/vboxpci \
+ KBUILD_VERBOSE= KERN_VER=$(basename $d) INSTALL_MODULE_PATH=$RPM_BUILD_ROOT -j4 \
+ %INSTMOD%
+ fi
+ fi
+done
+%if "%BUILDREL%" == "el7"
+# For el7 restore PATH, see above.
+PATH="$old_path"
+unset old_path
+%endif
+rm -r src
+%endif
+for i in additions/VBoxGuestAdditions.iso; do
+ mv $i $RPM_BUILD_ROOT/usr/share/virtualbox; done
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VirtualBox
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/virtualbox
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VirtualBoxVM
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/virtualboxvm
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxManage
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxmanage
+test -f VBoxSDL && ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxSDL
+test -f VBoxSDL && ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxsdl
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxVRDP
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxHeadless
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxheadless
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxDTrace
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxAudioTest
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxdtrace
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxaudiotest
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxBugReport
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxbugreport
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxBalloonCtrl
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxballoonctrl
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxAutostart
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxautostart
+test -f vboxwebsrv && ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxwebsrv
+ln -s /usr/lib/virtualbox/vbox-img $RPM_BUILD_ROOT/usr/bin/vbox-img
+ln -s /usr/lib/virtualbox/vboximg-mount $RPM_BUILD_ROOT/usr/bin/vboximg-mount
+ln -s /usr/share/virtualbox/src/vboxhost $RPM_BUILD_ROOT/usr/src/vboxhost-%VER%
+mv virtualbox.desktop $RPM_BUILD_ROOT/usr/share/applications/virtualbox.desktop
+mv VBox.png $RPM_BUILD_ROOT/usr/share/pixmaps/VBox.png
+%{!?is_ose: mv LICENSE $RPM_BUILD_ROOT%{VBOXDOCDIR}}
+mv UserManual*.pdf $RPM_BUILD_ROOT%{VBOXDOCDIR}
+%{?with_qhelp: mv UserManual*.qch UserManual*.qhc $RPM_BUILD_ROOT%{VBOXDOCDIR}}
+install -m 755 -d $RPM_BUILD_ROOT/usr/lib/debug/usr/lib/virtualbox
+%if %{?rpm_suse:1}%{!?rpm_suse:0}
+rm *.debug
+%else
+mv *.debug $RPM_BUILD_ROOT/usr/lib/debug/usr/lib/virtualbox
+%endif
+mv * $RPM_BUILD_ROOT/usr/lib/virtualbox
+if [ -f $RPM_BUILD_ROOT/usr/lib/virtualbox/libQt5CoreVBox.so.5 ]; then
+ $RPM_BUILD_ROOT/usr/lib/virtualbox/chrpath --keepgoing --replace /usr/lib/virtualbox \
+ $RPM_BUILD_ROOT/usr/lib/virtualbox/*.so.5 \
+ $RPM_BUILD_ROOT/usr/lib/virtualbox/plugins/platforms/*.so \
+ $RPM_BUILD_ROOT/usr/lib/virtualbox/plugins/platformthemes/*.so \
+ $RPM_BUILD_ROOT/usr/lib/virtualbox/plugins/sqldrivers/*.so \
+ $RPM_BUILD_ROOT/usr/lib/virtualbox/plugins/styles/*.so \
+ $RPM_BUILD_ROOT/usr/lib/virtualbox/plugins/xcbglintegrations/*.so || true
+ echo "[Paths]" > $RPM_BUILD_ROOT/usr/lib/virtualbox/qt.conf
+ echo "Plugins = /usr/lib/virtualbox/plugins" >> $RPM_BUILD_ROOT/usr/lib/virtualbox/qt.conf
+fi
+rm -f $RPM_BUILD_ROOT/usr/lib/virtualbox/chrpath
+ln -s ../VBoxVMM.so $RPM_BUILD_ROOT/usr/lib/virtualbox/components/VBoxVMM.so
+for i in VBoxHeadless VBoxNetDHCP VBoxNetNAT VBoxNetAdpCtl; do
+ chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/$i; done
+if test -e $RPM_BUILD_ROOT/usr/lib/virtualbox/VirtualBoxVM; then
+ chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VirtualBoxVM
+else
+ chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VirtualBox
+fi
+if [ -f $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxVolInfo ]; then
+ chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxVolInfo
+fi
+test -f $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxSDL && \
+ chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxSDL
+%if %{?with_python:1}%{!?with_python:0}
+if [ -x /usr/bin/pathfix.py ]; then
+ /usr/bin/pathfix.py -pni "%{__python3} %{py3_shbang_opts}" $RPM_BUILD_ROOT/usr/lib/virtualbox/vboxshell.py
+fi
+%endif
+
+
+%pre
+# defaults
+[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
+
+# check for old installation
+if [ -r /etc/vbox/vbox.cfg ]; then
+ . /etc/vbox/vbox.cfg
+ if [ "x$INSTALL_DIR" != "x" -a -d "$INSTALL_DIR" ]; then
+ echo "An old installation of VirtualBox was found. To install this package the"
+ echo "old package has to be removed first. Have a look at /etc/vbox/vbox.cfg to"
+ echo "determine the installation directory of the previous installation. After"
+ echo "uninstalling the old package remove the file /etc/vbox/vbox.cfg."
+ exit 1
+ fi
+fi
+
+# check for active VMs of the installed (old) package
+# Execute the installed packages pre-uninstaller if present.
+/usr/lib/virtualbox/prerm-common.sh 2>/dev/null
+# Stop services from older versions without pre-uninstaller.
+/etc/init.d/vboxballoonctrl-service stop 2>/dev/null
+/etc/init.d/vboxautostart-service stop 2>/dev/null
+/etc/init.d/vboxweb-service stop 2>/dev/null
+VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null || true`
+if [ -n "$VBOXSVC_PID" ]; then
+ # ask the daemon to terminate immediately
+ kill -USR1 $VBOXSVC_PID
+ sleep 1
+ if pidof VBoxSVC > /dev/null 2>&1; then
+ echo "A copy of VirtualBox is currently running. Please close it and try again."
+ echo "Please note that it can take up to ten seconds for VirtualBox (in particular"
+ echo "the VBoxSVC daemon) to finish running."
+ exit 1
+ fi
+fi
+
+
+%post
+LOG="/var/log/vbox-install.log"
+
+# defaults
+[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
+
+# remove old cruft
+if [ -f /etc/init.d/vboxdrv.sh ]; then
+ echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
+ rm /etc/init.d/vboxdrv.sh
+fi
+if [ -f /etc/vbox/vbox.cfg ]; then
+ echo "Found old version of /etc/vbox/vbox.cfg, removing."
+ rm /etc/vbox/vbox.cfg
+fi
+rm -f /etc/vbox/module_not_compiled
+
+# create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
+if [ "$INSTALL_NO_GROUP" != "1" ]; then
+ echo
+ echo "Creating group 'vboxusers'. VM users must be member of that group!"
+ echo
+ groupadd -r -f vboxusers 2> /dev/null
+fi
+
+%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
+/sbin/ldconfig
+%update_menus
+%endif
+update-mime-database /usr/share/mime &> /dev/null || :
+update-desktop-database -q > /dev/null 2>&1 || :
+touch --no-create /usr/share/icons/hicolor
+gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
+
+# Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
+if test "${INSTALL_NO_VBOXDRV}" = 1; then
+ POSTINST_START=--nostart
+else
+ POSTINST_START=
+fi
+# Install and start the new service scripts.
+/usr/lib/virtualbox/prerm-common.sh || true
+/usr/lib/virtualbox/postinst-common.sh ${POSTINST_START} > /dev/null || true
+
+
+%preun
+# Called before the package is removed, or during upgrade after (not before)
+# the new version's "post" scriptlet.
+# $1==0: remove the last version of the package
+# $1>=1: upgrade
+if [ "$1" = 0 ]; then
+ /usr/lib/virtualbox/prerm-common.sh || exit 1
+ rm -f /etc/udev/rules.d/60-vboxdrv.rules
+ rm -f /etc/vbox/license_agreed
+ rm -f /etc/vbox/module_not_compiled
+fi
+
+%postun
+%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
+/sbin/ldconfig
+%{clean_desktop_database}
+%clean_menus
+%endif
+update-mime-database /usr/share/mime &> /dev/null || :
+update-desktop-database -q > /dev/null 2>&1 || :
+touch --no-create /usr/share/icons/hicolor
+gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
+rm -rf /usr/lib/virtualbox/ExtensionPacks
+
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+
+%files
+%defattr(-,root,root)
+%doc %{VBOXDOCDIR}/*
+%if %{?with_python:1}%{!?with_python:0}
+%{vbox_python_sitelib}/*
+%endif
+/etc/vbox
+/usr/bin/*
+/usr/src/vbox*
+/usr/lib/virtualbox
+/usr/share/applications/*
+/usr/share/icons/hicolor/*/apps/*
+/usr/share/icons/hicolor/*/mimetypes/*
+/usr/share/mime/packages/*
+/usr/share/pixmaps/*
+/usr/share/virtualbox
diff --git a/src/VBox/Installer/linux/rpm/rules b/src/VBox/Installer/linux/rpm/rules
new file mode 100755
index 00000000..21cf35ea
--- /dev/null
+++ b/src/VBox/Installer/linux/rpm/rules
@@ -0,0 +1,282 @@
+#!/usr/bin/make -f
+# $Id: rules $
+## @file
+# VirtualBox rules.
+#
+
+#
+# Copyright (C) 2006-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# possible overrides:
+# OSE=1 force VBOX_OSE
+# NOPARALLEL=1 compile with -j1
+# LINUX=<dir> compile vboxdrv against Linux found in <dir>
+# VERBOSE=1 verbose build
+# DEBUG=1 debug build
+# NOSUBVER=1 disable generation of the sub-version field (which is
+# either the subversion rev [if available] or the build date)
+# NODOCS=1 don't build docs, use precompiled UserManual*.pdf and
+# maybe UserManual*.qch and UserManual*.qhc from $(vboxroot)/prebuild
+# NOMODS=1 don't build any module
+# NOQT=1 don't build the Qt GUI
+# NOSDL=1 don't build VBoxSDL
+# EFI=1 include the EFI binary from prebuild
+# VERSUFFIX=<suffix> set a particular package version suffix (e.g. _customer)
+# HEADLESS=1 build the headless version
+# VNC=1 build VNC code
+# NOWEBSVC=1 don't build the webservice API
+# STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
+# PKGDIR=<path> where to store the final package(s)
+# svn_revision=xxx do not depend on subversion being available, but use this
+# hard-coded revision number instead
+#
+# NODOCS will be set if UserManual*.pdf, UserManual*.qch and UserManual*.qhc are
+# placed in $(vboxroot)/prebuild.
+# STAGEDISO will be set if VBoxGuestAdditions.iso is placed there.
+#
+# Wine will not be required if STAGEDISO is set.
+
+verpkg := VirtualBox-7.0
+vboxroot := $(shell while ! test -r configure && ! test "$$PWD" = "/"; do cd ..; done; pwd)
+instlin := $(vboxroot)/src/VBox/Installer/linux
+pkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd $(vboxroot)/..; pwd))
+outdir := $(if $(PATH_OUT_BASE),$(PATH_OUT_BASE),$(vboxroot)/out)
+bldbase := $(outdir)/rpm
+builddir := $(bldbase)/builddir
+stagedir := $(bldbase)/rpmbuild
+rpmlib := $(shell if [ `uname -m` = "x86_64" ]; then echo "lib64"; else echo "lib"; fi)
+verfile := $(builddir)/version-generated.mk
+ose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
+chrarch := $(shell if [ `uname -m` = "x86_64" ]; then echo "amd64"; else echo "x86"; fi)
+-include $(vboxroot)/SVN_REVISION
+
+NOMODS ?= $(ose)
+NOQT ?= $(HEADLESS)
+NOSDL ?= $(HEADLESS)
+NOWEBSVC ?=
+EFI ?= $(if $(wildcard $(vboxroot)/prebuild/VBoxEFI32.fd $(vboxroot)/prebuild/VBoxEFI64.fd),1,)
+NODOCS ?= $(if $(wildcard $(addprefix $(vboxroot)/prebuild/,UserManual*.pdf UserManual*.qch UserManual*.qhc)),1,)
+STAGEDISO ?= $(if $(wildcard $(vboxroot)/prebuild/VBoxGuestAdditions.iso),$(vboxroot)/prebuild,)
+NOWINE := $(if $(STAGEDISO),1,$(ose))
+
+ifneq ($(STAGEDISO),)
+ ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
+ $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
+ endif
+endif
+
+ifeq ($(wildcard rpm/rules),)
+$(error call rpm/rules from src/VBox/Installer/linux)
+endif
+
+ifneq ($(MAKECMDGOALS),clean)
+ # look for fedora
+ rpmrel := $(shell cat /etc/fedora-release 2> /dev/null | sed -e 's/^Fedora *release *\([1-9][0-9]*\) .*/fedora\1/')
+ ifeq ($(rpmrel),)
+ # look for OEL
+ rpmrel := $(shell cat /etc/enterprise-release 2> /dev/null | sed -ne 's/^Enterprise Linux[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
+ endif
+ ifeq ($(rpmrel),)
+ # look for OL
+ rpmrel := $(shell cat /etc/oracle-release 2> /dev/null | sed -ne 's/^Oracle Linux[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
+ endif
+ ifeq ($(rpmrel),)
+ # look for CentOS
+ rpmrel := $(shell cat /etc/redhat-release 2> /dev/null | sed -ne 's/^CentOS[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
+ endif
+ ifeq ($(rpmrel),)
+ # look for Red Hat
+ rpmrel := $(shell cat /etc/redhat-release 2> /dev/null | sed -ne 's/^Red Hat[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
+ endif
+ ifeq ($(rpmrel),)
+ # look for openSUSE
+ rpmrel := $(shell cat /etc/SUSE-brand 2> /dev/null | sed -ne 's/^VERSION *= *\([0-9]*\)\.\([0-9]*\)/openSUSE\1\2/p')
+ endif
+ # look for openSUSE Tumbleweed
+ ifeq ($(rpmrel),)
+ rpmrel := $(shell cat /etc/SUSE-brand 2> /dev/null | sed -ne 's/^VERSION *= *tumbleweed/openSUSETW/p')
+ endif
+ ifeq ($(rpmrel),)
+ $(error failed to detect the release type. Hack the detection.)
+ endif
+
+ rpmdist := $(strip $(shell grep $(rpmrel) $(instlin)/distributions_rpm | cut -d'=' -f2))
+ ifeq ($(rpmdist),)
+ $(error Cannot detect package distribution (rpmrel=$(rpmrel)))
+ endif
+
+ ifeq ($(filter-out el5 el6 el7 el8 el9 fedora18 fedora19 fedora20 fedora21 fedora22 fedora24 fedora25 fedora26 fedora29 fedora31 fedora32 fedora33 fedora35 fedora36,$(rpmrel)),)
+ rpmspec := rpm_redhat
+ endif
+ ifeq ($(filter-out openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114 openSUSE123 openSUSE131 openSUSE132 openSUSE150 openSUSE153 openSUSETW,$(rpmrel)),)
+ rpmspec := rpm_suse
+ endif
+ ifeq ($(rpmspec),)
+ $(error failed to detect the .spec file (rpmrel=$(rpmrel)))
+ endif
+endif
+
+ifneq ($(wildcard $(verfile)),)
+include $(verfile)
+ver := $(VBOX_VERSION_STRING)
+svnver := $(if $(NOSUBVER),,$(if $(svn_revision),-$(svn_revision),$(shell if \
+ svn info $(vboxroot) > /dev/null 2>&1; then \
+ svn info $(vboxroot)|sed -e "s/^Revision: \(.*\)/-\1/;t;d"; else \
+ date +"-%Y%m%d"; fi)))
+rpmver := $(ver)$(subst -,_,$(svnver))$(VERSUFFIX)$(if $(HEADLESS),_headless,)$(if $(DEBUG),_dbg,)
+archdir := $(bldbase)/VirtualBox-$(ver)
+rpmname := $(verpkg)-$(rpmver)_$(rpmrel)
+endif
+
+# never ship any modules
+instmod :=
+
+ifeq ($(wildcard /usr/share/doc/packages/bash),)
+ doc_dir := VBOX_PATH_PACKAGE_DOCS="/usr/share/doc/$(verpkg)"
+else
+ # Novell (OpenSUSE, SLES)
+ doc_dir := VBOX_PATH_PACKAGE_DOCS="/usr/share/doc/packages/$(verpkg)"
+endif
+
+ifeq ($(NOQT),)
+ ifeq ($(rpmrel),el7)
+ # Protect against the fact that this Makefile is run several times, updating
+ # PATH every time. Still assumes that nothing else is added as a prefix.
+ PATH := $(PATH:/opt/rh/devtoolset-9/root/usr/bin:%=%)
+ export PATH := /opt/rh/devtoolset-9/root/usr/bin:$(PATH)
+ endif
+endif
+
+# EL5 ships Python 2.4 while our Python support requires Python 2.6 or later
+cfg_flags := $(if $(NOQT),--disable-qt,) \
+ $(if $(NOSDL),--disable-vboxsdl,) \
+ $(if $(filter el5 el6,$(rpmrel)),--build-libvpx,) \
+ $(if $(filter el5 el6,$(rpmrel)),--build-libopus,) \
+ $(if $(filter el5 el6,$(rpmrel)),--build-libssl,) \
+ $(if $(filter el5,$(rpmrel)),--build-libcurl,) \
+ $(if $(filter el5,$(rpmrel)),--disable-sdl-ttf,) \
+ $(if $(filter el5,$(rpmrel)),--disable-pulse,) \
+ $(if $(filter el5,$(rpmrel)),--disable-python,) \
+ $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
+ $(if $(HEADLESS),--build-headless,) \
+ $(if $(DEBUG),--build-debug,) \
+ $(if $(NOWINE),,--setup-wine) \
+ $(if $(VNC),--enable-vnc,) \
+ $(if $(PATH_OUT_BASE),--out-base-dir=$(PATH_OUT_BASE),) \
+ --disable-extpack
+
+bld_flags := LOCALCFG=$(instlin)/rpm/LocalConfig.kmk \
+ PATH_OUT=$(builddir) \
+ VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
+ VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
+ $(if $(filter el5 el6,$(rpmrel)),,VBOX_WITH_VMSVGA3D=1) \
+ VBOX_DO_STRIP= \
+ $(if $(filter el5,$(rpmrel)),VBOX_BLD_PYTHON=$(firstword $(wildcard \
+ /usr/local/bin/python2.7 /usr/bin/python2.7 /usr/bin/python2.6 /usr/bin/python2 /usr/bin/python)),) \
+ $(if $(filter el5,$(rpmrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1) \
+ $(doc_dir) \
+ VBOX_PACKAGE_DIST=$(rpmdist) \
+ $(if $(svn_revision),VBOX_SVN_REV=$(svn_revision),) \
+ $(if $(NODOCS),VBOX_WITH_DOCS=,) \
+ $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
+ $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,)
+
+configure: $(bldbase)/configure-stamp
+$(bldbase)/configure-stamp:
+ mkdir -p $(bldbase)
+ cd $(vboxroot) && ./configure --odir=$(bldbase) $(cfg_flags)
+ touch $@
+
+build: $(bldbase)/configure-stamp $(bldbase)/build-stamp
+$(bldbase)/build-stamp $(verfile): $(bldbase)/configure-stamp
+ . $(bldbase)/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
+ # Files from prebuild go to (builddir)/bin to be used during the
+ # packing stage, overriding what the build did/would produce.
+ $(if $(NODOCS),cp $(addprefix $(vboxroot)/prebuild/,UserManual*.pdf UserManual*.qch UserManual*.qhc) $(builddir)/bin,)
+ $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
+ $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
+ mkdir -p $(builddir)/bin/additions
+ $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
+ . $(bldbase)/env.sh && kmk -C $(vboxroot) $(bld_flags) \
+ VBOX_NO_LINUX_RUN_INSTALLER=1 \
+ VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86.tar.bz2 \
+ VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64.tar.bz2 \
+ VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
+ VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
+ packing
+ touch $(bldbase)/build-stamp
+
+clean:
+ rm -rf $(archdir)
+ rm -rf $(stagedir)
+ rm -rf $(builddir)
+ rm -rf $(bldbase)/wine.*
+ rm -rf $(bldbase)/VirtualBox-*
+ rm -f $(bldbase)/VirtualBox.tar $(bldbase)/VirtualBox.tar.bz2
+ rm -f $(bldbase)/build-stamp $(bldbase)/configure-stamp
+ rm -f $(bldbase)/AutoConfig.kmk $(bldbase)/configure.log $(bldbase)/env.sh
+ rm -f $(bldbase)/VirtualBox.spec
+ if [ -d $(bldbase) ]; then rmdir $(bldbase); fi
+
+ifeq ($(VBOX_VERSION_MAJOR),)
+binary: build $(verfile)
+ +$(MAKE) -f rpm/rules binary
+
+else
+binary: build
+ rm -rf $(bldbase)/VirtualBox-*
+ tar -xf $(builddir)/bin/VirtualBox.tar -C $(bldbase)
+ sed \
+ -e 's|%VER%|$(ver)|g' \
+ -e 's|%NAME%|$(verpkg)|g' \
+ -e 's|%BUILDVER%|$(rpmver)|g' \
+ -e 's|%BUILDREL%|$(rpmrel)|g' \
+ -e 's|%BUILDROOT%|$(bldbase)/buildroot|g' \
+ -e 's|%OSE%|$(if $(ose),is_ose,not_ose)|g' \
+ -e 's|%SPEC%|$(rpmspec)|g' \
+ -e 's|%QHELP%|$(if $(STAGEDQHELP),with_qhelp,without_qhelp)|g' \
+ -e 's|%PYTHON%|$(if $(filter el5,$(rpmrel)),without_python,with_python)|g' \
+ -e 's|%MACROSPYTHON%|$(if $(wildcard /usr/lib/rpm/macros.d/macros.python3),,$(if $(wildcard /usr/lib/rpm/macros.python),%include /usr/lib/rpm/macros.python,))|g' \
+ -e 's|%INSTMOD%|$(instmod)|g' \
+ -e 's|%LIBASOUND%|$(if $(filter lib64,$(rpmlib)),libasound.so.2()(64bit),libasound.so.2)|g' \
+ -e 's|%INITSCRIPTS%|$(if $(filter fedora,$(rpmspec)),initscripts,)|g' \
+ -e 's|%NETTOOLS%|$(if $(filter fedora18 fedora19 fedora20 fedora21 el5 openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114,$(rpmrel)),net-tools,iproute)|g' \
+ -e 's|%LIBVULKAN%|$(if $(filter el7,$(rpmrel)),vulkan,%LIBVULKAN%)|g' \
+ -e 's|%LIBVULKAN%|$(if $(findstring el,$(rpmrel)),vulkan-loader,%LIBVULKAN%)|g' \
+ -e 's|%LIBVULKAN%|$(if $(findstring fedora,$(rpmrel)),vulkan-loader,%LIBVULKAN%)|g' \
+ -e 's|%LIBVULKAN%|$(if $(filter openSUSE153,$(rpmrel)),libvulkan1,)|g' \
+ $(instlin)/rpm/VirtualBox.tmpl.spec > $(archdir)/VirtualBox.spec
+ mv $(bldbase)/VirtualBox-$(ver) $(bldbase)/$(rpmname)
+ cp $(vboxroot)/tools/linux.$(chrarch)/bin/chrpath $(bldbase)/$(rpmname) || true
+ tar -cf $(bldbase)/VirtualBox.tar -C $(bldbase) $(rpmname)
+ rm -f $(stagedir)/RPMS/*/VirtualBox*rpm
+ rm -f $(stagedir)/SPECS/*
+ mkdir -p $(stagedir)/BUILD $(stagedir)/RPMS/i386 $(stagedir)/RPMS/x86_64 $(stagedir)/SOURCES $(stagedir)/SPECS $(stagedir)/SRPMS
+ (cd $(bldbase); rpmbuild --define '_topdir $(stagedir)' -tb --clean VirtualBox.tar)
+ mv $(stagedir)/RPMS/*/$(verpkg)-debug* $(pkgdir) || true
+ file=`find $(stagedir)/RPMS -name $(verpkg)*rpm -print`; \
+ mv $$file $(pkgdir)
+# Note! if rpmbuild fails: sudo chmod a+rw /usr/src/redhat/* /usr/src/redhat/RPMS/*
+# Note! if find/mv fails: sudo ln -s redhat/ /usr/src/packages
+endif
+
+.PHONY: binary configure build clean