virtualbox-5.1.16.ebuild 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. PYTHON_COMPAT=( python2_7 )
  5. inherit eutils fdo-mime flag-o-matic java-pkg-opt-2 linux-info multilib pax-utils python-single-r1 toolchain-funcs udev
  6. MY_PV="${PV/beta/BETA}"
  7. MY_PV="${MY_PV/rc/RC}"
  8. MY_P=VirtualBox-${MY_PV}
  9. SRC_URI="http://download.virtualbox.org/virtualbox/${MY_PV}/${MY_P}.tar.bz2
  10. https://dev.gentoo.org/~polynomial-c/${PN}/patchsets/${PN}-5.1.6-patches-01.tar.xz"
  11. S="${WORKDIR}/${MY_P}"
  12. DESCRIPTION="Family of powerful x86 virtualization products for enterprise and home use"
  13. HOMEPAGE="http://www.virtualbox.org/"
  14. LICENSE="GPL-2"
  15. SLOT="0"
  16. KEYWORDS="~amd64 ~x86"
  17. IUSE="alsa debug doc headless java libressl lvm pam pax_kernel pulseaudio +opengl python +qt5 +sdk +udev vboxwebsrv vnc"
  18. RDEPEND="!app-emulation/virtualbox-bin
  19. ~app-emulation/virtualbox-modules-${PV}
  20. dev-libs/libIDL
  21. >=dev-libs/libxslt-1.1.19
  22. net-misc/curl
  23. dev-libs/libxml2
  24. media-libs/libpng:0=
  25. media-libs/libvpx:0=
  26. sys-libs/zlib
  27. !headless? (
  28. media-libs/libsdl:0[X,video]
  29. x11-libs/libX11
  30. x11-libs/libXcursor
  31. x11-libs/libXext
  32. x11-libs/libXmu
  33. x11-libs/libXt
  34. opengl? ( virtual/opengl media-libs/freeglut )
  35. qt5? (
  36. dev-qt/qtcore:5
  37. dev-qt/qtgui:5
  38. dev-qt/qtprintsupport:5
  39. dev-qt/qtwidgets:5
  40. dev-qt/qtx11extras:5
  41. opengl? ( dev-qt/qtopengl:5 )
  42. x11-libs/libXinerama
  43. )
  44. )
  45. java? ( >=virtual/jre-1.6:= )
  46. libressl? ( dev-libs/libressl:= )
  47. !libressl? ( dev-libs/openssl:0= )
  48. lvm? ( sys-fs/lvm2 )
  49. udev? ( >=virtual/udev-171 )
  50. vnc? ( >=net-libs/libvncserver-0.9.9 )"
  51. DEPEND="${RDEPEND}
  52. >=dev-util/kbuild-0.1.9998_pre20131130-r1
  53. >=dev-lang/yasm-0.6.2
  54. sys-devel/bin86
  55. sys-libs/libcap
  56. sys-power/iasl
  57. virtual/pkgconfig
  58. alsa? ( >=media-libs/alsa-lib-1.0.13 )
  59. doc? (
  60. app-text/docbook-sgml-dtd:4.4
  61. dev-texlive/texlive-basic
  62. dev-texlive/texlive-latex
  63. dev-texlive/texlive-latexrecommended
  64. dev-texlive/texlive-latexextra
  65. dev-texlive/texlive-fontsrecommended
  66. dev-texlive/texlive-fontsextra
  67. )
  68. !headless? ( x11-libs/libXinerama )
  69. java? ( >=virtual/jre-1.6:= )
  70. pam? ( sys-libs/pam )
  71. pax_kernel? ( sys-apps/elfix )
  72. pulseaudio? ( media-sound/pulseaudio )
  73. qt5? ( dev-qt/linguist-tools:5 )
  74. vboxwebsrv? ( net-libs/gsoap[-gnutls(-)] )
  75. ${PYTHON_DEPS}"
  76. QA_TEXTRELS_x86="usr/lib/virtualbox-ose/VBoxGuestPropSvc.so
  77. usr/lib/virtualbox/VBoxSDL.so
  78. usr/lib/virtualbox/VBoxSharedFolders.so
  79. usr/lib/virtualbox/VBoxDD2.so
  80. usr/lib/virtualbox/VBoxOGLrenderspu.so
  81. usr/lib/virtualbox/VBoxPython.so
  82. usr/lib/virtualbox/VBoxDD.so
  83. usr/lib/virtualbox/VBoxDDU.so
  84. usr/lib/virtualbox/VBoxREM64.so
  85. usr/lib/virtualbox/VBoxSharedClipboard.so
  86. usr/lib/virtualbox/VBoxHeadless.so
  87. usr/lib/virtualbox/VBoxRT.so
  88. usr/lib/virtualbox/VBoxREM.so
  89. usr/lib/virtualbox/VBoxSettings.so
  90. usr/lib/virtualbox/VBoxKeyboard.so
  91. usr/lib/virtualbox/VBoxSharedCrOpenGL.so
  92. usr/lib/virtualbox/VBoxVMM.so
  93. usr/lib/virtualbox/VirtualBox.so
  94. usr/lib/virtualbox/VBoxOGLhosterrorspu.so
  95. usr/lib/virtualbox/components/VBoxC.so
  96. usr/lib/virtualbox/components/VBoxSVCM.so
  97. usr/lib/virtualbox/components/VBoxDDU.so
  98. usr/lib/virtualbox/components/VBoxRT.so
  99. usr/lib/virtualbox/components/VBoxREM.so
  100. usr/lib/virtualbox/components/VBoxVMM.so
  101. usr/lib/virtualbox/VBoxREM32.so
  102. usr/lib/virtualbox/VBoxPython2_7.so
  103. usr/lib/virtualbox/VBoxXPCOMC.so
  104. usr/lib/virtualbox/VBoxOGLhostcrutil.so
  105. usr/lib/virtualbox/VBoxNetDHCP.so
  106. usr/lib/virtualbox/VBoxNetNAT.so"
  107. REQUIRED_USE="
  108. java? ( sdk )
  109. python? ( sdk )
  110. vboxwebsrv? ( java )
  111. ${PYTHON_REQUIRED_USE}
  112. "
  113. pkg_setup() {
  114. if ! use headless && ! use qt5 ; then
  115. einfo "No USE=\"qt5\" selected, this build will not include any Qt frontend."
  116. elif use headless && use qt5 ; then
  117. einfo "You selected USE=\"headless qt5\", defaulting to"
  118. einfo "USE=\"headless\", this build will not include any X11/Qt frontend."
  119. fi
  120. if ! use opengl ; then
  121. einfo "No USE=\"opengl\" selected, this build will lack"
  122. einfo "the OpenGL feature."
  123. fi
  124. if ! use python ; then
  125. einfo "You have disabled the \"python\" USE flag. This will only"
  126. einfo "disable the python bindings being installed."
  127. fi
  128. java-pkg-opt-2_pkg_setup
  129. python-single-r1_pkg_setup
  130. tc-ld-disable-gold #bug 488176
  131. tc-export CC CXX LD AR RANLIB
  132. export HOST_CC="$(tc-getBUILD_CC)"
  133. }
  134. src_prepare() {
  135. # Remove shipped binaries (kBuild,yasm), see bug #232775
  136. rm -r kBuild/bin tools || die
  137. # Remove pointless GCC version limitations in check_gcc()
  138. sed -e "/\s*-o\s*\\\(\s*\$cc_maj\s*-eq\s*[5-9]\s*-a\s*\$cc_min\s*-gt\s*[0-5]\s*\\\)\s*\\\/d" \
  139. -i configure || die
  140. # Disable things unused or split into separate ebuilds
  141. sed -e "s@MY_LIBDIR@$(get_libdir)@" \
  142. "${FILESDIR}"/${PN}-5-localconfig > LocalConfig.kmk || die
  143. # Respect LDFLAGS
  144. sed -e "s@_LDFLAGS\.${ARCH}*.*=@& ${LDFLAGS}@g" \
  145. -i Config.kmk src/libs/xpcom18a4/Config.kmk || die
  146. # Do not use hard-coded ld (related to bug #488176)
  147. sed -e '/QUIET)ld /s@ld @$(LD) @' \
  148. -i src/VBox/Devices/PC/ipxe/Makefile.kmk || die
  149. # Use PAM only when pam USE flag is enbaled (bug #376531)
  150. if ! use pam ; then
  151. elog "Disabling PAM removes the possibility to use the VRDP features."
  152. sed -i 's@^.*VBOX_WITH_PAM@#VBOX_WITH_PAM@' Config.kmk || die
  153. sed -i 's@\(.*/auth/Makefile.kmk.*\)@#\1@' \
  154. src/VBox/HostServices/Makefile.kmk || die
  155. fi
  156. # add correct java path
  157. if use java ; then
  158. sed "s@/usr/lib/jvm/java-6-sun@$(java-config -O)@" \
  159. -i "${S}"/Config.kmk || die
  160. java-pkg-opt-2_src_prepare
  161. fi
  162. # Only add nopie patch when we're on hardened
  163. if ! gcc-specs-pie ; then
  164. rm "${WORKDIR}"/patches/050_${PN}-*-nopie.patch || die
  165. fi
  166. # Only add paxmark patch when we're on pax_kernel
  167. if use pax_kernel ; then
  168. epatch "${FILESDIR}"/virtualbox-5.1.4-paxmark-bldprogs.patch || die
  169. fi
  170. eapply "${WORKDIR}/patches"
  171. eapply_user
  172. }
  173. src_configure() {
  174. local myconf=()
  175. use alsa || myconf+=( --disable-alsa )
  176. use debug && myconf+=( --build-debug )
  177. use doc || myconf+=( --disable-docs )
  178. use java || myconf+=( --disable-java )
  179. use lvm || myconf+=( --disable-devmapper )
  180. use opengl || myconf+=( --disable-opengl )
  181. use pulseaudio || myconf+=( --disable-pulse )
  182. use python || myconf+=( --disable-python )
  183. use vboxwebsrv && myconf+=( --enable-webservice )
  184. use vnc && myconf+=( --enable-vnc )
  185. if ! use headless ; then
  186. use qt5 || myconf+=( --disable-qt )
  187. else
  188. myconf+=( --build-headless --disable-opengl )
  189. fi
  190. if use amd64 && ! has_multilib_profile ; then
  191. myconf+=( --disable-vmmraw )
  192. fi
  193. # not an autoconf script
  194. ./configure \
  195. --with-gcc="$(tc-getCC)" \
  196. --with-g++="$(tc-getCXX)" \
  197. --disable-dbus \
  198. --disable-kmods \
  199. ${myconf[@]} \
  200. || die "configure failed"
  201. }
  202. src_compile() {
  203. source ./env.sh || die
  204. # Force kBuild to respect C[XX]FLAGS and MAKEOPTS (bug #178529)
  205. MAKEJOBS=$(echo ${MAKEOPTS} | egrep -o '(\-j|\-\-jobs)(=?|[[:space:]]*)[[:digit:]]+')
  206. MAKELOAD=$(echo ${MAKEOPTS} | egrep -o '(\-l|\-\-load-average)(=?|[[:space:]]*)[[:digit:]]+') #'
  207. MAKEOPTS="${MAKEJOBS} ${MAKELOAD}"
  208. MAKE="kmk" emake \
  209. VBOX_BUILD_PUBLISHER=_Gentoo \
  210. TOOL_GCC3_CC="$(tc-getCC)" TOOL_GCC3_CXX="$(tc-getCXX)" \
  211. TOOL_GCC3_AS="$(tc-getCC)" TOOL_GCC3_AR="$(tc-getAR)" \
  212. TOOL_GCC3_LD="$(tc-getCXX)" TOOL_GCC3_LD_SYSMOD="$(tc-getLD)" \
  213. TOOL_GCC3_CFLAGS="${CFLAGS}" TOOL_GCC3_CXXFLAGS="${CXXFLAGS}" \
  214. VBOX_GCC_OPT="${CXXFLAGS}" \
  215. TOOL_YASM_AS=yasm KBUILD_VERBOSE=2 \
  216. all
  217. }
  218. src_install() {
  219. local binpath="release"
  220. use debug && binpath="debug"
  221. cd "${S}"/out/linux.${ARCH}/${binpath}/bin || die
  222. local vbox_inst_path="/usr/$(get_libdir)/${PN}" each fwfile size ico icofile
  223. vbox_inst() {
  224. local binary="${1}"
  225. local perms="${2:-0750}"
  226. local path="${3:-${vbox_inst_path}}"
  227. [[ -n "${binary}" ]] || die "vbox_inst: No binray given!"
  228. [[ ${perms} =~ ^[[:digit:]]+{4}$ ]] || die "vbox_inst: perms must consist of four digits."
  229. insinto ${path}
  230. doins ${binary}
  231. fowners root:vboxusers ${path}/${binary}
  232. fperms ${perms} ${path}/${binary}
  233. }
  234. # Create configuration files
  235. insinto /etc/vbox
  236. newins "${FILESDIR}/${PN}-4-config" vbox.cfg
  237. # Set the correct libdir
  238. sed \
  239. -e "s@MY_LIBDIR@$(get_libdir)@" \
  240. -i "${D}"/etc/vbox/vbox.cfg || die "vbox.cfg sed failed"
  241. # Install the wrapper script
  242. exeinto ${vbox_inst_path}
  243. newexe "${FILESDIR}/${PN}-ose-5-wrapper" "VBox"
  244. fowners root:vboxusers ${vbox_inst_path}/VBox
  245. fperms 0750 ${vbox_inst_path}/VBox
  246. # Install binaries and libraries
  247. insinto ${vbox_inst_path}
  248. doins -r components
  249. # *.rc files for x86_64 are only available on multilib systems
  250. local rcfiles="*.rc"
  251. if use amd64 && ! has_multilib_profile ; then
  252. rcfiles=""
  253. fi
  254. for each in VBox{ExtPackHelperApp,Manage,SVC,Tunctl,XPCOMIPCD} *so *r0 ${rcfiles} ; do
  255. vbox_inst ${each}
  256. done
  257. # These binaries need to be suid root.
  258. for each in VBox{Headless,Net{AdpCtl,DHCP,NAT}} ; do
  259. vbox_inst ${each} 4750
  260. done
  261. # Install EFI Firmware files (bug #320757)
  262. pushd "${S}"/src/VBox/Devices/EFI/FirmwareBin &>/dev/null || die
  263. for fwfile in VBoxEFI{32,64}.fd ; do
  264. vbox_inst ${fwfile} 0644
  265. done
  266. popd &>/dev/null || die
  267. # VBoxSVC and VBoxManage need to be pax-marked (bug #403453)
  268. # VBoxXPCOMIPCD (bug #524202)
  269. for each in VBox{Headless,Manage,SVC,XPCOMIPCD} ; do
  270. pax-mark -m "${D}"${vbox_inst_path}/${each}
  271. done
  272. # Symlink binaries to the shipped wrapper
  273. for each in vbox{headless,manage} VBox{Headless,Manage,VRDP} ; do
  274. dosym ${vbox_inst_path}/VBox /usr/bin/${each}
  275. done
  276. dosym ${vbox_inst_path}/VBoxTunctl /usr/bin/VBoxTunctl
  277. # VRDPAuth only works with this (bug #351949)
  278. dosym VBoxAuth.so ${vbox_inst_path}/VRDPAuth.so
  279. # set an env-variable for 3rd party tools
  280. echo -n "VBOX_APP_HOME=${vbox_inst_path}" > "${T}/90virtualbox"
  281. doenvd "${T}/90virtualbox"
  282. if ! use headless ; then
  283. vbox_inst VBoxSDL 4750
  284. pax-mark -m "${D}"${vbox_inst_path}/VBoxSDL
  285. for each in vboxsdl VBoxSDL ; do
  286. dosym ${vbox_inst_path}/VBox /usr/bin/${each}
  287. done
  288. if use qt5 ; then
  289. vbox_inst VirtualBox 4750
  290. pax-mark -m "${D}"${vbox_inst_path}/VirtualBox
  291. if use opengl ; then
  292. vbox_inst VBoxTestOGL
  293. pax-mark -m "${D}"${vbox_inst_path}/VBoxTestOGL
  294. fi
  295. for each in virtualbox VirtualBox ; do
  296. dosym ${vbox_inst_path}/VBox /usr/bin/${each}
  297. done
  298. insinto /usr/share/${PN}
  299. doins -r nls
  300. newmenu "${FILESDIR}"/${PN}-ose.desktop-2 ${PN}.desktop
  301. fi
  302. pushd "${S}"/src/VBox/Artwork/OSE &>/dev/null || die
  303. for size in 16 32 48 64 128 ; do
  304. newicon -s ${size} ${PN}-${size}px.png ${PN}.png
  305. done
  306. newicon ${PN}-48px.png ${PN}.png
  307. doicon -s scalable ${PN}.svg
  308. popd &>/dev/null || die
  309. pushd "${S}"/src/VBox/Artwork/other &>/dev/null || die
  310. for size in 16 24 32 48 64 72 96 128 256 512 ; do
  311. for ico in hdd ova ovf vbox{,-extpack} vdi vdh vmdk ; do
  312. icofile="${PN}-${ico}-${size}px.png"
  313. if [[ -f "${icofile}" ]] ; then
  314. newicon -s ${size} ${icofile} ${PN}-${ico}.png
  315. fi
  316. done
  317. done
  318. popd &>/dev/null || die
  319. fi
  320. if use lvm ; then
  321. vbox_inst VBoxVolInfo 4750
  322. dosym ${vbox_inst_path}/VBoxVolInfo /usr/bin/VBoxVolInfo
  323. fi
  324. if use sdk ; then
  325. insinto ${vbox_inst_path}
  326. doins -r sdk
  327. if use java ; then
  328. java-pkg_regjar "${D}${vbox_inst_path}/sdk/bindings/xpcom/java/vboxjxpcom.jar"
  329. java-pkg_regso "${D}${vbox_inst_path}/libvboxjxpcom.so"
  330. fi
  331. fi
  332. if use udev ; then
  333. # New way of handling USB device nodes for VBox (bug #356215)
  334. local udevdir="$(get_udevdir)"
  335. insinto ${udevdir}
  336. doins VBoxCreateUSBNode.sh
  337. fowners root:vboxusers ${udevdir}/VBoxCreateUSBNode.sh
  338. fperms 0750 ${udevdir}/VBoxCreateUSBNode.sh
  339. insinto ${udevdir}/rules.d
  340. sed "s@%UDEVDIR%@${udevdir}@" "${FILESDIR}"/10-virtualbox.rules \
  341. > "${T}"/10-virtualbox.rules || die
  342. doins "${T}"/10-virtualbox.rules
  343. fi
  344. if use vboxwebsrv ; then
  345. vbox_inst vboxwebsrv
  346. dosym ${vbox_inst_path}/VBox /usr/bin/vboxwebsrv
  347. newinitd "${FILESDIR}"/vboxwebsrv-initd vboxwebsrv
  348. newconfd "${FILESDIR}"/vboxwebsrv-confd vboxwebsrv
  349. fi
  350. if use doc ; then
  351. dodoc UserManual.pdf
  352. fi
  353. }
  354. pkg_postinst() {
  355. fdo-mime_desktop_database_update
  356. if use udev ; then
  357. udevadm control --reload-rules \
  358. && udevadm trigger --subsystem-match=usb
  359. fi
  360. if ! use headless && use qt5 ; then
  361. elog "To launch VirtualBox just type: \"virtualbox\"."
  362. fi
  363. elog "You must be in the vboxusers group to use VirtualBox."
  364. elog ""
  365. elog "The latest user manual is available for download at:"
  366. elog "http://download.virtualbox.org/virtualbox/${PV}/UserManual.pdf"
  367. elog ""
  368. elog "For advanced networking setups you should emerge:"
  369. elog "net-misc/bridge-utils and sys-apps/usermode-utilities"
  370. elog ""
  371. elog "IMPORTANT!"
  372. elog "If you upgrade from app-emulation/virtualbox-ose make sure to run"
  373. elog "\"env-update\" as root and logout and relogin as the user you wish"
  374. elog "to run ${PN} as."
  375. elog ""
  376. elog "Starting with version 4.0.0, ${PN} has USB-1 support."
  377. elog "For USB-2 support, PXE-boot ability and VRDP support please emerge"
  378. elog " app-emulation/virtualbox-extpack-oracle"
  379. elog "package."
  380. elog "Starting with version 5.0.0, ${PN} no longer has the \"additions\" and"
  381. elog "the \"extension\" USE flag. For installation of the guest additions ISO"
  382. elog "image, please emerge"
  383. elog " app-emulation/virtualbox-additions"
  384. elog "and for the USB2, USB3, VRDP and PXE boot ROM modules, please emerge"
  385. elog " app-emulation/virtualbox-extpack-oracle"
  386. if ! use udev ; then
  387. elog ""
  388. elog "WARNING!"
  389. elog "Without USE=udev, USB devices will likely not work in ${PN}."
  390. elif [ -e "${ROOT}/etc/udev/rules.d/10-virtualbox.rules" ] ; then
  391. elog ""
  392. elog "Please remove \"${ROOT}/etc/udev/rules.d/10-virtualbox.rules\""
  393. elog "or else USB in ${PN} won't work."
  394. fi
  395. }
  396. pkg_postrm() {
  397. fdo-mime_desktop_database_update
  398. }