Gentoo Archives: gentoo-commits

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