virtualbox-5.0.36.ebuild 13 KB

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