Gentoo Archives: gentoo-commits

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