Gentoo Archives: gentoo-commits

From: Matthias Maier <tamiko@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-emulation/qemu/
Date: Wed, 12 Apr 2017 05:03:42
Message-Id: 1491973392.8b9a80ef2e08e673922ae6f76447a0cd97c7d842.tamiko@gentoo
1 commit: 8b9a80ef2e08e673922ae6f76447a0cd97c7d842
2 Author: Matthias Maier <tamiko <AT> gentoo <DOT> org>
3 AuthorDate: Wed Apr 12 04:29:06 2017 +0000
4 Commit: Matthias Maier <tamiko <AT> gentoo <DOT> org>
5 CommitDate: Wed Apr 12 05:03:12 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8b9a80ef
7
8 app-emulation/qemu: fix static dependencies, bug #614198
9
10 Oh *boy* what mess did I create with the last round of dependency fixes?
11
12 This commit puts back the old behavior of requiring only a subset of the
13 dependencies to be built with static-libs if USE=static-user is set.
14
15 Package-Manager: Portage-2.3.5, Repoman-2.3.2
16
17 app-emulation/qemu/qemu-2.8.0-r10.ebuild | 775 +++++++++++++++++++++++++++++++
18 1 file changed, 775 insertions(+)
19
20 diff --git a/app-emulation/qemu/qemu-2.8.0-r10.ebuild b/app-emulation/qemu/qemu-2.8.0-r10.ebuild
21 new file mode 100644
22 index 00000000000..8c8c3bdb820
23 --- /dev/null
24 +++ b/app-emulation/qemu/qemu-2.8.0-r10.ebuild
25 @@ -0,0 +1,775 @@
26 +# Copyright 1999-2017 Gentoo Foundation
27 +# Distributed under the terms of the GNU General Public License v2
28 +
29 +EAPI="6"
30 +
31 +PYTHON_COMPAT=( python2_7 )
32 +PYTHON_REQ_USE="ncurses,readline"
33 +
34 +PLOCALES="bg de_DE fr_FR hu it tr zh_CN"
35 +
36 +inherit eutils flag-o-matic linux-info toolchain-funcs multilib python-r1 \
37 + user udev fcaps readme.gentoo-r1 pax-utils l10n
38 +
39 +if [[ ${PV} = *9999* ]]; then
40 + EGIT_REPO_URI="git://git.qemu.org/qemu.git"
41 + inherit git-r3
42 + SRC_URI=""
43 +else
44 + SRC_URI="http://wiki.qemu-project.org/download/${P}.tar.bz2"
45 + KEYWORDS="~amd64 ~arm64 ~ppc ~ppc64 ~x86 ~x86-fbsd"
46 +fi
47 +
48 +# bug #606088
49 +SRC_URI+="
50 + https://dev.gentoo.org/~tamiko/distfiles/${P}-CVE-2016-9602-patches.tar.xz"
51 +
52 +DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
53 +HOMEPAGE="http://www.qemu.org http://www.linux-kvm.org"
54 +
55 +LICENSE="GPL-2 LGPL-2 BSD-2"
56 +SLOT="0"
57 +IUSE="accessibility +aio alsa bluetooth bzip2 +caps +curl debug +fdt
58 + glusterfs gnutls gtk gtk2 infiniband iscsi +jpeg kernel_linux
59 + kernel_FreeBSD lzo ncurses nfs nls numa opengl +pin-upstream-blobs +png
60 + pulseaudio python rbd sasl +seccomp sdl sdl2 selinux smartcard snappy
61 + spice ssh static static-user systemtap tci test +threads usb usbredir
62 + vde +vhost-net virgl virtfs +vnc vte xattr xen xfs"
63 +
64 +COMMON_TARGETS="aarch64 alpha arm cris i386 m68k microblaze microblazeel
65 + mips mips64 mips64el mipsel or32 ppc ppc64 s390x sh4 sh4eb sparc
66 + sparc64 x86_64"
67 +IUSE_SOFTMMU_TARGETS="${COMMON_TARGETS}
68 + lm32 moxie ppcemb tricore unicore32 xtensa xtensaeb"
69 +IUSE_USER_TARGETS="${COMMON_TARGETS}
70 + armeb mipsn32 mipsn32el ppc64abi32 ppc64le sparc32plus tilegx"
71 +
72 +use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS})
73 +use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
74 +IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
75 +
76 +# Allow no targets to be built so that people can get a tools-only build.
77 +# Block USE flag configurations known to not work.
78 +REQUIRED_USE="${PYTHON_REQUIRED_USE}
79 + gtk2? ( gtk )
80 + qemu_softmmu_targets_arm? ( fdt )
81 + qemu_softmmu_targets_microblaze? ( fdt )
82 + qemu_softmmu_targets_ppc? ( fdt )
83 + qemu_softmmu_targets_ppc64? ( fdt )
84 + sdl2? ( sdl )
85 + static? ( static-user !alsa !bluetooth !gtk !gtk2 !opengl !pulseaudio )
86 + virtfs? ( xattr )
87 + vte? ( gtk )"
88 +
89 +# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
90 +# and user/softmmu targets (qemu-*, qemu-system-*).
91 +#
92 +# Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
93 +#
94 +# The attr lib isn't always linked in (although the USE flag is always
95 +# respected). This is because qemu supports using the C library's API
96 +# when available rather than always using the extranl library.
97 +ALL_DEPEND="
98 + >=dev-libs/glib-2.0[static-libs(+)]
99 + >=x11-libs/pixman-0.28.0[static-libs(+)]
100 + sys-libs/zlib[static-libs(+)]
101 + python? ( ${PYTHON_DEPS} )
102 + systemtap? ( dev-util/systemtap )
103 + xattr? ( sys-apps/attr[static-libs(+)] )
104 + "
105 +
106 +# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
107 +# softmmu targets (qemu-system-*).
108 +SOFTMMU_TOOLS_DEPEND="
109 + accessibility? (
110 + app-accessibility/brltty[api]
111 + app-accessibility/brltty[static-libs(+)]
112 + )
113 + aio? ( dev-libs/libaio[static-libs(+)] )
114 + alsa? ( >=media-libs/alsa-lib-1.0.13 )
115 + bluetooth? ( net-wireless/bluez )
116 + bzip2? ( app-arch/bzip2[static-libs(+)] )
117 + caps? ( sys-libs/libcap-ng[static-libs(+)] )
118 + curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
119 + fdt? ( >=sys-apps/dtc-1.4.0[static-libs(+)] )
120 + glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
121 + gnutls? (
122 + dev-libs/nettle:=[static-libs(+)]
123 + >=net-libs/gnutls-3.0:=[static-libs(+)]
124 + )
125 + gtk? (
126 + gtk2? (
127 + x11-libs/gtk+:2
128 + vte? ( x11-libs/vte:0 )
129 + )
130 + !gtk2? (
131 + x11-libs/gtk+:3
132 + vte? ( x11-libs/vte:2.91 )
133 + )
134 + )
135 + infiniband? ( sys-fabric/librdmacm:=[static-libs(+)] )
136 + iscsi? ( net-libs/libiscsi )
137 + jpeg? ( virtual/jpeg:0=[static-libs(+)] )
138 + lzo? ( dev-libs/lzo:2[static-libs(+)] )
139 + ncurses? (
140 + sys-libs/ncurses:0=[unicode]
141 + sys-libs/ncurses:0=[static-libs(+)]
142 + )
143 + nfs? ( >=net-fs/libnfs-1.9.3[static-libs(+)] )
144 + numa? ( sys-process/numactl[static-libs(+)] )
145 + opengl? (
146 + virtual/opengl
147 + media-libs/libepoxy[static-libs(+)]
148 + media-libs/mesa[static-libs(+)]
149 + media-libs/mesa[egl,gbm]
150 + )
151 + png? ( media-libs/libpng:0=[static-libs(+)] )
152 + pulseaudio? ( media-sound/pulseaudio )
153 + rbd? ( sys-cluster/ceph[static-libs(+)] )
154 + sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
155 + sdl? (
156 + !sdl2? (
157 + media-libs/libsdl[X]
158 + >=media-libs/libsdl-1.2.11[static-libs(+)]
159 + )
160 + sdl2? (
161 + media-libs/libsdl2[X]
162 + media-libs/libsdl2[static-libs(+)]
163 + )
164 + )
165 + seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
166 + smartcard? ( >=app-emulation/libcacard-2.5.0[static-libs(+)] )
167 + snappy? ( app-arch/snappy[static-libs(+)] )
168 + spice? (
169 + >=app-emulation/spice-protocol-0.12.3
170 + >=app-emulation/spice-0.12.0[static-libs(+)]
171 + )
172 + ssh? ( >=net-libs/libssh2-1.2.8[static-libs(+)] )
173 + usb? ( >=virtual/libusb-1-r2[static-libs(+)] )
174 + usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
175 + vde? ( net-misc/vde[static-libs(+)] )
176 + virgl? ( media-libs/virglrenderer[static-libs(+)] )
177 + virtfs? ( sys-libs/libcap )
178 + xen? ( app-emulation/xen-tools:= )
179 + xfs? ( sys-fs/xfsprogs[static-libs(+)] )
180 +"
181 +
182 +X86_FIRMWARE_DEPEND="
183 + >=sys-firmware/ipxe-1.0.0_p20130624
184 + pin-upstream-blobs? (
185 + ~sys-firmware/seabios-1.10.1
186 + ~sys-firmware/sgabios-0.1_pre8
187 + ~sys-firmware/vgabios-0.7a
188 + )
189 + !pin-upstream-blobs? (
190 + sys-firmware/seabios
191 + sys-firmware/sgabios
192 + sys-firmware/vgabios
193 + )"
194 +
195 +CDEPEND="
196 + !static? (
197 + ${ALL_DEPEND//\[static-libs(+)]}
198 + ${SOFTMMU_TOOLS_DEPEND//\[static-libs(+)]}
199 + )
200 + qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
201 + qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )"
202 +DEPEND="${CDEPEND}
203 + dev-lang/perl
204 + =dev-lang/python-2*
205 + sys-apps/texinfo
206 + virtual/pkgconfig
207 + kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
208 + gtk? ( nls? ( sys-devel/gettext ) )
209 + static? (
210 + ${ALL_DEPEND}
211 + ${SOFTMMU_TOOLS_DEPEND}
212 + )
213 + static-user? ( ${ALL_DEPEND} )
214 + test? (
215 + dev-libs/glib[utils]
216 + sys-devel/bc
217 + )"
218 +RDEPEND="${CDEPEND}
219 + selinux? ( sec-policy/selinux-qemu )"
220 +
221 +PATCHES=(
222 + "${FILESDIR}"/${PN}-2.5.0-cflags.patch
223 + "${FILESDIR}"/${PN}-2.5.0-sysmacros.patch
224 + "${FILESDIR}"/${PN}-2.7.0-CVE-2016-8669-1.patch #597108
225 + "${FILESDIR}"/${PN}-2.8.0-CVE-2016-9908.patch #601826
226 + "${FILESDIR}"/${PN}-2.8.0-CVE-2016-9912.patch #602630
227 + "${FILESDIR}"/${PN}-2.8.0-CVE-2016-10028.patch #603444
228 + "${FILESDIR}"/${PN}-2.8.0-CVE-2016-10155.patch #606720
229 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-2615.patch #608034
230 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-2630.patch #609396
231 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-5525-1.patch #606264
232 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-5525-2.patch
233 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-5552.patch #606722
234 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-5578.patch #607000
235 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-5579.patch #607100
236 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-5667.patch #607766
237 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-5856.patch #608036
238 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-5857.patch #608038
239 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-5898.patch #608520
240 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-5931.patch #608728
241 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-5973.patch #609334
242 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-5987.patch #609398
243 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-6058.patch #609638
244 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-2620.patch #609206
245 + "${FILESDIR}"/${PN}-2.8.0-CVE-2017-6505.patch #612220
246 + "${S}-CVE-2016-9602-patches"
247 +)
248 +
249 +STRIP_MASK="/usr/share/qemu/palcode-clipper"
250 +
251 +QA_PREBUILT="
252 + usr/share/qemu/openbios-ppc
253 + usr/share/qemu/openbios-sparc64
254 + usr/share/qemu/openbios-sparc32
255 + usr/share/qemu/palcode-clipper
256 + usr/share/qemu/s390-ccw.img
257 + usr/share/qemu/u-boot.e500"
258 +
259 +QA_WX_LOAD="usr/bin/qemu-i386
260 + usr/bin/qemu-x86_64
261 + usr/bin/qemu-alpha
262 + usr/bin/qemu-arm
263 + usr/bin/qemu-cris
264 + usr/bin/qemu-m68k
265 + usr/bin/qemu-microblaze
266 + usr/bin/qemu-microblazeel
267 + usr/bin/qemu-mips
268 + usr/bin/qemu-mipsel
269 + usr/bin/qemu-or32
270 + usr/bin/qemu-ppc
271 + usr/bin/qemu-ppc64
272 + usr/bin/qemu-ppc64abi32
273 + usr/bin/qemu-sh4
274 + usr/bin/qemu-sh4eb
275 + usr/bin/qemu-sparc
276 + usr/bin/qemu-sparc64
277 + usr/bin/qemu-armeb
278 + usr/bin/qemu-sparc32plus
279 + usr/bin/qemu-s390x
280 + usr/bin/qemu-unicore32"
281 +
282 +DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure you have the
283 +kernel module loaded before running kvm. The easiest way to ensure that the
284 +kernel module is loaded is to load it on boot.
285 + For AMD CPUs the module is called 'kvm-amd'.
286 + For Intel CPUs the module is called 'kvm-intel'.
287 +Please review /etc/conf.d/modules for how to load these.
288 +
289 +Make sure your user is in the 'kvm' group. Just run
290 + $ gpasswd -a <USER> kvm
291 +then have <USER> re-login.
292 +
293 +For brand new installs, the default permissions on /dev/kvm might not let
294 +you access it. You can tell udev to reset ownership/perms:
295 + $ udevadm trigger -c add /dev/kvm
296 +
297 +If you want to register binfmt handlers for qemu user targets:
298 +For openrc:
299 + # rc-update add qemu-binfmt
300 +For systemd:
301 + # ln -s /usr/share/qemu/binfmt.d/qemu.conf /etc/binfmt.d/qemu.conf"
302 +
303 +pkg_pretend() {
304 + if use kernel_linux && kernel_is lt 2 6 25; then
305 + eerror "This version of KVM requres a host kernel of 2.6.25 or higher."
306 + elif use kernel_linux; then
307 + if ! linux_config_exists; then
308 + eerror "Unable to check your kernel for KVM support"
309 + else
310 + CONFIG_CHECK="~KVM ~TUN ~BRIDGE"
311 + ERROR_KVM="You must enable KVM in your kernel to continue"
312 + ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in"
313 + ERROR_KVM_AMD+=" your kernel configuration."
314 + ERROR_KVM_INTEL="If you have an Intel CPU, you must enable"
315 + ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration."
316 + ERROR_TUN="You will need the Universal TUN/TAP driver compiled"
317 + ERROR_TUN+=" into your kernel or loaded as a module to use the"
318 + ERROR_TUN+=" virtual network device if using -net tap."
319 + ERROR_BRIDGE="You will also need support for 802.1d"
320 + ERROR_BRIDGE+=" Ethernet Bridging for some network configurations."
321 + use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
322 + ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
323 + ERROR_VHOST_NET+=" support"
324 +
325 + if use amd64 || use x86 || use amd64-linux || use x86-linux; then
326 + CONFIG_CHECK+=" ~KVM_AMD ~KVM_INTEL"
327 + fi
328 +
329 + use python && CONFIG_CHECK+=" ~DEBUG_FS"
330 + ERROR_DEBUG_FS="debugFS support required for kvm_stat"
331 +
332 + # Now do the actual checks setup above
333 + check_extra_config
334 + fi
335 + fi
336 +
337 + if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
338 + eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt"
339 + eerror "instances are still pointing to it. Please update your"
340 + eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag"
341 + eerror "and the right system binary (e.g. qemu-system-x86_64)."
342 + die "update your virt configs to not use qemu-kvm"
343 + fi
344 +}
345 +
346 +pkg_setup() {
347 + enewgroup kvm 78
348 +}
349 +
350 +# Sanity check to make sure target lists are kept up-to-date.
351 +check_targets() {
352 + local var=$1 mak=$2
353 + local detected sorted
354 +
355 + pushd "${S}"/default-configs >/dev/null || die
356 +
357 + # Force C locale until glibc is updated. #564936
358 + detected=$(echo $(printf '%s\n' *-${mak}.mak | sed "s:-${mak}.mak::" | LC_COLLATE=C sort -u))
359 + sorted=$(echo $(printf '%s\n' ${!var} | LC_COLLATE=C sort -u))
360 + if [[ ${sorted} != "${detected}" ]] ; then
361 + eerror "The ebuild needs to be kept in sync."
362 + eerror "${var}: ${sorted}"
363 + eerror "$(printf '%-*s' ${#var} configure): ${detected}"
364 + die "sync ${var} to the list of targets"
365 + fi
366 +
367 + popd >/dev/null
368 +}
369 +
370 +handle_locales() {
371 + # Make sure locale list is kept up-to-date.
372 + local detected sorted
373 + detected=$(echo $(cd po && printf '%s\n' *.po | grep -v messages.po | sed 's:.po$::' | sort -u))
374 + sorted=$(echo $(printf '%s\n' ${PLOCALES} | sort -u))
375 + if [[ ${sorted} != "${detected}" ]] ; then
376 + eerror "The ebuild needs to be kept in sync."
377 + eerror "PLOCALES: ${sorted}"
378 + eerror " po/*.po: ${detected}"
379 + die "sync PLOCALES"
380 + fi
381 +
382 + # Deal with selective install of locales.
383 + if use nls ; then
384 + # Delete locales the user does not want. #577814
385 + rm_loc() { rm po/$1.po || die; }
386 + l10n_for_each_disabled_locale_do rm_loc
387 + else
388 + # Cheap hack to disable gettext .mo generation.
389 + rm -f po/*.po
390 + fi
391 +}
392 +
393 +src_prepare() {
394 + check_targets IUSE_SOFTMMU_TARGETS softmmu
395 + check_targets IUSE_USER_TARGETS linux-user
396 +
397 + # Alter target makefiles to accept CFLAGS set via flag-o
398 + sed -i -r \
399 + -e 's/^(C|OP_C|HELPER_C)FLAGS=/\1FLAGS+=/' \
400 + Makefile Makefile.target || die
401 +
402 + default
403 +
404 + # Fix ld and objcopy being called directly
405 + tc-export AR LD OBJCOPY
406 +
407 + # Verbose builds
408 + MAKEOPTS+=" V=1"
409 +
410 + # Run after we've applied all patches.
411 + handle_locales
412 +}
413 +
414 +##
415 +# configures qemu based on the build directory and the build type
416 +# we are using.
417 +#
418 +qemu_src_configure() {
419 + debug-print-function ${FUNCNAME} "$@"
420 +
421 + local buildtype=$1
422 + local builddir="${S}/${buildtype}-build"
423 +
424 + mkdir "${builddir}"
425 +
426 + local conf_opts=(
427 + --prefix=/usr
428 + --sysconfdir=/etc
429 + --libdir=/usr/$(get_libdir)
430 + --docdir=/usr/share/doc/${PF}/html
431 + --disable-bsd-user
432 + --disable-guest-agent
433 + --disable-strip
434 + --disable-werror
435 + # We support gnutls/nettle for crypto operations. It is possible
436 + # to use gcrypt when gnutls/nettle are disabled (but not when they
437 + # are enabled), but it's not really worth the hassle. Disable it
438 + # all the time to avoid automatically detecting it. #568856
439 + --disable-gcrypt
440 + --python="${PYTHON}"
441 + --cc="$(tc-getCC)"
442 + --cxx="$(tc-getCXX)"
443 + --host-cc="$(tc-getBUILD_CC)"
444 + $(use_enable debug debug-info)
445 + $(use_enable debug debug-tcg)
446 + --enable-docs
447 + $(use_enable tci tcg-interpreter)
448 + $(use_enable xattr attr)
449 + )
450 +
451 + # Disable options not used by user targets. This simplifies building
452 + # static user targets (USE=static-user) considerably.
453 + conf_notuser() {
454 + if [[ ${buildtype} == "user" ]] ; then
455 + echo "--disable-${2:-$1}"
456 + else
457 + use_enable "$@"
458 + fi
459 + }
460 + conf_opts+=(
461 + $(conf_notuser accessibility brlapi)
462 + $(conf_notuser aio linux-aio)
463 + $(conf_notuser bzip2)
464 + $(conf_notuser bluetooth bluez)
465 + $(conf_notuser caps cap-ng)
466 + $(conf_notuser curl)
467 + $(conf_notuser fdt)
468 + $(conf_notuser glusterfs)
469 + $(conf_notuser gnutls)
470 + $(conf_notuser gnutls nettle)
471 + $(conf_notuser gtk)
472 + $(conf_notuser infiniband rdma)
473 + $(conf_notuser iscsi libiscsi)
474 + $(conf_notuser jpeg vnc-jpeg)
475 + $(conf_notuser kernel_linux kvm)
476 + $(conf_notuser lzo)
477 + $(conf_notuser ncurses curses)
478 + $(conf_notuser nfs libnfs)
479 + $(conf_notuser numa)
480 + $(conf_notuser opengl)
481 + $(conf_notuser png vnc-png)
482 + $(conf_notuser rbd)
483 + $(conf_notuser sasl vnc-sasl)
484 + $(conf_notuser sdl)
485 + $(conf_notuser seccomp)
486 + $(conf_notuser smartcard)
487 + $(conf_notuser snappy)
488 + $(conf_notuser spice)
489 + $(conf_notuser ssh libssh2)
490 + $(conf_notuser usb libusb)
491 + $(conf_notuser usbredir usb-redir)
492 + $(conf_notuser vde)
493 + $(conf_notuser vhost-net)
494 + $(conf_notuser virgl virglrenderer)
495 + $(conf_notuser virtfs)
496 + $(conf_notuser vnc)
497 + $(conf_notuser vte)
498 + $(conf_notuser xen)
499 + $(conf_notuser xen xen-pci-passthrough)
500 + $(conf_notuser xfs xfsctl)
501 + )
502 +
503 + if [[ ! ${buildtype} == "user" ]] ; then
504 + # audio options
505 + local audio_opts="oss"
506 + use alsa && audio_opts="alsa,${audio_opts}"
507 + use sdl && audio_opts="sdl,${audio_opts}"
508 + use pulseaudio && audio_opts="pa,${audio_opts}"
509 + conf_opts+=(
510 + --audio-drv-list="${audio_opts}"
511 + )
512 + use gtk && conf_opts+=( --with-gtkabi=$(usex gtk2 2.0 3.0) )
513 + use sdl && conf_opts+=( --with-sdlabi=$(usex sdl2 2.0 1.2) )
514 + fi
515 +
516 + case ${buildtype} in
517 + user)
518 + conf_opts+=(
519 + --enable-linux-user
520 + --disable-system
521 + --disable-blobs
522 + --disable-tools
523 + )
524 + local static_flag="static-user"
525 + ;;
526 + softmmu)
527 + conf_opts+=(
528 + --disable-linux-user
529 + --enable-system
530 + --disable-tools
531 + --with-system-pixman
532 + )
533 + local static_flag="static"
534 + ;;
535 + tools)
536 + conf_opts+=(
537 + --disable-linux-user
538 + --disable-system
539 + --disable-blobs
540 + --enable-tools
541 + )
542 + local static_flag="static"
543 + ;;
544 + esac
545 +
546 + local targets="${buildtype}_targets"
547 + [[ -n ${targets} ]] && conf_opts+=( --target-list="${!targets}" )
548 +
549 + # Add support for SystemTAP
550 + use systemtap && conf_opts+=( --enable-trace-backend=dtrace )
551 +
552 + # We always want to attempt to build with PIE support as it results
553 + # in a more secure binary. But it doesn't work with static or if
554 + # the current GCC doesn't have PIE support.
555 + if use ${static_flag}; then
556 + conf_opts+=( --static --disable-pie )
557 + else
558 + gcc-specs-pie && conf_opts+=( --enable-pie )
559 + fi
560 +
561 + echo "../configure ${conf_opts[*]}"
562 + cd "${builddir}"
563 + ../configure "${conf_opts[@]}" || die "configure failed"
564 +
565 + # FreeBSD's kernel does not support QEMU assigning/grabbing
566 + # host USB devices yet
567 + use kernel_FreeBSD && \
568 + sed -i -E -e "s|^(HOST_USB=)bsd|\1stub|" "${S}"/config-host.mak
569 +}
570 +
571 +src_configure() {
572 + local target
573 +
574 + python_setup
575 +
576 + softmmu_targets= softmmu_bins=()
577 + user_targets= user_bins=()
578 +
579 + for target in ${IUSE_SOFTMMU_TARGETS} ; do
580 + if use "qemu_softmmu_targets_${target}"; then
581 + softmmu_targets+=",${target}-softmmu"
582 + softmmu_bins+=( "qemu-system-${target}" )
583 + fi
584 + done
585 +
586 + for target in ${IUSE_USER_TARGETS} ; do
587 + if use "qemu_user_targets_${target}"; then
588 + user_targets+=",${target}-linux-user"
589 + user_bins+=( "qemu-${target}" )
590 + fi
591 + done
592 +
593 + softmmu_targets=${softmmu_targets#,}
594 + user_targets=${user_targets#,}
595 +
596 + [[ -n ${softmmu_targets} ]] && qemu_src_configure "softmmu"
597 + [[ -n ${user_targets} ]] && qemu_src_configure "user"
598 + qemu_src_configure "tools"
599 +}
600 +
601 +src_compile() {
602 + if [[ -n ${user_targets} ]]; then
603 + cd "${S}/user-build"
604 + default
605 + fi
606 +
607 + if [[ -n ${softmmu_targets} ]]; then
608 + cd "${S}/softmmu-build"
609 + default
610 + fi
611 +
612 + cd "${S}/tools-build"
613 + default
614 +}
615 +
616 +src_test() {
617 + if [[ -n ${softmmu_targets} ]]; then
618 + cd "${S}/softmmu-build"
619 + pax-mark m */qemu-system-* #515550
620 + emake -j1 check
621 + emake -j1 check-report.html
622 + fi
623 +}
624 +
625 +qemu_python_install() {
626 + python_domodule "${S}/scripts/qmp/qmp.py"
627 +
628 + python_doscript "${S}/scripts/kvm/vmxcap"
629 + python_doscript "${S}/scripts/qmp/qmp-shell"
630 + python_doscript "${S}/scripts/qmp/qemu-ga-client"
631 +}
632 +
633 +# Generate binfmt support files.
634 +# - /etc/init.d/qemu-binfmt script which registers the user handlers (openrc)
635 +# - /usr/share/qemu/binfmt.d/qemu.conf (for use with systemd-binfmt)
636 +generate_initd() {
637 + local out="${T}/qemu-binfmt"
638 + local out_systemd="${T}/qemu.conf"
639 + local d="${T}/binfmt.d"
640 +
641 + einfo "Generating qemu binfmt scripts and configuration files"
642 +
643 + # Generate the debian fragments first.
644 + mkdir -p "${d}"
645 + "${S}"/scripts/qemu-binfmt-conf.sh \
646 + --debian \
647 + --exportdir "${d}" \
648 + --qemu-path "${EPREFIX}/usr/bin" \
649 + || die
650 + # Then turn the fragments into a shell script we can source.
651 + sed -E -i \
652 + -e 's:^([^ ]+) (.*)$:\1="\2":' \
653 + "${d}"/* || die
654 +
655 + # Generate the init.d script by assembling the fragments from above.
656 + local f qcpu package interpreter magic mask
657 + cat "${FILESDIR}"/qemu-binfmt.initd.head >"${out}" || die
658 + for f in "${d}"/qemu-* ; do
659 + source "${f}"
660 +
661 + # Normalize the cpu logic like we do in the init.d for the native cpu.
662 + qcpu=${package#qemu-}
663 + case ${qcpu} in
664 + arm*) qcpu="arm";;
665 + mips*) qcpu="mips";;
666 + ppc*) qcpu="ppc";;
667 + s390*) qcpu="s390";;
668 + sh*) qcpu="sh";;
669 + sparc*) qcpu="sparc";;
670 + esac
671 +
672 + cat <<EOF >>"${out}"
673 + if [ "\${cpu}" != "${qcpu}" -a -x "${interpreter}" ] ; then
674 + echo ':${package}:M::${magic}:${mask}:${interpreter}:'"\${QEMU_BINFMT_FLAGS}" >/proc/sys/fs/binfmt_misc/register
675 + fi
676 +EOF
677 +
678 + echo ":${package}:M::${magic}:${mask}:${interpreter}:OC" >>"${out_systemd}"
679 +
680 + done
681 + cat "${FILESDIR}"/qemu-binfmt.initd.tail >>"${out}" || die
682 +}
683 +
684 +src_install() {
685 + if [[ -n ${user_targets} ]]; then
686 + cd "${S}/user-build"
687 + emake DESTDIR="${ED}" install
688 +
689 + # Install binfmt handler init script for user targets.
690 + generate_initd
691 + doinitd "${T}/qemu-binfmt"
692 +
693 + # Install binfmt/qemu.conf.
694 + insinto "/usr/share/qemu/binfmt.d"
695 + doins "${T}/qemu.conf"
696 + fi
697 +
698 + if [[ -n ${softmmu_targets} ]]; then
699 + cd "${S}/softmmu-build"
700 + emake DESTDIR="${ED}" install
701 +
702 + # This might not exist if the test failed. #512010
703 + [[ -e check-report.html ]] && dohtml check-report.html
704 +
705 + if use kernel_linux; then
706 + udev_newrules "${FILESDIR}"/65-kvm.rules-r1 65-kvm.rules
707 + fi
708 +
709 + if use python; then
710 + python_foreach_impl qemu_python_install
711 + fi
712 + fi
713 +
714 + cd "${S}/tools-build"
715 + emake DESTDIR="${ED}" install
716 +
717 + # Disable mprotect on the qemu binaries as they use JITs to be fast #459348
718 + pushd "${ED}"/usr/bin >/dev/null
719 + pax-mark mr "${softmmu_bins[@]}" "${user_bins[@]}" # bug 575594
720 + popd >/dev/null
721 +
722 + # Install config file example for qemu-bridge-helper
723 + insinto "/etc/qemu"
724 + doins "${FILESDIR}/bridge.conf"
725 +
726 + # Remove the docdir placed qmp-commands.txt
727 + mv "${ED}/usr/share/doc/${PF}/html/qmp-commands.txt" "${S}/docs/" || die
728 +
729 + cd "${S}"
730 + dodoc Changelog MAINTAINERS docs/specs/pci-ids.txt
731 + newdoc pc-bios/README README.pc-bios
732 + dodoc docs/qmp-*.txt
733 +
734 + if [[ -n ${softmmu_targets} ]]; then
735 + # Remove SeaBIOS since we're using the SeaBIOS packaged one
736 + rm "${ED}/usr/share/qemu/bios.bin"
737 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
738 + dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
739 + fi
740 +
741 + # Remove vgabios since we're using the vgabios packaged one
742 + rm "${ED}/usr/share/qemu/vgabios.bin"
743 + rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
744 + rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
745 + rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
746 + rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
747 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
748 + dosym ../vgabios/vgabios.bin /usr/share/qemu/vgabios.bin
749 + dosym ../vgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
750 + dosym ../vgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
751 + dosym ../vgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
752 + dosym ../vgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
753 + fi
754 +
755 + # Remove sgabios since we're using the sgabios packaged one
756 + rm "${ED}/usr/share/qemu/sgabios.bin"
757 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
758 + dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
759 + fi
760 +
761 + # Remove iPXE since we're using the iPXE packaged one
762 + rm "${ED}"/usr/share/qemu/pxe-*.rom
763 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
764 + dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
765 + dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
766 + dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
767 + dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
768 + dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
769 + dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
770 + fi
771 + fi
772 +
773 + DISABLE_AUTOFORMATTING=true
774 + readme.gentoo_create_doc
775 +}
776 +
777 +pkg_postinst() {
778 + DISABLE_AUTOFORMATTING=true
779 + FORCE_PRINT_ELOG=1 # remove for next version bump
780 + readme.gentoo_print_elog
781 +
782 + if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
783 + udev_reload
784 + fi
785 +
786 + fcaps cap_net_admin /usr/libexec/qemu-bridge-helper
787 +}
788 +
789 +pkg_info() {
790 + echo "Using:"
791 + echo " $(best_version app-emulation/spice-protocol)"
792 + echo " $(best_version sys-firmware/ipxe)"
793 + echo " $(best_version sys-firmware/seabios)"
794 + if has_version 'sys-firmware/seabios[binary]'; then
795 + echo " USE=binary"
796 + else
797 + echo " USE=''"
798 + fi
799 + echo " $(best_version sys-firmware/vgabios)"
800 +}