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