virtualbox-guest-additions-5.0.32.ebuild 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. inherit eutils linux-mod systemd user toolchain-funcs
  5. MY_PV="${PV/beta/BETA}"
  6. MY_PV="${MY_PV/rc/RC}"
  7. MY_P=VirtualBox-${MY_PV}
  8. DESCRIPTION="VirtualBox kernel modules and user-space tools for Gentoo guests"
  9. HOMEPAGE="http://www.virtualbox.org/"
  10. SRC_URI="http://download.virtualbox.org/virtualbox/${MY_PV}/${MY_P}.tar.bz2"
  11. LICENSE="GPL-2"
  12. SLOT="0"
  13. KEYWORDS="amd64 x86"
  14. IUSE="X"
  15. RDEPEND="X? ( x11-apps/xrandr
  16. x11-apps/xrefresh
  17. x11-libs/libXmu
  18. x11-libs/libX11
  19. x11-libs/libXt
  20. x11-libs/libXext
  21. x11-libs/libXau
  22. x11-libs/libXdmcp
  23. x11-libs/libSM
  24. x11-libs/libICE
  25. x11-proto/glproto )
  26. sys-apps/dbus
  27. !!x11-drivers/xf86-input-virtualbox"
  28. DEPEND="${RDEPEND}
  29. >=dev-util/kbuild-0.1.9998_pre20131130
  30. >=dev-lang/yasm-0.6.2
  31. sys-devel/bin86
  32. sys-libs/pam
  33. sys-power/iasl
  34. X? ( x11-proto/renderproto )
  35. !X? ( x11-proto/xproto )"
  36. PDEPEND="X? ( ~x11-drivers/xf86-video-virtualbox-${PV} )"
  37. BUILD_TARGETS="all"
  38. BUILD_TARGET_ARCH="${ARCH}"
  39. S="${WORKDIR}/${MY_P}"
  40. pkg_setup() {
  41. MODULE_NAMES="vboxguest(misc:${WORKDIR}/vboxguest:${WORKDIR}/vboxguest)
  42. vboxsf(misc:${WORKDIR}/vboxsf:${WORKDIR}/vboxsf)"
  43. use X && MODULE_NAMES+=" vboxvideo(misc:${WORKDIR}/vboxvideo::${WORKDIR}/vboxvideo)"
  44. linux-mod_pkg_setup
  45. BUILD_PARAMS="KERN_DIR=${KV_OUT_DIR} KERNOUT=${KV_OUT_DIR}"
  46. enewgroup vboxguest
  47. enewuser vboxguest -1 /bin/sh /dev/null vboxguest
  48. # automount Error: VBoxServiceAutoMountWorker: Group "vboxsf" does not exist
  49. enewgroup vboxsf
  50. }
  51. src_unpack() {
  52. unpack ${A}
  53. # Create and unpack a tarball with the sources of the Linux guest
  54. # kernel modules, to include all the needed files
  55. "${S}"/src/VBox/Additions/linux/export_modules "${WORKDIR}/vbox-kmod.tar.gz"
  56. unpack ./vbox-kmod.tar.gz
  57. # Remove shipped binaries (kBuild,yasm), see bug #232775
  58. cd "${S}"
  59. rm -rf kBuild/bin tools
  60. }
  61. src_prepare() {
  62. # PaX fixes (see bug #298988)
  63. pushd "${WORKDIR}" &>/dev/null || die
  64. eapply "${FILESDIR}"/vboxguest-4.1.0-log-use-c99.patch
  65. popd &>/dev/null || die
  66. # Disable things unused or splitted into separate ebuilds
  67. cp "${FILESDIR}/${PN}-5-localconfig" LocalConfig.kmk || die
  68. use X || echo "VBOX_WITH_X11_ADDITIONS :=" >> LocalConfig.kmk
  69. # stupid new header references...
  70. for vboxheader in {product,revision,version}-generated.h ; do
  71. for mdir in vbox{guest,sf} ; do
  72. ln -sf "${S}"/out/linux.${ARCH}/release/${vboxheader} \
  73. "${WORKDIR}/${mdir}/${vboxheader}"
  74. done
  75. done
  76. # Remove pointless GCC version limitations in check_gcc()
  77. 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" \
  78. -i configure || die
  79. eapply_user
  80. }
  81. src_configure() {
  82. # build the user-space tools, warnings are harmless
  83. local cmd=(
  84. ./configure
  85. --nofatal
  86. --disable-xpcom
  87. --disable-sdl-ttf
  88. --disable-pulse
  89. --disable-alsa
  90. --with-gcc="$(tc-getCC)"
  91. --with-g++="$(tc-getCXX)"
  92. --target-arch=${ARCH}
  93. --with-linux="${KV_OUT_DIR}"
  94. --build-headless
  95. )
  96. echo "${cmd[@]}"
  97. "${cmd[@]}" || die "configure failed"
  98. source ./env.sh
  99. export VBOX_GCC_OPT="${CFLAGS} ${CPPFLAGS}"
  100. }
  101. src_compile() {
  102. MAKE="kmk" \
  103. emake TOOL_YASM_AS=yasm \
  104. VBOX_ONLY_ADDITIONS=1 \
  105. KBUILD_VERBOSE=2
  106. # Now creating the kernel modules. We must do this _after_
  107. # we compiled the user-space tools as we need two of the
  108. # automatically generated header files. (>=3.2.0)
  109. linux-mod_src_compile
  110. }
  111. src_install() {
  112. linux-mod_src_install
  113. cd "${S}"/out/linux.${ARCH}/release/bin/additions || die
  114. insinto /sbin
  115. newins mount.vboxsf mount.vboxsf
  116. fperms 4755 /sbin/mount.vboxsf
  117. newinitd "${FILESDIR}"/${PN}-8.initd ${PN}
  118. insinto /usr/sbin/
  119. newins VBoxService vboxguest-service
  120. fperms 0755 /usr/sbin/vboxguest-service
  121. insinto /usr/bin
  122. doins VBoxControl
  123. fperms 0755 /usr/bin/VBoxControl
  124. # VBoxClient user service and xrandr wrapper
  125. if use X ; then
  126. doins VBoxClient
  127. fperms 0755 /usr/bin/VBoxClient
  128. pushd "${S}"/src/VBox/Additions/x11/Installer &>/dev/null \
  129. || die
  130. newins 98vboxadd-xclient VBoxClient-all
  131. fperms 0755 /usr/bin/VBoxClient-all
  132. popd &>/dev/null || die
  133. fi
  134. # udev rule for vboxdrv
  135. local udev_rules_dir="/lib/udev/rules.d"
  136. dodir ${udev_rules_dir}
  137. echo 'KERNEL=="vboxguest", OWNER="vboxguest", GROUP="vboxguest", MODE="0660"' \
  138. >> "${D}/${udev_rules_dir}/60-virtualbox-guest-additions.rules" \
  139. || die
  140. echo 'KERNEL=="vboxuser", OWNER="vboxguest", GROUP="vboxguest", MODE="0660"' \
  141. >> "${D}/${udev_rules_dir}/60-virtualbox-guest-additions.rules" \
  142. || die
  143. # VBoxClient autostart file
  144. insinto /etc/xdg/autostart
  145. doins "${FILESDIR}"/vboxclient.desktop
  146. # sample xorg.conf
  147. insinto /usr/share/doc/${PF}
  148. doins "${FILESDIR}"/xorg.conf.vbox
  149. systemd_dounit "${FILESDIR}/${PN}.service"
  150. }
  151. pkg_postinst() {
  152. linux-mod_pkg_postinst
  153. if ! use X ; then
  154. elog "use flag X is off, enable it to install the"
  155. elog "X Window System video driver."
  156. fi
  157. elog ""
  158. elog "Please add users to the \"vboxguest\" group so they can"
  159. elog "benefit from seamless mode, auto-resize and clipboard."
  160. elog ""
  161. elog "The vboxsf group has been added to make automount services work."
  162. elog "These services are part of the shared folders support."
  163. elog ""
  164. elog "Please add:"
  165. elog "/etc/init.d/${PN}"
  166. elog "to the default runlevel in order to start"
  167. elog "needed services."
  168. elog "To use the VirtualBox X driver, use the following"
  169. elog "file as your /etc/X11/xorg.conf:"
  170. elog " /usr/share/doc/${PF}/xorg.conf.vbox"
  171. elog ""
  172. elog "Also make sure you use the Mesa library for OpenGL:"
  173. elog " eselect opengl set xorg-x11"
  174. elog ""
  175. elog "An autostart .desktop file has been installed to start"
  176. elog "VBoxClient in desktop sessions."
  177. elog ""
  178. elog "You can mount shared folders with:"
  179. elog " mount -t vboxsf <shared_folder_name> <mount_point>"
  180. elog ""
  181. elog "Warning:"
  182. elog "this ebuild is only needed if you are running gentoo"
  183. elog "inside a VirtualBox Virtual Machine, you don't need"
  184. elog "it to run VirtualBox itself."
  185. elog ""
  186. }