virtualbox-bin-5.1.16.113841.ebuild 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. PYTHON_COMPAT=( python2_7 )
  5. inherit eutils fdo-mime gnome2 pax-utils python-r1 udev unpacker versionator
  6. MAIN_PV="$(get_version_component_range 1-3)"
  7. if [[ ${PV} = *_beta* ]] || [[ ${PV} = *_rc* ]] ; then
  8. MY_PV="${MAIN_PV}_$(get_version_component_range 5)"
  9. MY_PV="${MY_PV/beta/BETA}"
  10. MY_PV="${MY_PV/rc/RC}"
  11. else
  12. MY_PV="${MAIN_PV}"
  13. fi
  14. VBOX_BUILD_ID="$(get_version_component_range 4)"
  15. VBOX_PV="${MY_PV}-${VBOX_BUILD_ID}"
  16. MY_P="VirtualBox-${VBOX_PV}-Linux"
  17. # needed as sometimes the extpack gets another build ID
  18. EXTP_PV="${VBOX_PV}"
  19. EXTP_PN="Oracle_VM_VirtualBox_Extension_Pack"
  20. EXTP_P="${EXTP_PN}-${EXTP_PV}"
  21. # needed as sometimes the SDK gets another build ID
  22. SDK_PV="${VBOX_PV}"
  23. SDK_P="VirtualBoxSDK-${SDK_PV}"
  24. DESCRIPTION="Family of powerful x86 virtualization products for enterprise and home use"
  25. HOMEPAGE="http://www.virtualbox.org/"
  26. SRC_URI="amd64? ( http://download.virtualbox.org/virtualbox/${MY_PV}/${MY_P}_amd64.run )
  27. x86? ( http://download.virtualbox.org/virtualbox/${MY_PV}/${MY_P}_x86.run )
  28. http://download.virtualbox.org/virtualbox/${MY_PV}/${EXTP_P}.vbox-extpack -> ${EXTP_P}.tar.gz"
  29. LICENSE="GPL-2 PUEL"
  30. SLOT="0"
  31. KEYWORDS="~amd64 ~x86"
  32. IUSE="+additions +chm headless python vboxwebsrv rdesktop-vrdp"
  33. RESTRICT="mirror"
  34. if [[ "${PV}" != *beta* ]] ; then
  35. SRC_URI+="
  36. sdk? ( http://download.virtualbox.org/virtualbox/${MY_PV}/${SDK_P}.zip )"
  37. IUSE+=" sdk"
  38. fi
  39. DEPEND="app-arch/unzip
  40. ${PYTHON_DEPS}"
  41. RDEPEND="!!app-emulation/virtualbox
  42. !app-emulation/virtualbox-additions
  43. ~app-emulation/virtualbox-modules-${MAIN_PV}
  44. !headless? (
  45. dev-libs/glib
  46. media-libs/fontconfig
  47. media-libs/freetype
  48. media-libs/libpng
  49. media-libs/libsdl[X]
  50. x11-libs/libXcursor
  51. x11-libs/libXext
  52. x11-libs/libXfixes
  53. x11-libs/libXft
  54. x11-libs/libXi
  55. x11-libs/libXinerama
  56. x11-libs/libXrandr
  57. x11-libs/libXrender
  58. chm? ( dev-libs/expat )
  59. )
  60. dev-libs/libxml2
  61. sys-fs/lvm2
  62. x11-libs/libXau
  63. x11-libs/libX11
  64. x11-libs/libXt
  65. x11-libs/libXmu
  66. x11-libs/libSM
  67. x11-libs/libICE
  68. x11-libs/libXdmcp
  69. ${PYTHON_DEPS}"
  70. REQUIRED_USE="${PYTHON_REQUIRED_USE}"
  71. S=${WORKDIR}
  72. QA_PREBUILT="opt/VirtualBox/*"
  73. PYTHON_UPDATER_IGNORE="1"
  74. src_unpack() {
  75. unpack_makeself ${MY_P}_${ARCH}.run
  76. unpack ./VirtualBox.tar.bz2
  77. mkdir "${S}"/${EXTP_PN} || die
  78. pushd "${S}"/${EXTP_PN} &>/dev/null || die
  79. unpack ${EXTP_P}.tar.gz
  80. popd &>/dev/null || die
  81. if [[ "${PV}" != *beta* ]] && use sdk ; then
  82. unpack VirtualBoxSDK-${SDK_PV}.zip
  83. fi
  84. }
  85. src_configure() {
  86. :;
  87. }
  88. src_compile() {
  89. :;
  90. }
  91. src_install() {
  92. # create virtualbox configurations files
  93. insinto /etc/vbox
  94. newins "${FILESDIR}/${PN}-config" vbox.cfg
  95. if ! use headless ; then
  96. newmenu "${FILESDIR}"/${PN}.desktop-2 ${PN}.desktop
  97. # set up symlinks (bug #572012)
  98. dosym /opt/VirtualBox/virtualbox.xml /usr/share/mime/packages/virtualbox.xml
  99. local size ico icofile
  100. for size in 16 24 32 48 64 72 96 128 256 ; do
  101. pushd "${S}"/icons/${size}x${size} &>/dev/null || die
  102. if [[ -f "virtualbox.png" ]] ; then
  103. doicon -s ${size} virtualbox.png
  104. fi
  105. for ico in hdd ova ovf vbox{,-extpack} vdi vdh vmdk ; do
  106. icofile="virtualbox-${ico}.png"
  107. if [[ -f "${icofile}" ]] ; then
  108. doicon -s ${size} ${icofile}
  109. fi
  110. done
  111. popd &>/dev/null || die
  112. done
  113. doicon -s scalable "${S}"/icons/scalable/virtualbox.svg
  114. insinto /usr/share/pixmaps
  115. newins "${S}"/icons/48x48/virtualbox.png ${PN}.png
  116. fi
  117. pushd "${S}"/${EXTP_PN} &>/dev/null || die
  118. insinto /opt/VirtualBox/ExtensionPacks/${EXTP_PN}
  119. doins -r linux.${ARCH}
  120. doins ExtPack* PXE-Intel.rom
  121. popd &>/dev/null || die
  122. rm -rf "${S}"/${EXTP_PN}
  123. insinto /opt/VirtualBox
  124. dodir /opt/bin
  125. doins UserManual.pdf
  126. if [[ "${PV}" != *beta* ]] && use sdk ; then
  127. doins -r sdk
  128. fi
  129. if use additions; then
  130. doins -r additions
  131. fi
  132. if use vboxwebsrv; then
  133. doins vboxwebsrv
  134. fowners root:vboxusers /opt/VirtualBox/vboxwebsrv
  135. fperms 0750 /opt/VirtualBox/vboxwebsrv
  136. dosym /opt/VirtualBox/VBox.sh /opt/bin/vboxwebsrv
  137. newinitd "${FILESDIR}"/vboxwebsrv-initd vboxwebsrv
  138. newconfd "${FILESDIR}"/vboxwebsrv-confd vboxwebsrv
  139. fi
  140. if use rdesktop-vrdp; then
  141. doins rdesktop-vrdp
  142. doins -r rdesktop-vrdp-keymaps
  143. fperms 0750 /opt/VirtualBox/rdesktop-vrdp
  144. dosym /opt/VirtualBox/rdesktop-vrdp /opt/bin/rdesktop-vrdp
  145. fi
  146. if ! use headless && use chm; then
  147. doins kchmviewer VirtualBox.chm
  148. fowners root:vboxusers /opt/VirtualBox/kchmviewer
  149. fperms 0750 /opt/VirtualBox/kchmviewer
  150. fi
  151. # This ebuild / package supports only py2.7. When py3 comes is unknown.
  152. # The compile phase makes VBoxPython2_7.so.
  153. # py3 support would presumably require a binary pre-compiled by py3.
  154. use python && doins VBoxPython.so VBoxPython2_7.so
  155. rm -rf src rdesktop* deffiles install* routines.sh runlevel.sh \
  156. vboxdrv.sh VBox.sh VBox.png vboxnet.sh additions VirtualBox.desktop \
  157. VirtualBox.tar.bz2 LICENSE VBoxSysInfo.sh rdesktop* vboxwebsrv \
  158. webtest kchmviewer VirtualBox.chm vbox-create-usb-node.sh \
  159. 90-vbox-usb.fdi uninstall.sh vboxshell.py vboxdrv-pardus.py \
  160. VBoxPython?_*.so
  161. if use headless ; then
  162. rm -rf VBoxSDL VirtualBox VBoxKeyboard.so
  163. fi
  164. doins -r * || die
  165. # create symlinks for working around unsupported $ORIGIN/.. in VBoxC.so (setuid)
  166. dosym /opt/VirtualBox/VBoxVMM.so /opt/VirtualBox/components/VBoxVMM.so
  167. dosym /opt/VirtualBox/VBoxREM.so /opt/VirtualBox/components/VBoxREM.so
  168. dosym /opt/VirtualBox/VBoxRT.so /opt/VirtualBox/components/VBoxRT.so
  169. dosym /opt/VirtualBox/VBoxDDU.so /opt/VirtualBox/components/VBoxDDU.so
  170. dosym /opt/VirtualBox/VBoxXPCOM.so /opt/VirtualBox/components/VBoxXPCOM.so
  171. local each
  172. for each in VBox{Manage,SVC,XPCOMIPCD,Tunctl,NetAdpCtl,NetDHCP,NetNAT,TestOGL,ExtPackHelperApp}; do
  173. fowners root:vboxusers /opt/VirtualBox/${each}
  174. fperms 0750 /opt/VirtualBox/${each}
  175. pax-mark -m "${D}"/opt/VirtualBox/${each}
  176. done
  177. # VBoxNetAdpCtl and VBoxNetDHCP binaries need to be suid root in any case..
  178. fperms 4750 /opt/VirtualBox/VBoxNetAdpCtl
  179. fperms 4750 /opt/VirtualBox/VBoxNetDHCP
  180. fperms 4750 /opt/VirtualBox/VBoxNetNAT
  181. if ! use headless ; then
  182. # Hardened build: Mark selected binaries set-user-ID-on-execution
  183. for each in VBox{SDL,Headless} VirtualBox; do
  184. fowners root:vboxusers /opt/VirtualBox/${each}
  185. fperms 4510 /opt/VirtualBox/${each}
  186. pax-mark -m "${D}"/opt/VirtualBox/${each}
  187. done
  188. dosym /opt/VirtualBox/VBox.sh /opt/bin/VirtualBox
  189. dosym /opt/VirtualBox/VBox.sh /opt/bin/VBoxSDL
  190. else
  191. # Hardened build: Mark selected binaries set-user-ID-on-execution
  192. fowners root:vboxusers /opt/VirtualBox/VBoxHeadless
  193. fperms 4510 /opt/VirtualBox/VBoxHeadless
  194. pax-mark -m "${D}"/opt/VirtualBox/VBoxHeadless
  195. fi
  196. exeinto /opt/VirtualBox
  197. newexe "${FILESDIR}/${PN}-3-wrapper" "VBox.sh"
  198. fowners root:vboxusers /opt/VirtualBox/VBox.sh
  199. fperms 0750 /opt/VirtualBox/VBox.sh
  200. dosym /opt/VirtualBox/VBox.sh /opt/bin/VBoxManage
  201. dosym /opt/VirtualBox/VBox.sh /opt/bin/VBoxVRDP
  202. dosym /opt/VirtualBox/VBox.sh /opt/bin/VBoxHeadless
  203. dosym /opt/VirtualBox/VBoxTunctl /opt/bin/VBoxTunctl
  204. # set an env-variable for 3rd party tools
  205. echo -n "VBOX_APP_HOME=/opt/VirtualBox" > "${T}/90virtualbox"
  206. doenvd "${T}/90virtualbox"
  207. local udevdir="$(get_udevdir)"
  208. insinto ${udevdir}/rules.d
  209. doins "${FILESDIR}"/10-virtualbox.rules
  210. sed "s@%UDEVDIR%@${udevdir}@" \
  211. -i "${D}"${udevdir}/rules.d/10-virtualbox.rules || die
  212. # move udev scripts into ${udevdir} (bug #372491)
  213. mv "${D}"/opt/VirtualBox/VBoxCreateUSBNode.sh "${D}"${udevdir} || die
  214. fperms 0750 ${udevdir}/VBoxCreateUSBNode.sh
  215. }
  216. pkg_postinst() {
  217. fdo-mime_desktop_database_update
  218. gnome2_icon_cache_update
  219. udevadm control --reload-rules && udevadm trigger --subsystem-match=usb
  220. elog ""
  221. if ! use headless ; then
  222. elog "To launch VirtualBox just type: \"VirtualBox\""
  223. elog ""
  224. fi
  225. elog "You must be in the vboxusers group to use VirtualBox."
  226. elog ""
  227. elog "For advanced networking setups you should emerge:"
  228. elog "net-misc/bridge-utils and sys-apps/usermode-utilities"
  229. elog ""
  230. elog "Please visit http://www.virtualbox.org/wiki/Editions for"
  231. elog "an overview about the different features of ${PN}"
  232. elog "and virtualbox-ose"
  233. if [ -e "${ROOT}/etc/udev/rules.d/10-virtualbox.rules" ] ; then
  234. elog ""
  235. elog "Please remove \"${ROOT}/etc/udev/rules.d/10-virtualbox.rules\""
  236. elog "or else USB in ${PN} won't work."
  237. fi
  238. }
  239. pkg_postrm() {
  240. fdo-mime_desktop_database_update
  241. }