app-emulation/docker: Remove old
[gentoo.git] / app-emulation / virtualbox-guest-additions / virtualbox-guest-additions-5.2.10.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit eutils linux-mod systemd user toolchain-funcs
7
8 MY_PV="${PV/beta/BETA}"
9 MY_PV="${MY_PV/rc/RC}"
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"
15
16 LICENSE="GPL-2"
17 SLOT="0"
18 KEYWORDS="~amd64 ~x86"
19 IUSE="X"
20
21 RDEPEND="
22         X? ( x11-apps/xrandr
23                 x11-apps/xrefresh
24                 x11-libs/libXmu
25                 x11-libs/libX11
26                 x11-libs/libXt
27                 x11-libs/libXext
28                 x11-libs/libXau
29                 x11-libs/libXdmcp
30                 x11-libs/libSM
31                 x11-libs/libICE )
32         sys-apps/dbus
33         !!x11-drivers/xf86-input-virtualbox
34         !x11-drivers/xf86-video-virtualbox
35 "
36 DEPEND="
37         ${RDEPEND}
38         >=dev-util/kbuild-0.1.9998.3127
39         >=dev-lang/yasm-0.6.2
40         sys-devel/bin86
41         sys-libs/pam
42         sys-power/iasl
43         x11-base/xorg-proto
44 "
45 PDEPEND="
46         X? ( x11-drivers/xf86-video-vboxvideo )
47 "
48 BUILD_TARGETS="all"
49 BUILD_TARGET_ARCH="${ARCH}"
50
51 S="${WORKDIR}/${MY_P}"
52
53 pkg_setup() {
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)"
57
58         linux-mod_pkg_setup
59         BUILD_PARAMS="KERN_DIR=${KV_OUT_DIR} KERNOUT=${KV_OUT_DIR}"
60         enewgroup vboxguest
61         enewuser vboxguest -1 /bin/sh /dev/null vboxguest
62         # automount Error: VBoxServiceAutoMountWorker: Group "vboxsf" does not exist
63         enewgroup vboxsf
64 }
65
66 src_unpack() {
67         unpack ${A}
68
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
73
74         # Remove shipped binaries (kBuild,yasm), see bug #232775
75         cd "${S}"
76         rm -rf kBuild/bin tools
77 }
78
79 src_prepare() {
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
84
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
88
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}"
94                 done
95         done
96
97         # Remove pointless GCC version check
98         sed -e '/^check_gcc$/d' -i configure || die
99
100         rm "${WORKDIR}/patches/011_virtualbox-5.1.30-sysmacros.patch" || die
101         eapply "${WORKDIR}/patches"
102
103         eapply_user
104 }
105
106 src_configure() {
107         # build the user-space tools, warnings are harmless
108         local cmd=(
109                 ./configure
110                 --nofatal
111                 --disable-xpcom
112                 --disable-sdl-ttf
113                 --disable-pulse
114                 --disable-alsa
115                 --with-gcc="$(tc-getCC)"
116                 --with-g++="$(tc-getCXX)"
117                 --target-arch=${ARCH}
118                 --with-linux="${KV_OUT_DIR}"
119                 --build-headless
120         )
121         echo "${cmd[@]}"
122         "${cmd[@]}" || die "configure failed"
123         source ./env.sh
124         export VBOX_GCC_OPT="${CFLAGS} ${CPPFLAGS}"
125 }
126
127 src_compile() {
128         MAKE="kmk" \
129         emake TOOL_YASM_AS=yasm \
130         VBOX_ONLY_ADDITIONS=1 \
131         KBUILD_VERBOSE=2
132
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
137 }
138
139 src_install() {
140         linux-mod_src_install
141
142         cd "${S}"/out/linux.${ARCH}/release/bin/additions || die
143
144         insinto /sbin
145         newins mount.vboxsf mount.vboxsf
146         fperms 4755 /sbin/mount.vboxsf
147
148         newinitd "${FILESDIR}"/${PN}-8.initd ${PN}
149
150         insinto /usr/sbin/
151         newins VBoxService vboxguest-service
152         fperms 0755 /usr/sbin/vboxguest-service
153
154         insinto /usr/bin
155         doins VBoxControl
156         fperms 0755 /usr/bin/VBoxControl
157
158         # VBoxClient user service and xrandr wrapper
159         if use X ; then
160                 doins VBoxClient
161                 fperms 0755 /usr/bin/VBoxClient
162
163                 pushd "${S}"/src/VBox/Additions/x11/Installer &>/dev/null \
164                         || die
165                 newins 98vboxadd-xclient VBoxClient-all
166                 fperms 0755 /usr/bin/VBoxClient-all
167                 popd &>/dev/null || die
168         fi
169
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" \
175                 || die
176         echo 'KERNEL=="vboxuser", OWNER="vboxguest", GROUP="vboxguest", MODE="0660"' \
177                 >> "${D}/${udev_rules_dir}/60-virtualbox-guest-additions.rules" \
178                 || die
179
180         # VBoxClient autostart file
181         insinto /etc/xdg/autostart
182         doins "${FILESDIR}"/vboxclient.desktop
183
184         # sample xorg.conf
185         insinto /usr/share/doc/${PF}
186         doins "${FILESDIR}"/xorg.conf.vbox
187
188         systemd_dounit "${FILESDIR}/${PN}.service"
189 }
190
191 pkg_postinst() {
192         linux-mod_pkg_postinst
193         if ! use X ; then
194                 elog "use flag X is off, enable it to install the"
195                 elog "X Window System video driver."
196         fi
197         elog ""
198         elog "Please add users to the \"vboxguest\" group so they can"
199         elog "benefit from seamless mode, auto-resize and clipboard."
200         elog ""
201         elog "The vboxsf group has been added to make automount services work."
202         elog "These services are part of the shared folders support."
203         elog ""
204         elog "Please add:"
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"
211         elog ""
212         elog "Also make sure you use the Mesa library for OpenGL:"
213         elog "    eselect opengl set xorg-x11"
214         elog ""
215         elog "An autostart .desktop file has been installed to start"
216         elog "VBoxClient in desktop sessions."
217         elog ""
218         elog "You can mount shared folders with:"
219         elog "    mount -t vboxsf <shared_folder_name> <mount_point>"
220         elog ""
221         elog "Warning:"
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."
225         elog ""
226 }