From 2d01b3d133c0fbf17de8d7b47905585af88bd6e4 Mon Sep 17 00:00:00 2001
From: V3n3RiX <venerix@koprulu.sector>
Date: Thu, 18 Apr 2024 12:04:39 +0100
Subject: gentoo auto-resync : 18:04:2024 - 12:04:39

---
 app-emulation/virtualbox/Manifest                 |   4 +
 app-emulation/virtualbox/virtualbox-7.0.16.ebuild | 740 ++++++++++++++++++++++
 2 files changed, 744 insertions(+)
 create mode 100644 app-emulation/virtualbox/virtualbox-7.0.16.ebuild

(limited to 'app-emulation/virtualbox')

diff --git a/app-emulation/virtualbox/Manifest b/app-emulation/virtualbox/Manifest
index 5db7287f8e18..40554bddf8be 100644
--- a/app-emulation/virtualbox/Manifest
+++ b/app-emulation/virtualbox/Manifest
@@ -16,15 +16,19 @@ DIST VirtualBox-6.1.48.tar.bz2 165960987 BLAKE2B c981e390ae518b829970827f6032fb1
 DIST VirtualBox-6.1.50.tar.bz2 165959648 BLAKE2B e244c4fa2ffe86216664104473e27e8ddbad86aae3bc26612d18204a4e67cece91d1fa3aa9e70f1c39f915bf5e4a1e6a14bbb19162c3ae2ff554373df95bce51 SHA512 ee2ec352e020f07262bf2120278d0d9807c501cd7c4d621d4e12ce18a821b134d48eb852bc7136008cfa77ed709703d3c2835b7a7177c325d989e8f433aff73f
 DIST VirtualBox-7.0.12.tar.bz2 175644088 BLAKE2B 507cbf7b1a8a807bd2602e74bc19a59cb177b9b2bdefa1be582e520666360a42510ca501f20c354746a0f1dadf61fe29135e3edc867e611bfe60a9405cb2bbce SHA512 9fe4511442eba788d02f932f5e98cfcc5aa4ebed41c00bd7333cf7e3f5de787e458f1f56930978283f041f403652c803143335fe9120ab63a2c113ca7b3f588f
 DIST VirtualBox-7.0.14.tar.bz2 175654864 BLAKE2B 99f4942b864ce481d69983af31393d763452c5b55697ab642b43c155f5fbc2a9963fbe1b7744baef620d0b351e1ac73c1ef978698b9a7e77897bb9cbc18dc17c SHA512 6a82933bbf51ff255d17cb61ae6ddfb791a2200e3dff705f181cd06c6031b48cf15faa5e8202a65daef0fb20b7fd9e33d40dbd0f9cc3f49af49fff04a1cb0a73
+DIST VirtualBox-7.0.16.tar.bz2 170897951 BLAKE2B 6b436c38df632222621723db94677a0efef5de2ac1eacec73571bc658955f23fff347fa60c37ec78c58bf94b82b8f9a95fb26c07ef4becc7e9f535af069151f5 SHA512 1b8ba08bec144cbd1f2e9aa0929cdf60a0b99930f1dd80567094fba75097d87661aef3da2cc24f4abff6b6db8f186e251c5f693a2a93943cc39909d5f1e1bce5
 DIST virtualbox-help-7.0.10.tar.xz 3941196 BLAKE2B fa6667e0cf12e2e05b896a7d9d7e1f78d43bb4618f35b3c81f5ccf5f227d1181b0c8fb1f6dc02a8619550b193a73d4094c5d3f0d43514392f9ed563085068789 SHA512 fab2dff812a438f3e78dbace24741d91b317bbbc7362f082a18f3871e3c6fd8af7744cf1b3fd3b82cf5135e03d521de05a7a5bc98ec19aacfa1b4e5392e60f30
 DIST virtualbox-help-7.0.12.tar.xz 3945920 BLAKE2B 7f2201f3baf6d27d95dc9f878426e34a27c9f9e113d55348f57703b1bd4878df8c6f02492412b779896c48224fb2df224c953b425dde9c99d2b4dbfda1d80d4f SHA512 ddf429a984fe433c4bcbdf87930b3cc16075d4f4725d2e571e9bf05d820d26eb6f88dd6f2bd3992927b261377c84ac4e35a929113b3294e3b2887760fe7a0b52
 DIST virtualbox-help-7.0.14.tar.xz 3944832 BLAKE2B 95079e4da8c960c41cee799142779a6c2587e0e8af7956ca551cb5a4c0f36f313189dfe08afba83a0c32886866a7f9903b5e370008d6b3ce6283fb2288866b06 SHA512 e2f1acdd7577a93047e220300b1996d2855ddef20053c01294f8295fde0840645c41b75632d71dd2fc276219084fe4105fd057623f39375542358796425a2d03
