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