1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit 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.2.16-patches-02.tar.xz"
18 KEYWORDS="~amd64 ~x86"
36 >=dev-util/kbuild-0.1.9998.3127
44 X? ( x11-drivers/xf86-video-vboxvideo )
47 BUILD_TARGET_ARCH="${ARCH}"
49 S="${WORKDIR}/${MY_P}"
52 export DISTCC_DISABLE=1 #674256
53 MODULE_NAMES="vboxguest(misc:${WORKDIR}/vboxguest:${WORKDIR}/vboxguest)
54 vboxsf(misc:${WORKDIR}/vboxsf:${WORKDIR}/vboxsf)"
55 use X && MODULE_NAMES+=" vboxvideo(misc:${WORKDIR}/vboxvideo::${WORKDIR}/vboxvideo)"
58 BUILD_PARAMS="KERN_DIR=/lib/modules/${KV_FULL}/build KERNOUT=${KV_OUT_DIR}"
64 # Create and unpack a tarball with the sources of the Linux guest
65 # kernel modules, to include all the needed files
66 "${S}"/src/VBox/Additions/linux/export_modules.sh "${WORKDIR}/vbox-kmod.tar.gz"
67 unpack ./vbox-kmod.tar.gz
69 # Remove shipped binaries (kBuild,yasm), see bug #232775
71 rm -rf kBuild/bin tools
75 # PaX fixes (see bug #298988)
76 pushd "${WORKDIR}" &>/dev/null || die
77 eapply "${FILESDIR}"/vboxguest-4.1.0-log-use-c99.patch
78 popd &>/dev/null || die
80 # Disable things unused or splitted into separate ebuilds
81 cp "${FILESDIR}/${PN}-5-localconfig" LocalConfig.kmk || die
82 use X || echo "VBOX_WITH_X11_ADDITIONS :=" >> LocalConfig.kmk
84 # stupid new header references...
86 for vboxheader in {product,revision,version}-generated.h ; do
87 for mdir in vbox{guest,sf} ; do
88 ln -sf "${S}"/out/linux.${ARCH}/release/${vboxheader} \
89 "${WORKDIR}/${mdir}/${vboxheader}"
93 # Remove pointless GCC version check
94 sed -e '/^check_gcc$/d' -i configure || die
96 rm "${WORKDIR}/patches/008_virtualbox-4.3.14-missing_define.patch" || die
97 eapply "${WORKDIR}/patches"
103 # build the user-space tools, warnings are harmless
111 --with-gcc="$(tc-getCC)"
112 --with-g++="$(tc-getCXX)"
113 --target-arch=${ARCH}
114 --with-linux="${KV_OUT_DIR}"
118 "${cmd[@]}" || die "configure failed"
120 export VBOX_GCC_OPT="${CFLAGS} ${CPPFLAGS}"
125 emake TOOL_YASM_AS=yasm \
126 VBOX_ONLY_ADDITIONS=1 \
129 # Now creating the kernel modules. We must do this _after_
130 # we compiled the user-space tools as we need two of the
131 # automatically generated header files. (>=3.2.0)
132 linux-mod_src_compile
136 linux-mod_src_install
138 cd "${S}"/out/linux.${ARCH}/release/bin/additions || die
141 newins mount.vboxsf mount.vboxsf
142 fperms 4755 /sbin/mount.vboxsf
144 newinitd "${FILESDIR}"/${PN}-8.initd ${PN}
147 newins VBoxService vboxguest-service
148 fperms 0755 /usr/sbin/vboxguest-service
152 fperms 0755 /usr/bin/VBoxControl
154 # VBoxClient user service and xrandr wrapper
157 fperms 0755 /usr/bin/VBoxClient
159 pushd "${S}"/src/VBox/Additions/x11/Installer &>/dev/null \
161 newins 98vboxadd-xclient VBoxClient-all
162 fperms 0755 /usr/bin/VBoxClient-all
163 popd &>/dev/null || die
166 # udev rule for vboxdrv
167 local udev_rules_dir="/lib/udev/rules.d"
168 dodir ${udev_rules_dir}
169 echo 'KERNEL=="vboxguest", OWNER="vboxguest", GROUP="vboxguest", MODE="0660"' \
170 >> "${ED%/}/${udev_rules_dir}/60-virtualbox-guest-additions.rules" \
172 echo 'KERNEL=="vboxuser", OWNER="vboxguest", GROUP="vboxguest", MODE="0660"' \
173 >> "${ED%/}/${udev_rules_dir}/60-virtualbox-guest-additions.rules" \
176 # VBoxClient autostart file
177 insinto /etc/xdg/autostart
178 doins "${FILESDIR}"/vboxclient.desktop
181 insinto /usr/share/doc/${PF}
182 doins "${FILESDIR}"/xorg.conf.vbox
184 systemd_dounit "${FILESDIR}/${PN}.service"
189 enewuser vboxguest -1 /bin/sh /dev/null vboxguest
190 # automount Error: VBoxServiceAutoMountWorker: Group "vboxsf" does not exist
195 linux-mod_pkg_postinst
197 elog "use flag X is off, enable it to install the"
198 elog "X Window System video driver."
201 elog "Please add users to the \"vboxguest\" group so they can"
202 elog "benefit from seamless mode, auto-resize and clipboard."
204 elog "The vboxsf group has been added to make automount services work."
205 elog "These services are part of the shared folders support."
208 elog "/etc/init.d/${PN}"
209 elog "to the default runlevel in order to start"
210 elog "needed services."
211 elog "To use the VirtualBox X driver, use the following"
212 elog "file as your /etc/X11/xorg.conf:"
213 elog " /usr/share/doc/${PF}/xorg.conf.vbox"
215 elog "Also make sure you use the Mesa library for OpenGL:"
216 elog " eselect opengl set xorg-x11"
218 elog "An autostart .desktop file has been installed to start"
219 elog "VBoxClient in desktop sessions."
221 elog "You can mount shared folders with:"
222 elog " mount -t vboxsf <shared_folder_name> <mount_point>"
225 elog "this ebuild is only needed if you are running gentoo"
226 elog "inside a VirtualBox Virtual Machine, you don't need"
227 elog "it to run VirtualBox itself."