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