+DIST virtualbox-help-7.0.16.tar.xz 3948696 BLAKE2B 5c5937313ea0e5cb4764b8a61fd1587e88a4afc965ef00862c5a265a15253929d35e0635231b6be5656f26f600bc4b70a2fa2ebc0f33b35d35c184b57e5acef8 SHA512 b9baca57118a82e3489c8445f0988671f16f75de60cc2d929d5e3b0c4c9e3ceacd796a72a81bba88d69eb4b4559835a13775c18d7782ae7dbe8ad202e247db0c
 DIST virtualbox-patches-6.1.36.tar.bz2 2733 BLAKE2B dcfebfeca4873d382441515d48b4dfee9343bc7c83ea3cbb5002dbf7975143a79fae9a701b67dc35505e9ca03ff1b6293cb7c3279c4fdfda8ad21ba5fb9b7e87 SHA512 1bed5cdefbf8e7c4b0d9092ba4961ecf2262f27f35c71a91ef6f2e8fe8a1d92ed74f06bafbf58d70ba7165d933997f58073f4d4f4051e3ba5c0339b729066f57
 DIST virtualbox-patches-7.0.14.tar.bz2 6937 BLAKE2B da5f18efbba2a8f4701b3d29dc00784e4e80e18a18b029e5dce8c142eb4dc97637069bfc5081422064a7dc59dfacf503ebbdc3421caa96430dc53fa72988aa20 SHA512 57cc34b92e4626de5c445e34ae025da7ec0d752a60618c619a55c28bf7d6b1cc9dc81ea059b949b0f3e625568207e8084f9462faf487ca0daf2794e7f1feac36
+DIST virtualbox-patches-7.0.16.tar.bz2 6808 BLAKE2B d15fa2ca306375142c3e25d4759d2790b2bb9eb69e333a8773ad500b29dd127b401943abf59ca59d01858a3ed5551fb3a6c93c4c893c8de971a714ce5306d577 SHA512 a488cbc6660fe8637c44cd79d87156609af089988239a7e76fea8a3c7e6319512c574bef2e942b354b14ce671a8e75ab8b2160abf7c40963795ee8a545ecd992
 DIST virtualbox-patches-7.1.0_pre20240210.tar.bz2 5479 BLAKE2B 98bfc9391e756df139e0dd88ca2dd5c9f6cd9c0ce5b5e770dbe28d2e6acbfd04a26b06414c2640894bd3bbd2f10a80f6053d0c6f18d27752a05cadf773e50f19 SHA512 51b0fe68f23a73d20ec3a93b1fc8c073e0bc2bfe4e2e267de6ee6f103abc44c35bb50a96f3842a1e46049418336a3327ab291972a17b8a29b596ba9be4bdb962
 EBUILD virtualbox-6.1.48-r2.ebuild 18946 BLAKE2B aad9adbb63d7252b67c4ac441900542ab085e749c6f3159a2a4ca88b7ba22d492ca81d72dce940d3caa9db449929e377544414873a7b7029456f0ba63b085a25 SHA512 a62a6b18a51143b925ef3d8940283746ba2ddff975bec0e1335da7bc5f5bcd9b0bc4a4f30880faa3e590c0c7064fe758620f730726899d81e0a97c6c953e822e
 EBUILD virtualbox-6.1.50-r2.ebuild 18982 BLAKE2B 0290f1ebcb0f31f211b92c7e7d64a9187886ce214d7a710df4676060789ae4d9d408cd25d50c97698ad67aad4384682ae87d6b6f4076f39e4722145245ed7314 SHA512 63e87fec69f8d1ec84bfa4ddb364ea029f7950d684ddbe6d58552c0582ae5dc782c08b58126f68a96219737ef72410196434a888781d6f367209c88302f67424
 EBUILD virtualbox-7.0.12-r2.ebuild 20777 BLAKE2B bb294e6143551fdd1553609e4f47c2e7451cc5907b8b5d180f0b0263097a1d21b63b1822b7e7579e4661b1d1831dcf0a8cced0cc906655a4cd76d1bdae6117f4 SHA512 888b6736c82b57bd364c4671f6cddea033c92798f7ba5cd1edd934b3c0edbf63dfbafddb61044cea2c9e5f4347eb2910a4c3a16ec7357b8c4f59fb6c6056dd26
 EBUILD virtualbox-7.0.14-r2.ebuild 20785 BLAKE2B 2b67f9feb5aeca76ee368fed058e70199c0eaa81c61dd1d6f45f7792535555369a6cca5b48036b2a471b8b2ae61daa4e25f98cb37eb2b74aa09d5e228d2e91a7 SHA512 753839ffe74dfc62a0cbd43cd93b6afbb3614cf64dc768ff22c0f42096225364e60099adb2b996f8cdd36b051a1f8b24d16f15760106a7f9a51d69ee4dd83f5b
+EBUILD virtualbox-7.0.16.ebuild 20785 BLAKE2B f7894541ca64dab97dfb0c254dc88efbc4b1e0ae016b30ef53bcc9b43e45da35e027e1c929938d11d8d50873cee291fa826e7d204367e05c323f8e52ae6b61f9 SHA512 dbff90c4946662cf3daebe7769c8c33444368fe88a7f09fb992ec931ad5164ff412327fb5cbd396c43b5db6142a214e27c08520493d9afa2588e20ba2852754d
 EBUILD virtualbox-9999.ebuild 21624 BLAKE2B a3590b3abfa2f318ced4bbe4fe35c224a09229d199f215fa60e72a9de80bc561ec479f80ae3de3923d0adaf6160cbc825b7cc3d8f167cc46ceeb50bec8559634 SHA512 917b865d73c3c41c7c2b91140e0fcd7771dcf35dff54643ad10587012ea87ecef125b0f0e76cebcb519134fab9e248370bf86a027fc3b315e18747a92c2ec8c8
 MISC metadata.xml 870 BLAKE2B 26f9370557a12c17465e7ca2d63902a2ce5b2d65fbdf40f3b890bd89aca28a1816424caf579f71b762876e8e91b292c5ecbcbad985e9da1e1472e66a2eaf6965 SHA512 eb2e9114dc343062e9afd3b933a5d355be790febb4a18f741347072d305b7d63ed40a6a3b9d11b91eb8602d5d2d4f5cf6c2ebde278fb0d0df48a5c5647374e33
