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