app-crypt/rhash: fix configure for Cygwin
[gentoo.git] / app-emulation / virtualbox-guest-additions / virtualbox-guest-additions-5.2.30.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit 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.2.16-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 "
34 DEPEND="
35         ${RDEPEND}
36         >=dev-util/kbuild-0.1.9998.3127
37         >=dev-lang/yasm-0.6.2
38         sys-devel/bin86
39         sys-libs/pam
40         sys-power/iasl
41         x11-base/xorg-proto
42 "
43 PDEPEND="
44         X? ( x11-drivers/xf86-video-vboxvideo )
45 "
46 BUILD_TARGETS="all"
47 BUILD_TARGET_ARCH="${ARCH}"
48
49 S="${WORKDIR}/${MY_P}"
50
51 pkg_setup() {
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)"
56
57         linux-mod_pkg_setup
58         BUILD_PARAMS="KERN_DIR=/lib/modules/${KV_FULL}/build KERNOUT=${KV_OUT_DIR}"
59 }
60
61 src_unpack() {
62         unpack ${A}
63
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
68
69         # Remove shipped binaries (kBuild,yasm), see bug #232775
70         cd "${S}"
71         rm -rf kBuild/bin tools
72 }
73
74 src_prepare() {
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
79
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
83
84         # stupid new header references...
85         local vboxheader mdir
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}"
90                 done
91         done
92
93         # Remove pointless GCC version check
94         sed -e '/^check_gcc$/d' -i configure || die
95
96         rm "${WORKDIR}/patches/008_virtualbox-4.3.14-missing_define.patch" || die
97         eapply "${WORKDIR}/patches"
98
99         eapply_user
100 }
101
102 src_configure() {
103         # build the user-space tools, warnings are harmless
104         local cmd=(
105                 ./configure
106                 --nofatal
107                 --disable-xpcom
108                 --disable-sdl-ttf
109                 --disable-pulse
110                 --disable-alsa
111                 --with-gcc="$(tc-getCC)"
112                 --with-g++="$(tc-getCXX)"
113                 --target-arch=${ARCH}
114                 --with-linux="${KV_OUT_DIR}"
115                 --build-headless
116         )
117         echo "${cmd[@]}"
118         "${cmd[@]}" || die "configure failed"
119         source ./env.sh
120         export VBOX_GCC_OPT="${CFLAGS} ${CPPFLAGS}"
121 }
122
123 src_compile() {
124         MAKE="kmk" \
125         emake TOOL_YASM_AS=yasm \
126         VBOX_ONLY_ADDITIONS=1 \
127         KBUILD_VERBOSE=2
128
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
133 }
134
135 src_install() {
136         linux-mod_src_install
137
138         cd "${S}"/out/linux.${ARCH}/release/bin/additions || die
139
140         insinto /sbin
141         newins mount.vboxsf mount.vboxsf
142         fperms 4755 /sbin/mount.vboxsf
143
144         newinitd "${FILESDIR}"/${PN}-8.initd ${PN}
145
146         insinto /usr/sbin/
147         newins VBoxService vboxguest-service
148         fperms 0755 /usr/sbin/vboxguest-service
149
150         insinto /usr/bin
151         doins VBoxControl
152         fperms 0755 /usr/bin/VBoxControl
153
154         # VBoxClient user service and xrandr wrapper
155         if use X ; then
156                 doins VBoxClient
157                 fperms 0755 /usr/bin/VBoxClient
158
159                 pushd "${S}"/src/VBox/Additions/x11/Installer &>/dev/null \
160                         || die
161                 newins 98vboxadd-xclient VBoxClient-all
162                 fperms 0755 /usr/bin/VBoxClient-all
163                 popd &>/dev/null || die
164         fi
165
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" \
171                 || die
172         echo 'KERNEL=="vboxuser", OWNER="vboxguest", GROUP="vboxguest", MODE="0660"' \
173                 >> "${ED%/}/${udev_rules_dir}/60-virtualbox-guest-additions.rules" \
174                 || die
175
176         # VBoxClient autostart file
177         insinto /etc/xdg/autostart
178         doins "${FILESDIR}"/vboxclient.desktop
179
180         # sample xorg.conf
181         insinto /usr/share/doc/${PF}
182         doins "${FILESDIR}"/xorg.conf.vbox
183
184         systemd_dounit "${FILESDIR}/${PN}.service"
185 }
186
187 pkg_preinst() {
188         enewgroup vboxguest
189         enewuser vboxguest -1 /bin/sh /dev/null vboxguest
190         # automount Error: VBoxServiceAutoMountWorker: Group "vboxsf" does not exist
191         enewgroup vboxsf
192 }
193
194 pkg_postinst() {
195         linux-mod_pkg_postinst
196         if ! use X ; then
197                 elog "use flag X is off, enable it to install the"
198                 elog "X Window System video driver."
199         fi
200         elog ""
201         elog "Please add users to the \"vboxguest\" group so they can"
202         elog "benefit from seamless mode, auto-resize and clipboard."
203         elog ""
204         elog "The vboxsf group has been added to make automount services work."
205         elog "These services are part of the shared folders support."
206         elog ""
207         elog "Please add:"
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"
214         elog ""
215         elog "Also make sure you use the Mesa library for OpenGL:"
216         elog "    eselect opengl set xorg-x11"
217         elog ""
218         elog "An autostart .desktop file has been installed to start"
219         elog "VBoxClient in desktop sessions."
220         elog ""
221         elog "You can mount shared folders with:"
222         elog "    mount -t vboxsf <shared_folder_name> <mount_point>"
223         elog ""
224         elog "Warning:"
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."
228         elog ""
229 }