diff --git a/app-emulation/virtualbox/virtualbox-7.0.16.ebuild b/app-emulation/virtualbox/virtualbox-7.0.16.ebuild
new file mode 100644
index 000000000000..eb51ad77cc44
--- /dev/null
+++ b/app-emulation/virtualbox/virtualbox-7.0.16.ebuild
@@ -0,0 +1,740 @@
+# Copyright 2022-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+# To add a new Python here:
+# 1. Patch src/libs/xpcom18a4/python/Makefile.kmk (copy the previous impl's logic)
+#    Do NOT skip this part. It'll end up silently not-building the Python extension
+#    or otherwise misbehaving if you do.
+#
+# 2. Then update PYTHON_COMPAT & set PYTHON_SINGLE_TARGET for testing w/ USE=python.
+#
+#  May need to look at other distros (e.g. Arch Linux) to find patches for newer
+#  Python versions as upstream tends to lag. Upstream may have patches on their
+#  trunk branch but not release branch.
+#
+#  See bug #785835, bug #856121.
+PYTHON_COMPAT=( python3_{10..11} )
+
+inherit desktop edo flag-o-matic java-pkg-opt-2 linux-info multilib optfeature pax-utils \
+	python-single-r1 tmpfiles toolchain-funcs udev xdg
+
+MY_PN="VirtualBox"
+MY_P=${MY_PN}-${PV}
+
+DESCRIPTION="Family of powerful x86 virtualization products for enterprise and home use"
+HOMEPAGE="https://www.virtualbox.org/"
+SRC_URI="
+	https://download.virtualbox.org/virtualbox/${PV}/${MY_P}.tar.bz2
+	https://gitweb.gentoo.org/proj/virtualbox-patches.git/snapshot/virtualbox-patches-7.0.16.tar.bz2
+	gui? ( !doc? ( https://dev.gentoo.org/~ceamac/${CATEGORY}/${PN}/${PN}-help-${PV}.tar.xz ) )
+"
+S="${WORKDIR}/${MY_PN}-${PV}"
+
+LICENSE="GPL-2+ GPL-3 LGPL-2.1 MIT dtrace? ( CDDL )"
+SLOT="0/$(ver_cut 1-2)"
+KEYWORDS="~amd64"
+IUSE="alsa dbus debug doc dtrace +gui java lvm nls pam pch pulseaudio +opengl python +sdk +sdl +udev vboxwebsrv vde vnc"
+
+unset WATCOM #856769
+
+COMMON_DEPEND="
+	${PYTHON_DEPS}
+	acct-group/vboxusers
+	~app-emulation/virtualbox-modules-${PV}
+	dev-libs/libtpms
+	dev-libs/libxml2
+	dev-libs/openssl:0=
+	media-libs/libpng:0=
+	media-libs/libvpx:0=
+	net-misc/curl
+	sys-libs/zlib
+	dbus? ( sys-apps/dbus )
+	gui? (
+		dev-qt/qtcore:5
+		dev-qt/qtdbus:5
+		dev-qt/qtgui:5
+		dev-qt/qthelp:5
+		dev-qt/qtprintsupport:5
+		dev-qt/qtwidgets:5
+		dev-qt/qtx11extras:5
+		dev-qt/qtxml:5
+		x11-libs/libX11
+		x11-libs/libXt
+		opengl? ( dev-qt/qtopengl:5 )
+	)
+	lvm? ( sys-fs/lvm2 )
+	opengl? (
+		media-libs/libglvnd[X]
+		media-libs/vulkan-loader
+		x11-libs/libX11
+		x11-libs/libXt
+	)
+	pam? ( sys-libs/pam )
+	sdl? (
+		media-libs/libsdl2[X,video]
+		x11-libs/libX11
+		x11-libs/libXcursor
+		x11-libs/libXt
+	)
+	vboxwebsrv? ( net-libs/gsoap[-gnutls(-),debug?] )
+	vde? ( net-misc/vde )
+	vnc? ( >=net-libs/libvncserver-0.9.9 )
+"
+# We're stuck on JDK (and JRE, I guess?) 1.8 because of need for wsimport
+# with USE="vboxwebsrv java". Note that we have to put things in DEPEND,
+# not (only, anyway) BDEPEND, as the eclass magic to set the environment variables
+# based on *DEPEND doesn't work for BDEPEND at least right now.
+#
+# There's a comment in Config.kmk about it
+# ("With Java 11 wsimport was removed, usually part of a separate install now.")
+# but it needs more investigation.
+#
+# See bug #878299 to track this issue.
+DEPEND="
+	${COMMON_DEPEND}
+	>=dev-libs/libxslt-1.1.19
+	virtual/libcrypt:=
+	alsa? ( >=media-libs/alsa-lib-1.0.13 )
+	gui? (
+		x11-base/xorg-proto
+		x11-libs/libxcb:=
+		x11-libs/libXcursor
+		x11-libs/libXext
+		x11-libs/libXinerama
+		x11-libs/libXmu
+		x11-libs/libXrandr
+	)
+	java? ( virtual/jdk:1.8 )
+	opengl? (
+		x11-base/xorg-proto
+		x11-libs/libXcursor
+		x11-libs/libXinerama
+		x11-libs/libXmu
+		x11-libs/libXrandr
+		virtual/glu
+	)
+	sdl? ( x11-libs/libXinerama )
+	pulseaudio? ( media-libs/libpulse )
+	udev? ( >=virtual/udev-171 )
+"
+RDEPEND="
+	${COMMON_DEPEND}
+	gui? ( x11-libs/libxcb:= )
+	java? ( virtual/jre:1.8 )
+"
+BDEPEND="
+	${PYTHON_DEPS}
+	>=app-arch/tar-1.34-r2
+	>=dev-lang/yasm-0.6.2
+	dev-libs/libIDL
+	dev-util/glslang
+	>=dev-build/kbuild-0.1.9998.3592
+	sys-apps/which
+	sys-devel/bin86
+	sys-libs/libcap
+	sys-power/iasl
+	virtual/pkgconfig
+	doc? (
+		app-text/docbook-sgml-dtd:4.4
+		app-text/docbook-xsl-ns-stylesheets
+		dev-texlive/texlive-basic
+		dev-texlive/texlive-latex
+		dev-texlive/texlive-latexrecommended
+		dev-texlive/texlive-latexextra
+		dev-texlive/texlive-fontsrecommended
+		dev-texlive/texlive-fontsextra
+		dev-qt/qthelp:5
+	)
+	gui? ( dev-qt/linguist-tools:5 )
+	nls? ( dev-qt/linguist-tools:5 )
+	java? ( virtual/jdk:1.8 )
+"
+
+QA_FLAGS_IGNORED="
+	usr/lib64/virtualbox/VBoxDDR0.r0
+	usr/lib64/virtualbox/VMMR0.r0
+	usr/lib64/virtualbox/ExtensionPacks/Oracle_VBoxDTrace_Extension_Pack/linux.amd64/VBoxDTraceR0.r0
+	usr/lib64/virtualbox/ExtensionPacks/Oracle_VBoxDTrace_Extension_Pack/linux.amd64/VBoxDTraceR0.debug
+"
+
+QA_TEXTRELS="
+	usr/lib64/virtualbox/VMMR0.r0
+	usr/lib64/virtualbox/ExtensionPacks/Oracle_VBoxDTrace_Extension_Pack/linux.amd64/VBoxDTraceR0.r0
+"
+
+QA_EXECSTACK="
+	usr/lib64/virtualbox/iPxeBaseBin
+	usr/lib64/virtualbox/VMMR0.r0
+	usr/lib64/virtualbox/VBoxDDR0.r0
+	usr/lib64/virtualbox/ExtensionPacks/Oracle_VBoxDTrace_Extension_Pack/linux.amd64/VBoxDTraceR0.r0
+	usr/lib64/virtualbox/ExtensionPacks/Oracle_VBoxDTrace_Extension_Pack/linux.amd64/VBoxDTraceR0.debug
+"
+
+QA_WX_LOAD="
+	usr/lib64/virtualbox/iPxeBaseBin
+"
+
+QA_PRESTRIPPED="
+	usr/lib64/virtualbox/VMMR0.r0
+	usr/lib64/virtualbox/VBoxDDR0.r0
+	usr/lib64/virtualbox/ExtensionPacks/Oracle_VBoxDTrace_Extension_Pack/linux.amd64/VBoxDTraceR0.r0
+"
+
+REQUIRED_USE="
+	java? ( sdk )
+	python? ( sdk )
+	vboxwebsrv? ( java )
+	${PYTHON_REQUIRED_USE}
+"
+
+PATCHES=(
+	# Downloaded patchset
+	"${WORKDIR}"/virtualbox-patches-7.0.16/patches
+)
+
+pkg_pretend() {
+	if ! use gui; then
+		einfo "No USE=\"gui\" selected, this build will not include any Qt frontend."
+	fi
+
+	if ! use opengl; then
+		einfo "No USE=\"opengl\" selected, this build will lack"
+		einfo "the OpenGL feature."
+	fi
+	if ! use python; then
+		einfo "You have disabled the \"python\" USE flag. This will only"
+		einfo "disable the python bindings being installed."
+	fi
+	if ! use nls && use gui; then
+		einfo "USE=\"gui\" also selects USE=\"nls\".  This build"
+		einfo "will have NLS support."
+	fi
+
+	# 749273
+	local d=${ROOT}
+	for i in usr "$(get_libdir)"; do
+		d="${d}/$i"
+		if [[ "$(stat -L -c "%g %u" "${d}")" != "0 0" ]]; then
+			die "${d} should be owned by root, VirtualBox will not start otherwise"
+		fi
+	done
+}
+
+pkg_setup() {
+	java-pkg-opt-2_pkg_setup
+	python-single-r1_pkg_setup
+}
+
+src_prepare() {
+	default
+
+	# Only add nopie patch when we're on hardened
+	if gcc-specs-pie; then
+		eapply "${FILESDIR}"/050_virtualbox-5.2.8-nopie.patch
+	fi
+
+	# Remove shipped binaries (kBuild, yasm) and tools, see bug #232775
+	rm -r kBuild/bin || die
+	# Remove everything in tools except kBuildUnits
+	find tools -mindepth 1 -maxdepth 1 -name kBuildUnits -prune -o -exec rm -r {} \+ || die
+
+	# Disable things unused or split into separate ebuilds
+	sed -e "s@MY_LIBDIR@$(get_libdir)@" \
+		"${FILESDIR}"/${PN}-5-localconfig > LocalConfig.kmk || die
+
+	if ! use pch; then
+		# bug #753323
+		printf '\n%s\n' "VBOX_WITHOUT_PRECOMPILED_HEADERS=1" \
+			>> LocalConfig.kmk || die
+	fi
+
+	# bug #916002, #488176
+	tc-ld-force-bfd
+
+	# Respect LDFLAGS
+	sed -e "s@_LDFLAGS\.${ARCH}*.*=@& ${LDFLAGS}@g" \
+		-i Config.kmk src/libs/xpcom18a4/Config.kmk || die
+
+	# Do not use hard-coded ld (related to bug #488176)
+	sed -e '/QUIET)ld /s@ld @$(LD) @' \
+		-i src/VBox/Devices/PC/ipxe/Makefile.kmk || die
+
+	# Use PAM only when pam USE flag is enbaled (bug #376531)
+	if ! use pam; then
+		einfo "Disabling PAM removes the possibility to use the VRDP features."
+		sed -i 's@^.*VBOX_WITH_PAM@#VBOX_WITH_PAM@' Config.kmk || die
+		sed -i 's@\(.*/auth/Makefile.kmk.*\)@#\1@' \
+			src/VBox/HostServices/Makefile.kmk || die
+		echo -e "\nIPRT_WITHOUT_PAM=1" >> LocalConfig.kmk || die
+	fi
+
+	# add correct java path
+	if use java; then
+		sed "s@/usr/lib/jvm/java-6-sun@$(java-config -O)@" \
+			-i "${S}"/Config.kmk || die
+		java-pkg-opt-2_src_prepare
+	fi
+
+	#856811 #864274
+	# cannot filter out only one flag, some combinations of these flags produce buggy executables
+	for i in abm avx avx2 bmi bmi2 fma fma4 popcnt; do
+		append-cflags $(test-flags-CC -mno-$i)
+		append-cxxflags $(test-flags-CXX -mno-$i)
+	done
+
+	# bug #908814
+	filter-lto
+
+	# bug #843437
+	cat >> LocalConfig.kmk <<-EOF || die
+		CXXFLAGS=${CXXFLAGS}
+		CFLAGS=${CFLAGS}
+	EOF
+
+	if use sdl; then
+		sed -i 's/sdl-config/sdl2-config/' configure || die
+		echo -e "\nVBOX_WITH_VBOXSDL=1" >> LocalConfig.kmk || die
+	fi
+
+	#443830
+	echo -e "\nVBOX_WITH_VBOX_IMG=1" >> LocalConfig.kmk || die
+
+	if tc-is-clang; then
+		# clang assembler chokes on comments starting with /
+		sed -i -e '/^\//d' src/libs/xpcom18a4/nsprpub/pr/src/md/unix/os_Linux_x86_64.s || die
+
+		# clang does not support this extension
+		eapply "${FILESDIR}"/${PN}-7.0.8-disable-rebuild-iPxeBiosBin.patch
+	fi
+
+	# fix doc generation
+	echo -e "\nVBOX_PATH_DOCBOOK=/usr/share/sgml/docbook/xsl-ns-stylesheets" >> LocalConfig.kmk || die
+	# replace xhtml names with numeric equivalents
+	find doc/manual -name \*.xml -exec sed -i \
+		-e 's/&nbsp;/\&#160;/g' \
+		-e 's/&ndash;/\&#8211;/g' \
+		-e 's/&larr;/\&#8592;/g' \
+		-e 's/&rarr;/\&#8594;/g' \
+		-e 's/&harr;/\&#8596;/g' {} \+ || die
+
+	# fix help path #891879
+	echo -e "\nVBOX_PATH_PACKAGE_DOCS=/usr/share/doc/${PF}" >> LocalConfig.kmk || die
+
+	# 489208
+	# Cannot patch the whole text, many translations.  Use sed instead to replace the command
+	find src/VBox/Frontends/VirtualBox/nls -name \*.ts -exec sed -i \
+		's/&apos;[^&]*\(vboxdrv setup\|vboxconfig\)&apos;/\&apos;emerge -1 virtualbox-modules\&apos;/' {} \+ || die
+	sed -i "s:'/sbin/vboxconfig':'emerge -1 virtualbox-modules':" \
+		src/VBox/Frontends/VirtualBox/src/main.cpp \
+		src/VBox/VMM/VMMR3/VM.cpp || die
+
+	# 890561
+	echo -e "\nVBOX_GTAR=gtar" >> LocalConfig.kmk || die
+
+	if ! use nls && ! use gui; then
+		cat >> LocalConfig.kmk <<-EOF || die
+			VBOX_WITH_NLS :=
+			VBOX_WITH_MAIN_NLS :=
+			VBOX_WITH_PUEL_NLS :=
+			VBOX_WITH_VBOXMANAGE_NLS :=
+		EOF
+	fi
+}
+
+src_configure() {
+	tc-export AR CC CXX LD RANLIB
+	export HOST_CC="$(tc-getBUILD_CC)"
+
+	local myconf=(
+		--with-gcc="$(tc-getCC)"
+		--with-g++="$(tc-getCXX)"
+
+		--disable-kmods
+
+		$(usev !alsa --disable-alsa)
+		$(usev !dbus --disable-dbus)
+		$(usev debug --build-debug)
+		$(usev !doc --disable-docs)
+		$(usev !java --disable-java)
+		$(usev !lvm --disable-devmapper)
+		$(usev !pulseaudio --disable-pulse)
+		$(usev !python --disable-python)
+		$(usev vboxwebsrv --enable-webservice)
+		$(usev vde --enable-vde)
+		$(usev vnc --enable-vnc)
+	)
+
+	if use gui || use sdl || use opengl; then
+		myconf+=(
+			$(usev !opengl --disable-opengl)
+			$(usev !gui --disable-qt)
+			$(usev !sdl --disable-sdl)
+		)
+	else
+		myconf+=(
+			--build-headless
+		)
+	fi
+
+	if use amd64 && ! has_multilib_profile; then
+		myconf+=( --disable-vmmraw )
+	fi
+
+	# not an autoconf script
+	edo ./configure "${myconf[@]}"
+
+	# Force usage of chosen Python implementation
+	# bug #856121, bug #785835
+	sed -i \
+		-e '/VBOX_WITH_PYTHON.*=/d' \
+		-e '/VBOX_PATH_PYTHON_INC.*=/d' \
+		-e '/VBOX_LIB_PYTHON.*=/d' \
+		AutoConfig.kmk || die
+
+	cat >> AutoConfig.kmk <<-EOF || die
+		VBOX_WITH_PYTHON=$(usev python 1)
+		VBOX_PATH_PYTHON_INC=$(python_get_includedir)
+		VBOX_LIB_PYTHON=$(python_get_library_path)
+	EOF
+
+	if use python; then
+		local mangled_python="${EPYTHON#python}"
+		mangled_python="${mangled_python/.}"
+
+		# Stub out the script which defines what the Makefile ends up
+		# building for. gen_python_deps.py gets called by the Makefile
+		# with some args and it spits out a bunch of paths for a hardcoded
+		# list of Pythons. We just override it with what we're actually using.
+		# This minimises the amount of patching we have to do for new Pythons.
+		cat > src/libs/xpcom18a4/python/gen_python_deps.py <<-EOF || die
+			print("VBOX_PYTHON${mangled_python}_INC=$(python_get_includedir)")
+			print("VBOX_PYTHON${mangled_python}_LIB=$(python_get_library_path)")
+			print("VBOX_PYTHONDEF_INC=$(python_get_includedir)")
+			print("VBOX_PYTHONDEF_LIB=$(python_get_library_path)")
+		EOF
+
+		chmod +x src/libs/xpcom18a4/python/gen_python_deps.py || die
+	fi
+}
+
+src_compile() {
+	source ./env.sh || die
+
+	# Force kBuild to respect C[XX]FLAGS and MAKEOPTS (bug #178529)
+	MAKEJOBS=$(grep -Eo '(\-j|\-\-jobs)(=?|[[:space:]]*)[[:digit:]]+' <<< ${MAKEOPTS})
+	MAKELOAD=$(grep -Eo '(\-l|\-\-load-average)(=?|[[:space:]]*)[[:digit:]]+' <<< ${MAKEOPTS})
+	MAKEOPTS="${MAKEJOBS} ${MAKELOAD}"
+
+	local myemakeargs=(
+		VBOX_BUILD_PUBLISHER=_Gentoo
+		VBOX_WITH_VBOXIMGMOUNT=1
+
+		KBUILD_VERBOSE=2
+
+		AS="$(tc-getCC)"
+		CC="$(tc-getCC)"
+		CXX="$(tc-getCXX)"
+
+		TOOL_GCC3_CC="$(tc-getCC)"
+		TOOL_GCC3_LD="$(tc-getCC)"
+		TOOL_GCC3_AS="$(tc-getCC)"
+		TOOL_GCC3_AR="$(tc-getAR)"
+		TOOL_GCC3_OBJCOPY="$(tc-getOBJCOPY)"
+
+		TOOL_GXX3_CC="$(tc-getCC)"
+		TOOL_GXX3_CXX="$(tc-getCXX)"
+		TOOL_GXX3_LD="$(tc-getCXX)"
+		TOOL_GXX3_AS="$(tc-getCXX)"
+		TOOL_GXX3_AR="$(tc-getAR)"
+		TOOL_GXX3_OBJCOPY="$(tc-getOBJCOPY)"
+
+		TOOL_GCC3_CFLAGS="${CFLAGS}"
+		TOOL_GCC3_CXXFLAGS="${CXXFLAGS}"
+		VBOX_GCC_OPT="${CXXFLAGS}"
+		VBOX_NM="$(tc-getNM)"
+
+		TOOL_YASM_AS=yasm
+	)
+
+	if use amd64 && has_multilib_profile; then
+		myemakeargs+=(
+			CC32="$(tc-getCC) -m32"
+			CXX32="$(tc-getCXX) -m32"
+
+			TOOL_GCC32_CC="$(tc-getCC) -m32"
+			TOOL_GCC32_CXX="$(tc-getCXX) -m32"
+			TOOL_GCC32_LD="$(tc-getCC) -m32"
+			TOOL_GCC32_AS="$(tc-getCC) -m32"
+			TOOL_GCC32_AR="$(tc-getAR)"
+			TOOL_GCC32_OBJCOPY="$(tc-getOBJCOPY)"
+
+			TOOL_GXX32_CC="$(tc-getCC) -m32"
+			TOOL_GXX32_CXX="$(tc-getCXX) -m32"
+			TOOL_GXX32_LD="$(tc-getCXX) -m32"
+			TOOL_GXX32_AS="$(tc-getCXX) -m32"
+			TOOL_GXX32_AR="$(tc-getAR)"
+			TOOL_GXX32_OBJCOPY="$(tc-getOBJCOPY)"
+		)
+	fi
+
+	MAKE="kmk" emake "${myemakeargs[@]}" all
+}
+
+src_install() {
+	cd "${S}"/out/linux.${ARCH}/$(usex debug debug release)/bin || die
+
+	local vbox_inst_path="/usr/$(get_libdir)/${PN}" each size ico icofile
+
+	vbox_inst() {
+		local binary="${1}"
+		local perms="${2:-0750}"
+		local path="${3:-${vbox_inst_path}}"
+
+		[[ -n "${binary}" ]] || die "vbox_inst: No binary given!"
+		[[ ${perms} =~ ^[[:digit:]]+{4}$ ]] || die "vbox_inst: perms must consist of four digits."
+
+		insinto ${path}
+		doins ${binary}
+		fowners root:vboxusers ${path}/${binary}
+		fperms ${perms} ${path}/${binary}
+	}
+
+	# Create configuration files
+	insinto /etc/vbox
+	newins "${FILESDIR}/${PN}-4-config" vbox.cfg
+
+	# Set the correct libdir
+	sed \
+		-e "s@MY_LIBDIR@$(get_libdir)@" \
+		-i "${ED}"/etc/vbox/vbox.cfg || die "vbox.cfg sed failed"
+
+	# Install the wrapper script
+	exeinto ${vbox_inst_path}
+	newexe "${FILESDIR}/${PN}-ose-6-wrapper" "VBox"
+	fowners root:vboxusers ${vbox_inst_path}/VBox
+	fperms 0750 ${vbox_inst_path}/VBox
+
+	# Install binaries and libraries
+	insinto ${vbox_inst_path}
+	doins -r components
+
+	for each in VBox{Autostart,BalloonCtrl,BugReport,CpuReport,ExtPackHelperApp,Manage,SVC,VMMPreload,XPCOMIPCD} \
+		vboximg-mount vbox-img *so *r0; do
+		vbox_inst ${each}
+	done
+
+	# These binaries need to be suid root.
+	for each in VBox{Headless,Net{AdpCtl,DHCP,NAT}} ; do
+		vbox_inst ${each} 4750
+	done
+
+	# Install EFI Firmware files (bug #320757)
+	for each in VBoxEFI{32,64}.fd ; do
+		vbox_inst ${each} 0644
+	done
+
+	# VBoxSVC and VBoxManage need to be pax-marked (bug #403453)
+	# VBoxXPCOMIPCD (bug #524202)
+	for each in VBox{Headless,Manage,SVC,XPCOMIPCD} ; do
+		pax-mark -m "${ED}"${vbox_inst_path}/${each}
+	done
+
+	# Symlink binaries to the shipped wrapper
+	for each in vbox{autostart,balloonctrl,bugreport,headless,manage} \
+		VBox{Autostart,BalloonCtrl,BugReport,Headless,Manage,VRDP} ; do
+			dosym ${vbox_inst_path}/VBox /usr/bin/${each}
+	done
+	dosym ${vbox_inst_path}/vboximg-mount /usr/bin/vboximg-mount
+	dosym ${vbox_inst_path}/vbox-img /usr/bin/vbox-img
+
+	if use pam; then
+		# VRDPAuth only works with this (bug #351949)
+		dosym VBoxAuth.so ${vbox_inst_path}/VRDPAuth.so
+	fi
+
+	# set an env-variable for 3rd party tools
+	echo "VBOX_APP_HOME=${vbox_inst_path}" > "${T}/90virtualbox"
+	# environment variables used during SDK binding installation
+	echo "VBOX_SDK_PATH=${vbox_inst_path}/sdk" >> "${T}/90virtualbox"
+	echo "VBOX_INSTALL_PATH=${vbox_inst_path}" >> "${T}/90virtualbox"
+	doenvd "${T}/90virtualbox"
+
+	if use sdl; then
+		vbox_inst VBoxSDL 4750
+		pax-mark -m "${ED}"${vbox_inst_path}/VBoxSDL
+
+		for each in vboxsdl VBoxSDL ; do
+			dosym ${vbox_inst_path}/VBox /usr/bin/${each}
+		done
+	fi
+
+	if use gui; then
+		vbox_inst VirtualBox
+		vbox_inst VirtualBoxVM 4750
+		for each in VirtualBox{,VM} ; do
+			pax-mark -m "${ED}"${vbox_inst_path}/${each}
+		done
+
+		if use opengl; then
+			vbox_inst VBoxTestOGL
+			pax-mark -m "${ED}"${vbox_inst_path}/VBoxTestOGL
+		fi
+
+		for each in virtualbox{,vm} VirtualBox{,VM} ; do
+			dosym ${vbox_inst_path}/VBox /usr/bin/${each}
+		done
+
+		insinto /usr/share/${PN}
+		doins -r nls
+		doins -r UnattendedTemplates
+
+		domenu ${PN}.desktop
+
+		pushd "${S}"/src/VBox/Artwork/OSE &>/dev/null || die
+		for size in 16 32 48 64 128 ; do
+			newicon -s ${size} ${PN}-${size}px.png ${PN}.png
+		done
+		newicon ${PN}-48px.png ${PN}.png
+		doicon -s scalable ${PN}.svg
+		popd &>/dev/null || die
+		pushd "${S}"/src/VBox/Artwork/other &>/dev/null || die
+		for size in 16 24 32 48 64 72 96 128 256 512 ; do
+			for ico in hdd ova ovf vbox{,-extpack} vdi vdh vmdk ; do
+				icofile="${PN}-${ico}-${size}px.png"
+				if [[ -f "${icofile}" ]]; then
+					newicon -s ${size} ${icofile} ${PN}-${ico}.png
+				fi
+			done
+		done
+		popd &>/dev/null || die
+	fi
+
+	if use lvm; then
+		vbox_inst VBoxVolInfo 4750
+		dosym ${vbox_inst_path}/VBoxVolInfo /usr/bin/VBoxVolInfo
+	fi
+
+	if use sdk; then
+		insinto ${vbox_inst_path}
+		doins -r sdk
+
+		if use java; then
+			java-pkg_regjar "${ED}/${vbox_inst_path}/sdk/bindings/xpcom/java/vboxjxpcom.jar"
+			java-pkg_regso "${ED}/${vbox_inst_path}/libvboxjxpcom.so"
+		fi
+	fi
+
+	if use udev; then
+		local udevdir="$(get_udevdir)"
+		local udev_file="VBoxCreateUSBNode.sh"
+		local rules_file="10-virtualbox.rules"
+
+		insinto ${udevdir}
+		doins ${udev_file}
+		fowners root:vboxusers ${udevdir}/${udev_file}
+		fperms 0750 ${udevdir}/${udev_file}
+
+		insinto ${udevdir}/rules.d
+		sed "s@%UDEVDIR%@${udevdir}@" "${FILESDIR}"/${rules_file} \
+			> "${T}"/${rules_file} || die
+		doins "${T}"/${rules_file}
+	fi
+
+	if use vboxwebsrv; then
+		vbox_inst vboxwebsrv
+		dosym ${vbox_inst_path}/VBox /usr/bin/vboxwebsrv
+		newinitd "${FILESDIR}"/vboxwebsrv-initd vboxwebsrv
+		newconfd "${FILESDIR}"/vboxwebsrv-confd vboxwebsrv
+	fi
+
+	# Remove dead symlinks (bug #715338)
+	find "${ED}"/usr/$(get_libdir)/${PN} -xtype l -delete || die
+
+	# Fix version string in extensions or else they don't get accepted
+	# by the virtualbox host process (see bug #438930)
+	find ExtensionPacks -type f -name "ExtPack.xml" -exec sed -i '/Version/s@_Gentoo@@' {} \+ || die
+
+	local extensions_dir="${vbox_inst_path}/ExtensionPacks"
+
+	if use vnc; then
+		insinto ${extensions_dir}
+		doins -r ExtensionPacks/VNC
+	fi
+
+	if use dtrace; then
+		insinto ${extensions_dir}
+		doins -r ExtensionPacks/Oracle_VBoxDTrace_Extension_Pack
+	fi
+
+	if use doc; then
+		dodoc UserManual.pdf UserManual.q{ch,hc}
+		docompress -x /usr/share/doc/${PF}
+	elif use gui; then
+		dodoc "${WORKDIR}"/${PN}-help-${PV}/UserManual.q{ch,hc}
+		docompress -x /usr/share/doc/${PF}
+	fi
+
+	if use python; then
+		local python_path_ext="${ED}/usr/$(get_libdir)/virtualbox/VBoxPython3.so"
+		if [[ ! -x "${python_path_ext}" ]]; then
+			eerror "Couldn't find ${python_path_ext}! Bindings were requested with USE=python"
+			eerror "but none were installed. This may happen if support for a Python target"
+			eerror "(listed in PYTHON_COMPAT in the ebuild) is incomplete within the Makefiles."
+			die "Incomplete installation of Python bindings! File a bug with Gentoo!"
+		fi
+
+		# 378871
+		local installer_dir="${ED}/usr/$(get_libdir)/virtualbox/sdk/installer"
+		pushd "${installer_dir}" &> /dev/null || die
+		sed -e "s;%VBOX_INSTALL_PATH%;${vbox_inst_path};" \
+			-e "s;%VBOX_SDK_PATH%;${vbox_inst_path}/sdk;" \
+			-i vboxapi/__init__.py || die
+		# insert shebang, the files come without one
+		find vboxapi -name \*.py -exec sed -e "1 i\#! ${PYTHON}" -i {} \+ || die
+		python_domodule vboxapi
+		popd &> /dev/null || die
+		python_doscript vboxshell.py
+
+		# do not install the installer
+		rm -r "${installer_dir}" || die
+	fi
+
+	newtmpfiles "${FILESDIR}"/${PN}-vboxusb_tmpfilesd ${PN}-vboxusb.conf
+}
+
+pkg_postinst() {
+	xdg_pkg_postinst
+
+	if use udev; then
+		udev_reload
+		udevadm trigger --subsystem-match=usb
+	fi
+
+	tmpfiles_process virtualbox-vboxusb.conf
+
+	if use gui; then
+		elog "To launch VirtualBox just type: \"virtualbox\"."
+	fi
+
+	elog "You must be in the vboxusers group to use VirtualBox."
+	elog ""
+	elog "The latest user manual is available for download at:"
+	elog "https://download.virtualbox.org/virtualbox/${PV}/UserManual.pdf"
+	elog ""
+
+	optfeature "Advanced networking setups" net-misc/bridge-utils sys-apps/usermode-utilities
+	optfeature "USB2, USB3, PXE boot, and VRDP support" app-emulation/virtualbox-extpack-oracle
+	optfeature "Guest additions ISO" app-emulation/virtualbox-additions
+
+	if ! use udev; then
+		ewarn "Without USE=udev, USB devices will likely not work in ${PN}."
+	fi
+}
+
+pkg_postrm() {
+	xdg_pkg_postrm
+
+	use udev && udev_reload
+}
-- 
cgit v1.2.3