Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-emulation/qemu/
Date: Thu, 17 Dec 2015 15:12:52
Message-Id: 1450365157.bf3c2e3023804fc32ef37bbda5d804550f14eec6.vapier@gentoo
1 commit: bf3c2e3023804fc32ef37bbda5d804550f14eec6
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Thu Dec 17 14:55:03 2015 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Thu Dec 17 15:12:37 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bf3c2e30
7
8 app-emulation/qemu: version bump to 2.5.0
9
10 app-emulation/qemu/Manifest | 1 +
11 app-emulation/qemu/qemu-2.5.0.ebuild | 645 +++++++++++++++++++++++++++++++++++
12 2 files changed, 646 insertions(+)
13
14 diff --git a/app-emulation/qemu/Manifest b/app-emulation/qemu/Manifest
15 index 861b373..91125c9 100644
16 --- a/app-emulation/qemu/Manifest
17 +++ b/app-emulation/qemu/Manifest
18 @@ -3,3 +3,4 @@ DIST qemu-2.3.1.tar.bz2 24692020 SHA256 661d029809421cae06b4b1bc74ac0e560cb4ed47
19 DIST qemu-2.4.0.1.tar.bz2 25068555 SHA256 ecfe8b88037e41e817d72c460c56c6a0b573d540d6ba38b162d0de4fd22d1bdb SHA512 08eabe92fa9096386ef00f8e9d99eeec1508d15e5a98431e043a729cbaca2d96d6e3afc612e7c4a0fe5a6bba80006276185f1066b4c73105b2ea24b7e9133b84 WHIRLPOOL 1daaec23d6ada6af8bf4902e590fb96375e7149d2f53ff6bf6d8fb39722c182a2d2efcc0d40bee673a8316f621983c512daa54202bb4e632b3a4b09f0268cd09
20 DIST qemu-2.4.0.tar.bz2 25070979 SHA256 72b0b991bbcc540663a019e1e8c4f714053b691dda32c9b9ee80b25f367e6620 SHA512 8740e0fb2c654ed897dff4649f1f83d14d57cfa9cbde723899f115982f93253ce9a2bddd60aab379d241027d2044137770efe4c0b3c83d5b20f3a2a06f05a5dc WHIRLPOOL 8c6cfae096624e01f0d5daeb86aa2dccbeaa86d2aeab626cf55cf20b7edace82d0b0f3a1d85eeb2dc1fd53abaaa9dccf8f0d7ddc657a1f5ffd72fd68301648f1
21 DIST qemu-2.4.1.tar.bz2 25087522 SHA256 e3d5cf4c8b1f9129c9c797329a515bfb6b3b1ded0ab8b394c8a316490fe3a177 SHA512 fde32b71a50d888c1055e61f4e6dfc45bb97e8e9ebee490c545965fbdcbd5ffd859fbf20648abed1f4fa9fcc5635e9b22e1829bbe802fc8aaf989d6013235917 WHIRLPOOL a698cfa5d2d138eeddb3c6bea57e3b89ca5d47165c04ed1cfd66a81647ac59cbdd594c919abef67bf198278da1160c5b9f3a0da84cd73827f3eb19a6e6f05436
22 +DIST qemu-2.5.0.tar.bz2 25464996 SHA256 3443887401619fe33bfa5d900a4f2d6a79425ae2b7e43d5b8c36eb7a683772d4 SHA512 12153f94cc7f834fd6a85f25690c36f2331d88d414426fb8b9ac20a34e6f9222b1eda30b727674af583580fae90dfd6d0614a905dce1567d94cd049d426b9dd3 WHIRLPOOL 8f5717989d8d234ecf1763ee386b2e1f20c3b17918de130c6dae255e4523a230b2b01a759eba25e4b9f604c680d9b868c56f58bd71b7c6c2c22a2e46804435ef
23
24 diff --git a/app-emulation/qemu/qemu-2.5.0.ebuild b/app-emulation/qemu/qemu-2.5.0.ebuild
25 new file mode 100644
26 index 0000000..249a20a
27 --- /dev/null
28 +++ b/app-emulation/qemu/qemu-2.5.0.ebuild
29 @@ -0,0 +1,645 @@
30 +# Copyright 1999-2015 Gentoo Foundation
31 +# Distributed under the terms of the GNU General Public License v2
32 +# $Id$
33 +
34 +EAPI=5
35 +
36 +PYTHON_COMPAT=( python2_7 )
37 +PYTHON_REQ_USE="ncurses,readline"
38 +
39 +inherit eutils flag-o-matic linux-info toolchain-funcs multilib python-r1 \
40 + user udev fcaps readme.gentoo pax-utils
41 +
42 +BACKPORTS=
43 +
44 +if [[ ${PV} = *9999* ]]; then
45 + EGIT_REPO_URI="git://git.qemu.org/qemu.git"
46 + inherit git-2
47 + SRC_URI=""
48 +else
49 + SRC_URI="http://wiki.qemu-project.org/download/${P}.tar.bz2
50 + ${BACKPORTS:+
51 + https://dev.gentoo.org/~cardoe/distfiles/${P}-${BACKPORTS}.tar.xz}"
52 + KEYWORDS="~amd64 ~ppc ~ppc64 ~x86 ~x86-fbsd"
53 +fi
54 +
55 +DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
56 +HOMEPAGE="http://www.qemu.org http://www.linux-kvm.org"
57 +
58 +LICENSE="GPL-2 LGPL-2 BSD-2"
59 +SLOT="0"
60 +IUSE="accessibility +aio alsa bluetooth +caps +curl debug +fdt glusterfs \
61 +gnutls gtk gtk2 infiniband iscsi +jpeg \
62 +kernel_linux kernel_FreeBSD lzo ncurses nfs nls numa opengl +pin-upstream-blobs
63 ++png pulseaudio python \
64 +rbd sasl +seccomp sdl sdl2 selinux smartcard snappy spice ssh static static-softmmu
65 +static-user systemtap tci test +threads usb usbredir +uuid vde +vhost-net \
66 +virgl virtfs +vnc vte xattr xen xfs"
67 +
68 +COMMON_TARGETS="aarch64 alpha arm cris i386 m68k microblaze microblazeel mips
69 +mips64 mips64el mipsel or32 ppc ppc64 s390x sh4 sh4eb sparc sparc64 unicore32
70 +x86_64"
71 +IUSE_SOFTMMU_TARGETS="${COMMON_TARGETS} lm32 moxie ppcemb tricore xtensa xtensaeb"
72 +IUSE_USER_TARGETS="${COMMON_TARGETS} armeb mipsn32 mipsn32el ppc64abi32 ppc64le sparc32plus tilegx"
73 +
74 +use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS})
75 +use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
76 +IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
77 +
78 +# Allow no targets to be built so that people can get a tools-only build.
79 +# Block USE flag configurations known to not work.
80 +REQUIRED_USE="${PYTHON_REQUIRED_USE}
81 + gtk2? ( gtk )
82 + qemu_softmmu_targets_arm? ( fdt )
83 + qemu_softmmu_targets_microblaze? ( fdt )
84 + qemu_softmmu_targets_ppc? ( fdt )
85 + qemu_softmmu_targets_ppc64? ( fdt )
86 + sdl2? ( sdl )
87 + static? ( static-softmmu static-user )
88 + static-softmmu? ( !alsa !pulseaudio !bluetooth !opengl !gtk !gtk2 )
89 + virtfs? ( xattr )
90 + vte? ( gtk )"
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 +#
98 +# Older versions of gnutls are supported, but it's simpler to just require
99 +# the latest versions. This is also why we require nettle.
100 +COMMON_LIB_DEPEND=">=dev-libs/glib-2.0[static-libs(+)]
101 + sys-libs/zlib[static-libs(+)]
102 + xattr? ( sys-apps/attr[static-libs(+)] )"
103 +SOFTMMU_LIB_DEPEND="${COMMON_LIB_DEPEND}
104 + >=x11-libs/pixman-0.28.0[static-libs(+)]
105 + accessibility? ( app-accessibility/brltty[static-libs(+)] )
106 + aio? ( dev-libs/libaio[static-libs(+)] )
107 + alsa? ( >=media-libs/alsa-lib-1.0.13 )
108 + bluetooth? ( net-wireless/bluez )
109 + caps? ( sys-libs/libcap-ng[static-libs(+)] )
110 + curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
111 + fdt? ( >=sys-apps/dtc-1.4.0[static-libs(+)] )
112 + glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
113 + gnutls? (
114 + dev-libs/nettle[static-libs(+)]
115 + >=net-libs/gnutls-3.0[static-libs(+)]
116 + )
117 + gtk? (
118 + gtk2? (
119 + x11-libs/gtk+:2
120 + vte? ( x11-libs/vte:0 )
121 + )
122 + !gtk2? (
123 + x11-libs/gtk+:3
124 + vte? ( x11-libs/vte:2.90 )
125 + )
126 + )
127 + infiniband? ( sys-infiniband/librdmacm:=[static-libs(+)] )
128 + iscsi? ( net-libs/libiscsi )
129 + jpeg? ( virtual/jpeg:=[static-libs(+)] )
130 + lzo? ( dev-libs/lzo:2[static-libs(+)] )
131 + ncurses? ( sys-libs/ncurses:0=[static-libs(+)] )
132 + nfs? ( >=net-fs/libnfs-1.9.3[static-libs(+)] )
133 + numa? ( sys-process/numactl[static-libs(+)] )
134 + opengl? (
135 + virtual/opengl
136 + media-libs/libepoxy[static-libs(+)]
137 + media-libs/mesa[static-libs(+)]
138 + media-libs/mesa[egl,gles2]
139 + )
140 + png? ( media-libs/libpng:0=[static-libs(+)] )
141 + pulseaudio? ( media-sound/pulseaudio )
142 + rbd? ( sys-cluster/ceph[static-libs(+)] )
143 + sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
144 + sdl? (
145 + !sdl2? (
146 + media-libs/libsdl[X]
147 + >=media-libs/libsdl-1.2.11[static-libs(+)]
148 + )
149 + sdl2? (
150 + media-libs/libsdl2[X]
151 + media-libs/libsdl2[static-libs(+)]
152 + )
153 + )
154 + seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
155 + smartcard? ( >=app-emulation/libcacard-2.5.0[static-libs(+)] )
156 + snappy? ( app-arch/snappy[static-libs(+)] )
157 + spice? (
158 + >=app-emulation/spice-protocol-0.12.3
159 + >=app-emulation/spice-0.12.0[static-libs(+)]
160 + )
161 + ssh? ( >=net-libs/libssh2-1.2.8[static-libs(+)] )
162 + usb? ( >=virtual/libusb-1-r2[static-libs(+)] )
163 + usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
164 + uuid? ( >=sys-apps/util-linux-2.16.0[static-libs(+)] )
165 + vde? ( net-misc/vde[static-libs(+)] )
166 + virgl? ( media-libs/virglrenderer[static-libs(+)] )
167 + virtfs? ( sys-libs/libcap )
168 + xfs? ( sys-fs/xfsprogs[static-libs(+)] )"
169 +USER_LIB_DEPEND="${COMMON_LIB_DEPEND}"
170 +X86_FIRMWARE_DEPEND="
171 + >=sys-firmware/ipxe-1.0.0_p20130624
172 + pin-upstream-blobs? (
173 + ~sys-firmware/seabios-1.8.2
174 + ~sys-firmware/sgabios-0.1_pre8
175 + ~sys-firmware/vgabios-0.7a
176 + )
177 + !pin-upstream-blobs? (
178 + sys-firmware/seabios
179 + sys-firmware/sgabios
180 + sys-firmware/vgabios
181 + )"
182 +CDEPEND="
183 + !static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND//\[static-libs(+)]} ) " ${use_softmmu_targets}) )
184 + !static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND//\[static-libs(+)]} ) " ${use_user_targets}) )
185 + qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
186 + qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )
187 + python? ( ${PYTHON_DEPS} )
188 + systemtap? ( dev-util/systemtap )
189 + xen? ( app-emulation/xen-tools:= )"
190 +DEPEND="${CDEPEND}
191 + dev-lang/perl
192 + =dev-lang/python-2*
193 + sys-apps/texinfo
194 + virtual/pkgconfig
195 + kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
196 + gtk? ( nls? ( sys-devel/gettext ) )
197 + static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND} ) " ${use_softmmu_targets}) )
198 + static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND} ) " ${use_user_targets}) )
199 + test? (
200 + dev-libs/glib[utils]
201 + sys-devel/bc
202 + )"
203 +RDEPEND="${CDEPEND}
204 + selinux? ( sec-policy/selinux-qemu )
205 +"
206 +
207 +STRIP_MASK="/usr/share/qemu/palcode-clipper"
208 +
209 +QA_PREBUILT="
210 + usr/share/qemu/openbios-ppc
211 + usr/share/qemu/openbios-sparc64
212 + usr/share/qemu/openbios-sparc32
213 + usr/share/qemu/palcode-clipper
214 + usr/share/qemu/s390-ccw.img
215 + usr/share/qemu/u-boot.e500
216 +"
217 +
218 +QA_WX_LOAD="usr/bin/qemu-i386
219 + usr/bin/qemu-x86_64
220 + usr/bin/qemu-alpha
221 + usr/bin/qemu-arm
222 + usr/bin/qemu-cris
223 + usr/bin/qemu-m68k
224 + usr/bin/qemu-microblaze
225 + usr/bin/qemu-microblazeel
226 + usr/bin/qemu-mips
227 + usr/bin/qemu-mipsel
228 + usr/bin/qemu-or32
229 + usr/bin/qemu-ppc
230 + usr/bin/qemu-ppc64
231 + usr/bin/qemu-ppc64abi32
232 + usr/bin/qemu-sh4
233 + usr/bin/qemu-sh4eb
234 + usr/bin/qemu-sparc
235 + usr/bin/qemu-sparc64
236 + usr/bin/qemu-armeb
237 + usr/bin/qemu-sparc32plus
238 + usr/bin/qemu-s390x
239 + usr/bin/qemu-unicore32"
240 +
241 +DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure
242 +you have the kernel module loaded before running kvm. The easiest way to
243 +ensure that the kernel module is loaded is to load it on boot.\n
244 +For AMD CPUs the module is called 'kvm-amd'\n
245 +For Intel CPUs the module is called 'kvm-intel'\n
246 +Please review /etc/conf.d/modules for how to load these\n\n
247 +Make sure your user is in the 'kvm' group\n
248 +Just run 'gpasswd -a <USER> kvm', then have <USER> re-login."
249 +
250 +qemu_support_kvm() {
251 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 \
252 + use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64 \
253 + use qemu_softmmu_targets_s390x; then
254 + return 0
255 + fi
256 +
257 + return 1
258 +}
259 +
260 +pkg_pretend() {
261 + if use kernel_linux && kernel_is lt 2 6 25; then
262 + eerror "This version of KVM requres a host kernel of 2.6.25 or higher."
263 + elif use kernel_linux; then
264 + if ! linux_config_exists; then
265 + eerror "Unable to check your kernel for KVM support"
266 + else
267 + CONFIG_CHECK="~KVM ~TUN ~BRIDGE"
268 + ERROR_KVM="You must enable KVM in your kernel to continue"
269 + ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in"
270 + ERROR_KVM_AMD+=" your kernel configuration."
271 + ERROR_KVM_INTEL="If you have an Intel CPU, you must enable"
272 + ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration."
273 + ERROR_TUN="You will need the Universal TUN/TAP driver compiled"
274 + ERROR_TUN+=" into your kernel or loaded as a module to use the"
275 + ERROR_TUN+=" virtual network device if using -net tap."
276 + ERROR_BRIDGE="You will also need support for 802.1d"
277 + ERROR_BRIDGE+=" Ethernet Bridging for some network configurations."
278 + use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
279 + ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
280 + ERROR_VHOST_NET+=" support"
281 +
282 + if use amd64 || use x86 || use amd64-linux || use x86-linux; then
283 + CONFIG_CHECK+=" ~KVM_AMD ~KVM_INTEL"
284 + fi
285 +
286 + use python && CONFIG_CHECK+=" ~DEBUG_FS"
287 + ERROR_DEBUG_FS="debugFS support required for kvm_stat"
288 +
289 + # Now do the actual checks setup above
290 + check_extra_config
291 + fi
292 + fi
293 +
294 + if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
295 + eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt"
296 + eerror "instances are still pointing to it. Please update your"
297 + eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag"
298 + eerror "and the right system binary (e.g. qemu-system-x86_64)."
299 + die "update your virt configs to not use qemu-kvm"
300 + fi
301 +}
302 +
303 +pkg_setup() {
304 + enewgroup kvm 78
305 +}
306 +
307 +# Sanity check to make sure target lists are kept up-to-date.
308 +check_targets() {
309 + local var=$1 mak=$2
310 + local detected sorted
311 +
312 + pushd "${S}"/default-configs >/dev/null || die
313 +
314 + # Force C locale until glibc is updated. #564936
315 + detected=$(echo $(printf '%s\n' *-${mak}.mak | sed "s:-${mak}.mak::" | LC_COLLATE=C sort -u))
316 + sorted=$(echo $(printf '%s\n' ${!var} | LC_COLLATE=C sort -u))
317 + if [[ ${sorted} != "${detected}" ]] ; then
318 + eerror "The ebuild needs to be kept in sync."
319 + eerror "${var}: ${sorted}"
320 + eerror "$(printf '%-*s' ${#var} configure): ${detected}"
321 + die "sync ${var} to the list of targets"
322 + fi
323 +
324 + popd >/dev/null
325 +}
326 +
327 +src_prepare() {
328 + check_targets IUSE_SOFTMMU_TARGETS softmmu
329 + check_targets IUSE_USER_TARGETS linux-user
330 +
331 + # Alter target makefiles to accept CFLAGS set via flag-o
332 + sed -i -r \
333 + -e 's/^(C|OP_C|HELPER_C)FLAGS=/\1FLAGS+=/' \
334 + Makefile Makefile.target || die
335 +
336 + # Cheap hack to disable gettext .mo generation.
337 + use nls || rm -f po/*.po
338 +
339 + epatch "${FILESDIR}"/qemu-2.5.0-cflags.patch
340 + [[ -n ${BACKPORTS} ]] && \
341 + EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" \
342 + epatch
343 +
344 + # Fix ld and objcopy being called directly
345 + tc-export AR LD OBJCOPY
346 +
347 + # Verbose builds
348 + MAKEOPTS+=" V=1"
349 +
350 + epatch_user
351 +}
352 +
353 +##
354 +# configures qemu based on the build directory and the build type
355 +# we are using.
356 +#
357 +qemu_src_configure() {
358 + debug-print-function ${FUNCNAME} "$@"
359 +
360 + local buildtype=$1
361 + local builddir="${S}/${buildtype}-build"
362 + local static_flag="static-${buildtype}"
363 +
364 + mkdir "${builddir}"
365 +
366 + local conf_opts=(
367 + --prefix=/usr
368 + --sysconfdir=/etc
369 + --libdir=/usr/$(get_libdir)
370 + --docdir=/usr/share/doc/${PF}/html
371 + --disable-bsd-user
372 + --disable-guest-agent
373 + --disable-strip
374 + --disable-werror
375 + --python="${PYTHON}"
376 + --cc="$(tc-getCC)"
377 + --cxx="$(tc-getCXX)"
378 + --host-cc="$(tc-getBUILD_CC)"
379 + $(use_enable debug debug-info)
380 + $(use_enable debug debug-tcg)
381 + --enable-docs
382 + $(use_enable tci tcg-interpreter)
383 + $(use_enable xattr attr)
384 + )
385 +
386 + # Disable options not used by user targets as the default configure
387 + # options will autoprobe and try to link in a bunch of unused junk.
388 + conf_softmmu() {
389 + if [[ ${buildtype} == "user" ]] ; then
390 + echo "--disable-${2:-$1}"
391 + else
392 + use_enable "$@"
393 + fi
394 + }
395 + conf_opts+=(
396 + $(conf_softmmu accessibility brlapi)
397 + $(conf_softmmu aio linux-aio)
398 + $(conf_softmmu bluetooth bluez)
399 + $(conf_softmmu caps cap-ng)
400 + $(conf_softmmu curl)
401 + $(conf_softmmu fdt)
402 + $(conf_softmmu glusterfs)
403 + $(conf_softmmu gnutls)
404 + $(conf_softmmu gtk)
405 + $(conf_softmmu infiniband rdma)
406 + $(conf_softmmu iscsi libiscsi)
407 + $(conf_softmmu jpeg vnc-jpeg)
408 + $(conf_softmmu kernel_linux kvm)
409 + $(conf_softmmu lzo)
410 + $(conf_softmmu ncurses curses)
411 + $(conf_softmmu nfs libnfs)
412 + $(conf_softmmu numa)
413 + $(conf_softmmu opengl)
414 + $(conf_softmmu png vnc-png)
415 + $(conf_softmmu rbd)
416 + $(conf_softmmu sasl vnc-sasl)
417 + $(conf_softmmu sdl)
418 + $(conf_softmmu seccomp)
419 + $(conf_softmmu smartcard)
420 + $(conf_softmmu snappy)
421 + $(conf_softmmu spice)
422 + $(conf_softmmu ssh libssh2)
423 + $(conf_softmmu usb libusb)
424 + $(conf_softmmu usbredir usb-redir)
425 + $(conf_softmmu uuid)
426 + $(conf_softmmu vde)
427 + $(conf_softmmu vhost-net)
428 + $(conf_softmmu virgl virglrenderer)
429 + $(conf_softmmu virtfs)
430 + $(conf_softmmu vnc)
431 + $(conf_softmmu vte)
432 + $(conf_softmmu xen)
433 + $(conf_softmmu xen xen-pci-passthrough)
434 + $(conf_softmmu xfs xfsctl)
435 + )
436 +
437 + case ${buildtype} in
438 + user)
439 + conf_opts+=(
440 + --enable-linux-user
441 + --disable-system
442 + --disable-blobs
443 + --disable-tools
444 + )
445 + ;;
446 + softmmu)
447 + # audio options
448 + local audio_opts="oss"
449 + use alsa && audio_opts="alsa,${audio_opts}"
450 + use sdl && audio_opts="sdl,${audio_opts}"
451 + use pulseaudio && audio_opts="pa,${audio_opts}"
452 +
453 + conf_opts+=(
454 + --disable-linux-user
455 + --enable-system
456 + --with-system-pixman
457 + --audio-drv-list="${audio_opts}"
458 + )
459 + use gtk && conf_opts+=( --with-gtkabi=$(usex gtk2 2.0 3.0) )
460 + use sdl && conf_opts+=( --with-sdlabi=$(usex sdl2 2.0 1.2) )
461 + ;;
462 + tools)
463 + conf_opts+=(
464 + --disable-linux-user
465 + --disable-system
466 + --disable-blobs
467 + )
468 + static_flag="static"
469 + ;;
470 + esac
471 +
472 + local targets="${buildtype}_targets"
473 + [[ -n ${targets} ]] && conf_opts+=( --target-list="${!targets}" )
474 +
475 + # Add support for SystemTAP
476 + use systemtap && conf_opts+=( --enable-trace-backend=dtrace )
477 +
478 + # We always want to attempt to build with PIE support as it results
479 + # in a more secure binary. But it doesn't work with static or if
480 + # the current GCC doesn't have PIE support.
481 + if use ${static_flag}; then
482 + conf_opts+=( --static --disable-pie )
483 + else
484 + gcc-specs-pie && conf_opts+=( --enable-pie )
485 + fi
486 +
487 + echo "../configure ${conf_opts[*]}"
488 + cd "${builddir}"
489 + ../configure "${conf_opts[@]}" || die "configure failed"
490 +
491 + # FreeBSD's kernel does not support QEMU assigning/grabbing
492 + # host USB devices yet
493 + use kernel_FreeBSD && \
494 + sed -i -E -e "s|^(HOST_USB=)bsd|\1stub|" "${S}"/config-host.mak
495 +}
496 +
497 +src_configure() {
498 + local target
499 +
500 + python_setup
501 +
502 + softmmu_targets= softmmu_bins=()
503 + user_targets= user_bins=()
504 +
505 + for target in ${IUSE_SOFTMMU_TARGETS} ; do
506 + if use "qemu_softmmu_targets_${target}"; then
507 + softmmu_targets+=",${target}-softmmu"
508 + softmmu_bins+=( "qemu-system-${target}" )
509 + fi
510 + done
511 +
512 + for target in ${IUSE_USER_TARGETS} ; do
513 + if use "qemu_user_targets_${target}"; then
514 + user_targets+=",${target}-linux-user"
515 + user_bins+=( "qemu-${target}" )
516 + fi
517 + done
518 +
519 + softmmu_targets=${softmmu_targets#,}
520 + user_targets=${user_targets#,}
521 +
522 + [[ -n ${softmmu_targets} ]] && qemu_src_configure "softmmu"
523 + [[ -n ${user_targets} ]] && qemu_src_configure "user"
524 + [[ -z ${softmmu_targets}${user_targets} ]] && qemu_src_configure "tools"
525 +}
526 +
527 +src_compile() {
528 + if [[ -n ${user_targets} ]]; then
529 + cd "${S}/user-build"
530 + default
531 + fi
532 +
533 + if [[ -n ${softmmu_targets} ]]; then
534 + cd "${S}/softmmu-build"
535 + default
536 + fi
537 +
538 + if [[ -z ${softmmu_targets}${user_targets} ]]; then
539 + cd "${S}/tools-build"
540 + default
541 + fi
542 +}
543 +
544 +src_test() {
545 + if [[ -n ${softmmu_targets} ]]; then
546 + cd "${S}/softmmu-build"
547 + pax-mark m */qemu-system-* #515550
548 + emake -j1 check
549 + emake -j1 check-report.html
550 + fi
551 +}
552 +
553 +qemu_python_install() {
554 + python_domodule "${S}/scripts/qmp/qmp.py"
555 +
556 + python_doscript "${S}/scripts/kvm/kvm_stat"
557 + python_doscript "${S}/scripts/kvm/vmxcap"
558 + python_doscript "${S}/scripts/qmp/qmp-shell"
559 + python_doscript "${S}/scripts/qmp/qemu-ga-client"
560 +}
561 +
562 +src_install() {
563 + if [[ -n ${user_targets} ]]; then
564 + cd "${S}/user-build"
565 + emake DESTDIR="${ED}" install
566 +
567 + # Install binfmt handler init script for user targets
568 + newinitd "${FILESDIR}/qemu-binfmt.initd-r1" qemu-binfmt
569 + fi
570 +
571 + if [[ -n ${softmmu_targets} ]]; then
572 + cd "${S}/softmmu-build"
573 + emake DESTDIR="${ED}" install
574 +
575 + # This might not exist if the test failed. #512010
576 + [[ -e check-report.html ]] && dohtml check-report.html
577 +
578 + if use kernel_linux; then
579 + udev_dorules "${FILESDIR}"/65-kvm.rules
580 + fi
581 +
582 + if use python; then
583 + python_foreach_impl qemu_python_install
584 + fi
585 + fi
586 +
587 + if [[ -z ${softmmu_targets}${user_targets} ]]; then
588 + cd "${S}/tools-build"
589 + emake DESTDIR="${ED}" install
590 + fi
591 +
592 + # Disable mprotect on the qemu binaries as they use JITs to be fast #459348
593 + pushd "${ED}"/usr/bin >/dev/null
594 + pax-mark m "${softmmu_bins[@]}" "${user_bins[@]}"
595 + popd >/dev/null
596 +
597 + # Install config file example for qemu-bridge-helper
598 + insinto "/etc/qemu"
599 + doins "${FILESDIR}/bridge.conf"
600 +
601 + # Remove the docdir placed qmp-commands.txt
602 + mv "${ED}/usr/share/doc/${PF}/html/qmp-commands.txt" "${S}/docs/" || die
603 +
604 + cd "${S}"
605 + dodoc Changelog MAINTAINERS docs/specs/pci-ids.txt
606 + newdoc pc-bios/README README.pc-bios
607 + dodoc docs/qmp-*.txt
608 +
609 + if [[ -n ${softmmu_targets} ]]; then
610 + # Remove SeaBIOS since we're using the SeaBIOS packaged one
611 + rm "${ED}/usr/share/qemu/bios.bin"
612 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
613 + dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
614 + fi
615 +
616 + # Remove vgabios since we're using the vgabios packaged one
617 + rm "${ED}/usr/share/qemu/vgabios.bin"
618 + rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
619 + rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
620 + rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
621 + rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
622 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
623 + dosym ../vgabios/vgabios.bin /usr/share/qemu/vgabios.bin
624 + dosym ../vgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
625 + dosym ../vgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
626 + dosym ../vgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
627 + dosym ../vgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
628 + fi
629 +
630 + # Remove sgabios since we're using the sgabios packaged one
631 + rm "${ED}/usr/share/qemu/sgabios.bin"
632 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
633 + dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
634 + fi
635 +
636 + # Remove iPXE since we're using the iPXE packaged one
637 + rm "${ED}"/usr/share/qemu/pxe-*.rom
638 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
639 + dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
640 + dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
641 + dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
642 + dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
643 + dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
644 + dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
645 + fi
646 + fi
647 +
648 + qemu_support_kvm && readme.gentoo_create_doc
649 +}
650 +
651 +pkg_postinst() {
652 + if qemu_support_kvm; then
653 + readme.gentoo_print_elog
654 + fi
655 +
656 + if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
657 + udev_reload
658 + fi
659 +
660 + fcaps cap_net_admin /usr/libexec/qemu-bridge-helper
661 +}
662 +
663 +pkg_info() {
664 + echo "Using:"
665 + echo " $(best_version app-emulation/spice-protocol)"
666 + echo " $(best_version sys-firmware/ipxe)"
667 + echo " $(best_version sys-firmware/seabios)"
668 + if has_version 'sys-firmware/seabios[binary]'; then
669 + echo " USE=binary"
670 + else
671 + echo " USE=''"
672 + fi
673 + echo " $(best_version sys-firmware/vgabios)"
674 +}