1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils linux-mod systemd user toolchain-funcs
8 MY_PV="${PV/beta/BETA}"
10 MY_P=VirtualBox-${MY_PV}
11 DESCRIPTION="VirtualBox kernel modules and user-space tools for Gentoo guests"
12 HOMEPAGE="https://www.virtualbox.org/"
13 SRC_URI="https://download.virtualbox.org/virtualbox/${MY_PV}/${MY_P}.tar.bz2
14 https://dev.gentoo.org/~polynomial-c/virtualbox/patchsets/virtualbox-5.1.30-patches-02.tar.xz"
18 KEYWORDS="~amd64 ~x86"
33 !!x11-drivers/xf86-input-virtualbox
34 !x11-drivers/xf86-video-virtualbox
38 >=dev-util/kbuild-0.1.9998.3127
46 X? ( x11-drivers/xf86-video-vboxvideo )
49 BUILD_TARGET_ARCH="${ARCH}"
51 S="${WORKDIR}/${MY_P}"
54 MODULE_NAMES="vboxguest(misc:${WORKDIR}/vboxguest:${WORKDIR}/vboxguest)
55 vboxsf(misc:${WORKDIR}/vboxsf:${WORKDIR}/vboxsf)"
56 use X && MODULE_NAMES+=" vboxvideo(misc:${WORKDIR}/vboxvideo::${WORKDIR}/vboxvideo)"
59 BUILD_PARAMS="KERN_DIR=${KV_OUT_DIR} KERNOUT=${KV_OUT_DIR}"
61 enewuser vboxguest -1 /bin/sh /dev/null vboxguest
62 # automount Error: VBoxServiceAutoMountWorker: Group "vboxsf" does not exist
69 # Create and unpack a tarball with the sources of the Linux guest
70 # kernel modules, to include all the needed files
71 "${S}"/src/VBox/Additions/linux/export_modules.sh "${WORKDIR}/vbox-kmod.tar.gz"
72 unpack ./vbox-kmod.tar.gz
74 # Remove shipped binaries (kBuild,yasm), see bug #232775
76 rm -rf kBuild/bin tools
80 # PaX fixes (see bug #298988)
81 pushd "${WORKDIR}" &>/dev/null || die
82 eapply "${FILESDIR}"/vboxguest-4.1.0-log-use-c99.patch
83 popd &>/dev/null || die
85 # Disable things unused or splitted into separate ebuilds
86 cp "${FILESDIR}/${PN}-5-localconfig" LocalConfig.kmk || die
87 use X || echo "VBOX_WITH_X11_ADDITIONS :=" >> LocalConfig.kmk
89 # stupid new header references...
90 for vboxheader in {product,revision,version}-generated.h ; do
91 for mdir in vbox{guest,sf} ; do
92 ln -sf "${S}"/out/linux.${ARCH}/release/${vboxheader} \
93 "${WORKDIR}/${mdir}/${vboxheader}"
97 # Remove pointless GCC version check
98 sed -e '/^check_gcc$/d' -i configure || die
100 rm "${WORKDIR}/patches/011_virtualbox-5.1.30-sysmacros.patch" || die
101 eapply "${WORKDIR}/patches"
107 # build the user-space tools, warnings are harmless
115 --with-gcc="$(tc-getCC)"
116 --with-g++="$(tc-getCXX)"
117 --target-arch=${ARCH}
118 --with-linux="${KV_OUT_DIR}"
122 "${cmd[@]}" || die "configure failed"
124 export VBOX_GCC_OPT="${CFLAGS} ${CPPFLAGS}"
129 emake TOOL_YASM_AS=yasm \
130 VBOX_ONLY_ADDITIONS=1 \
133 # Now creating the kernel modules. We must do this _after_
134 # we compiled the user-space tools as we need two of the
135 # automatically generated header files. (>=3.2.0)
136 linux-mod_src_compile
140 linux-mod_src_install
142 cd "${S}"/out/linux.${ARCH}/release/bin/additions || die
145 newins mount.vboxsf mount.vboxsf
146 fperms 4755 /sbin/mount.vboxsf
148 newinitd "${FILESDIR}"/${PN}-8.initd ${PN}
151 newins VBoxService vboxguest-service
152 fperms 0755 /usr/sbin/vboxguest-service
156 fperms 0755 /usr/bin/VBoxControl
158 # VBoxClient user service and xrandr wrapper
161 fperms 0755 /usr/bin/VBoxClient
163 pushd "${S}"/src/VBox/Additions/x11/Installer &>/dev/null \
165 newins 98vboxadd-xclient VBoxClient-all
166 fperms 0755 /usr/bin/VBoxClient-all
167 popd &>/dev/null || die
170 # udev rule for vboxdrv
171 local udev_rules_dir="/lib/udev/rules.d"
172 dodir ${udev_rules_dir}
173 echo 'KERNEL=="vboxguest", OWNER="vboxguest", GROUP="vboxguest", MODE="0660"' \
174 >> "${D}/${udev_rules_dir}/60-virtualbox-guest-additions.rules" \
176 echo 'KERNEL=="vboxuser", OWNER="vboxguest", GROUP="vboxguest", MODE="0660"' \
177 >> "${D}/${udev_rules_dir}/60-virtualbox-guest-additions.rules" \
180 # VBoxClient autostart file
181 insinto /etc/xdg/autostart
182 doins "${FILESDIR}"/vboxclient.desktop
185 insinto /usr/share/doc/${PF}
186 doins "${FILESDIR}"/xorg.conf.vbox
188 systemd_dounit "${FILESDIR}/${PN}.service"
192 linux-mod_pkg_postinst
194 elog "use flag X is off, enable it to install the"
195 elog "X Window System video driver."
198 elog "Please add users to the \"vboxguest\" group so they can"
199 elog "benefit from seamless mode, auto-resize and clipboard."
201 elog "The vboxsf group has been added to make automount services work."
202 elog "These services are part of the shared folders support."
205 elog "/etc/init.d/${PN}"
206 elog "to the default runlevel in order to start"
207 elog "needed services."
208 elog "To use the VirtualBox X driver, use the following"
209 elog "file as your /etc/X11/xorg.conf:"
210 elog " /usr/share/doc/${PF}/xorg.conf.vbox"
212 elog "Also make sure you use the Mesa library for OpenGL:"
213 elog " eselect opengl set xorg-x11"
215 elog "An autostart .desktop file has been installed to start"
216 elog "VBoxClient in desktop sessions."
218 elog "You can mount shared folders with:"
219 elog " mount -t vboxsf <shared_folder_name> <mount_point>"
222 elog "this ebuild is only needed if you are running gentoo"
223 elog "inside a VirtualBox Virtual Machine, you don't need"
224 elog "it to run VirtualBox itself."