Gentoo Archives: gentoo-commits

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