Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-emulation/xen-tools/files/, app-emulation/xen-tools/
Date: Thu, 21 Oct 2021 04:20:56
Message-Id: 1634789993.fcdbfdb8dd89d3b47067b235218955a15c0dd2ed.sam@gentoo
1 commit: fcdbfdb8dd89d3b47067b235218955a15c0dd2ed
2 Author: Tomáš Mózes <hydrapolic <AT> gmail <DOT> com>
3 AuthorDate: Wed Oct 20 12:40:08 2021 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Thu Oct 21 04:19:53 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fcdbfdb8
7
8 app-emulation/xen-tools: fix building with ocaml-4.12
9
10 Closes: https://bugs.gentoo.org/818100
11 Signed-off-by: Tomáš Mózes <hydrapolic <AT> gmail.com>
12 Signed-off-by: Sam James <sam <AT> gentoo.org>
13
14 app-emulation/xen-tools/Manifest | 1 +
15 .../files/xen-tools-4.15.1-ocaml-4.12.patch | 101 ++++
16 app-emulation/xen-tools/xen-tools-4.15.1-r2.ebuild | 556 +++++++++++++++++++++
17 3 files changed, 658 insertions(+)
18
19 diff --git a/app-emulation/xen-tools/Manifest b/app-emulation/xen-tools/Manifest
20 index d7ffa4f1fbb..fe0fec07cc3 100644
21 --- a/app-emulation/xen-tools/Manifest
22 +++ b/app-emulation/xen-tools/Manifest
23 @@ -7,5 +7,6 @@ DIST edk2-a3741780fe3535e19e02efa869a7cac481891129.tar.gz 12886279 BLAKE2B 2054b
24 DIST ipxe-git-988d2c13cdf0f0b4140685af35ced70ac5b3283c.tar.gz 3931642 BLAKE2B bf0b5d9ea1d44803bc5c4aa0bf9188636e292b226ab759f32e3c2bfa3f80dd3f546526b9a11c1f67193793ede5309bfa67bdce80aba62ccca54597dc6e7e4ba4 SHA512 0a63f83c9135d05c6bfe7c4d12da3ff76271e35305a4d5654bd5aefa9ee59f5363546c65820c42133deb0fb5a0a0bcaa9b1c48396f9f996acea0d492a5f03f33
25 DIST seabios-1.14.0.tar.gz 628985 BLAKE2B cc1126925dab1551a655680d20d06ebf28c12c386500d1ee4df9e1a99403b4c5bc6a66c2cc5ef58b4c3d6d7226f35007506a6a1855c2cf2742469dcb7aba05bb SHA512 215c42f59425f8abd062be7b11fc0e39c977cee5001a2381551b0f851ac337d0dd53c065267e6dee0e710ffd700fa635f9007b89da8dfce0f47122c984ee8146
26 DIST xen-4.14.3.tar.gz 39982036 BLAKE2B 927fd2937f451567238702430cea3a6e5d2db70d5eef10f029bb1d6d030681573c851eb8076c8bad89c97c115f81a19ac8e46e78ca3f0e642565f7300c264ca1 SHA512 b462fcc1549f6e57f7f2a4fd10ce1e957a25a6a7c0319672b62699468f6c4330b9cd0cf2b0231b5cce94f4bb142a957eb8aa58aa0ffb5c85b37211d6b34ccf16
27 +DIST xen-4.15.1-upstream-patches-1.tar.xz 15476 BLAKE2B 9f0cf8f3dd993e32939ff1ee35244224bd3d16fbd345500ff01e51eb5828d3e44bddc539462c39d8c37b6497d4bf8887261a8df5d31b17b413b0c21f7faf3a84 SHA512 aac3f91c3c753aa8430abad055252cba5dbdfd9e548f219df1452388ef2f82b65c428755363aa0645824431e812f3b799af4f9468669e42a0f5b6b8874397c75
28 DIST xen-4.15.1.tar.gz 40800852 BLAKE2B 39475ea33f029fb0e84b82b4a2b13fd613bab01e3ef6c241dfede3d190ee9be53c99b62121d37d83b1e078764b3e4d88d1dfb99be1b5623691e56519850c6798 SHA512 8d3cbdf708f46477e32ee7cbd16a490c82efa855cecd84ee712b8680df4d69c987ba9ab00ff3851f627b98a8ebbc5dab71f92f142ed958ee2bc538bc792cd4b9
29 DIST xen-gentoo-patches-23.tar.xz 20536 BLAKE2B 0064f79f8794a21ab13047a4ee296e37efa616e16ca6cd65b31fdafeb458fd9b80f0443758343c8328b1901d7169618346becfe75f16dcaeff08fc975f1d08d5 SHA512 09248e17ff7865feb2a505169d62ee5c8c60bd672fa8c4c7c4e3a2e4af58bfad0379d37b395bab3e3393af8d53d882f56749dfeb560edeea6b7ab56c902a3c49
30
31 diff --git a/app-emulation/xen-tools/files/xen-tools-4.15.1-ocaml-4.12.patch b/app-emulation/xen-tools/files/xen-tools-4.15.1-ocaml-4.12.patch
32 new file mode 100644
33 index 00000000000..b06a7f195bf
34 --- /dev/null
35 +++ b/app-emulation/xen-tools/files/xen-tools-4.15.1-ocaml-4.12.patch
36 @@ -0,0 +1,101 @@
37 +From 2d1a35f1e6c2113a6322fdb758a198608c90e4bd Mon Sep 17 00:00:00 2001
38 +From: Costin Lupu <costin.lupu@××××××.ro>
39 +Date: Tue, 8 Jun 2021 15:35:29 +0300
40 +Subject: [PATCH] tools/ocaml: Fix redefinition errors
41 +
42 +If PAGE_SIZE is already defined in the system (e.g. in /usr/include/limits.h
43 +header) then gcc will trigger a redefinition error because of -Werror. This
44 +patch replaces usage of PAGE_* macros with XC_PAGE_* macros in order to avoid
45 +confusion between control domain page granularity (PAGE_* definitions) and
46 +guest domain page granularity (which is what we are dealing with here).
47 +
48 +Same issue applies for redefinitions of Val_none and Some_val macros which
49 +can be already define in the OCaml system headers (e.g.
50 +/usr/lib/ocaml/caml/mlvalues.h).
51 +
52 +Signed-off-by: Costin Lupu <costin.lupu@××××××.ro>
53 +Reviewed-by: Julien Grall <jgrall@××××××.com>
54 +Acked-by: Ian Jackson <iwj@××××××××××.org>
55 +Tested-by: Dario Faggioli <dfaggioli@××××.com>
56 +---
57 + tools/ocaml/libs/xc/xenctrl_stubs.c | 10 ++++------
58 + tools/ocaml/libs/xentoollog/xentoollog_stubs.c | 4 ++++
59 + tools/ocaml/libs/xl/xenlight_stubs.c | 4 ++++
60 + 3 files changed, 12 insertions(+), 6 deletions(-)
61 +
62 +diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c
63 +index 6e4bc567f5..a6756c4a8c 100644
64 +--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
65 ++++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
66 +@@ -37,14 +37,12 @@
67 +
68 + #include "mmap_stubs.h"
69 +
70 +-#define PAGE_SHIFT 12
71 +-#define PAGE_SIZE (1UL << PAGE_SHIFT)
72 +-#define PAGE_MASK (~(PAGE_SIZE-1))
73 +-
74 + #define _H(__h) ((xc_interface *)(__h))
75 + #define _D(__d) ((uint32_t)Int_val(__d))
76 +
77 ++#ifndef Val_none
78 + #define Val_none (Val_int(0))
79 ++#endif
80 +
81 + #define string_of_option_array(array, index) \
82 + ((Field(array, index) == Val_none) ? NULL : String_val(Field(Field(array, index), 0)))
83 +@@ -819,7 +817,7 @@ CAMLprim value stub_xc_domain_memory_increase_reservation(value xch,
84 + CAMLparam3(xch, domid, mem_kb);
85 + int retval;
86 +
87 +- unsigned long nr_extents = ((unsigned long)(Int64_val(mem_kb))) >> (PAGE_SHIFT - 10);
88 ++ unsigned long nr_extents = ((unsigned long)(Int64_val(mem_kb))) >> (XC_PAGE_SHIFT - 10);
89 +
90 + uint32_t c_domid = _D(domid);
91 + caml_enter_blocking_section();
92 +@@ -925,7 +923,7 @@ CAMLprim value stub_pages_to_kib(value pages)
93 + {
94 + CAMLparam1(pages);
95 +
96 +- CAMLreturn(caml_copy_int64(Int64_val(pages) << (PAGE_SHIFT - 10)));
97 ++ CAMLreturn(caml_copy_int64(Int64_val(pages) << (XC_PAGE_SHIFT - 10)));
98 + }
99 +
100 +
101 +diff --git a/tools/ocaml/libs/xentoollog/xentoollog_stubs.c b/tools/ocaml/libs/xentoollog/xentoollog_stubs.c
102 +index bf64b211c2..e4306a0c2f 100644
103 +--- a/tools/ocaml/libs/xentoollog/xentoollog_stubs.c
104 ++++ b/tools/ocaml/libs/xentoollog/xentoollog_stubs.c
105 +@@ -53,8 +53,12 @@ static char * dup_String_val(value s)
106 + #include "_xtl_levels.inc"
107 +
108 + /* Option type support as per http://www.linux-nantes.org/~fmonnier/ocaml/ocaml-wrapping-c.php */
109 ++#ifndef Val_none
110 + #define Val_none Val_int(0)
111 ++#endif
112 ++#ifndef Some_val
113 + #define Some_val(v) Field(v,0)
114 ++#endif
115 +
116 + static value Val_some(value v)
117 + {
118 +diff --git a/tools/ocaml/libs/xl/xenlight_stubs.c b/tools/ocaml/libs/xl/xenlight_stubs.c
119 +index 352a00134d..45b8af61c7 100644
120 +--- a/tools/ocaml/libs/xl/xenlight_stubs.c
121 ++++ b/tools/ocaml/libs/xl/xenlight_stubs.c
122 +@@ -227,8 +227,12 @@ static value Val_string_list(libxl_string_list *c_val)
123 + }
124 +
125 + /* Option type support as per http://www.linux-nantes.org/~fmonnier/ocaml/ocaml-wrapping-c.php */
126 ++#ifndef Val_none
127 + #define Val_none Val_int(0)
128 ++#endif
129 ++#ifndef Some_val
130 + #define Some_val(v) Field(v,0)
131 ++#endif
132 +
133 + static value Val_some(value v)
134 + {
135 +--
136 +2.30.2
137 +
138
139 diff --git a/app-emulation/xen-tools/xen-tools-4.15.1-r2.ebuild b/app-emulation/xen-tools/xen-tools-4.15.1-r2.ebuild
140 new file mode 100644
141 index 00000000000..1bd53de373b
142 --- /dev/null
143 +++ b/app-emulation/xen-tools/xen-tools-4.15.1-r2.ebuild
144 @@ -0,0 +1,556 @@
145 +# Copyright 1999-2021 Gentoo Authors
146 +# Distributed under the terms of the GNU General Public License v2
147 +
148 +EAPI=7
149 +
150 +PYTHON_COMPAT=( python3_{8..9} )
151 +PYTHON_REQ_USE='ncurses,xml,threads(+)'
152 +
153 +inherit bash-completion-r1 flag-o-matic multilib python-single-r1 toolchain-funcs
154 +
155 +MY_PV=${PV/_/-}
156 +
157 +if [[ ${PV} == *9999 ]]; then
158 + inherit git-r3
159 + REPO="xen.git"
160 + EGIT_REPO_URI="git://xenbits.xen.org/${REPO}"
161 + S="${WORKDIR}/${REPO}"
162 +else
163 + KEYWORDS="~amd64 ~arm ~arm64 ~x86"
164 + UPSTREAM_VER=1
165 + SECURITY_VER=
166 + # xen-tools's gentoo patches tarball
167 + GENTOO_VER=23
168 + # xen-tools's gentoo patches version which apply to this specific ebuild
169 + GENTOO_GPV=0
170 + # xen-tools ovmf's patches
171 + OVMF_VER=
172 +
173 + SEABIOS_VER="1.14.0"
174 + EDK2_COMMIT="a3741780fe3535e19e02efa869a7cac481891129"
175 + EDK2_OPENSSL_VERSION="1_1_1j"
176 + EDK2_SOFTFLOAT_COMMIT="b64af41c3276f97f0e181920400ee056b9c88037"
177 + EDK2_BROTLI_COMMIT="666c3280cc11dc433c303d79a83d4ffbdd12cc8d"
178 + IPXE_COMMIT="988d2c13cdf0f0b4140685af35ced70ac5b3283c"
179 +
180 + [[ -n ${UPSTREAM_VER} ]] && \
181 + UPSTREAM_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${P/-tools/}-upstream-patches-${UPSTREAM_VER}.tar.xz
182 + https://github.com/hydrapolic/gentoo-dist/raw/master/xen/${P/-tools/}-upstream-patches-${UPSTREAM_VER}.tar.xz"
183 + [[ -n ${SECURITY_VER} ]] && \
184 + SECURITY_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${PN/-tools}-security-patches-${SECURITY_VER}.tar.xz
185 + https://github.com/hydrapolic/gentoo-dist/raw/master/xen/${PN/-tools/}-security-patches-${SECURITY_VER}.tar.xz"
186 + [[ -n ${GENTOO_VER} ]] && \
187 + GENTOO_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${PN/-tools}-gentoo-patches-${GENTOO_VER}.tar.xz
188 + https://github.com/hydrapolic/gentoo-dist/raw/master/xen/${PN/-tools/}-gentoo-patches-${GENTOO_VER}.tar.xz"
189 + [[ -n ${OVMF_VER} ]] && \
190 + OVMF_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${PN/-tools}-ovmf-patches-${OVMF_VER}.tar.xz"
191 +
192 + SRC_URI="https://downloads.xenproject.org/release/xen/${MY_PV}/xen-${MY_PV}.tar.gz
193 + https://www.seabios.org/downloads/seabios-${SEABIOS_VER}.tar.gz
194 + ipxe? ( http://xenbits.xen.org/xen-extfiles/ipxe-git-${IPXE_COMMIT}.tar.gz )
195 + ovmf? ( https://github.com/tianocore/edk2/archive/${EDK2_COMMIT}.tar.gz -> edk2-${EDK2_COMMIT}.tar.gz
196 + https://github.com/openssl/openssl/archive/OpenSSL_${EDK2_OPENSSL_VERSION}.tar.gz
197 + https://github.com/ucb-bar/berkeley-softfloat-3/archive/${EDK2_SOFTFLOAT_COMMIT}.tar.gz -> berkeley-softfloat-${EDK2_SOFTFLOAT_COMMIT}.tar.gz
198 + https://github.com/google/brotli/archive/${EDK2_BROTLI_COMMIT}.tar.gz -> brotli-${EDK2_BROTLI_COMMIT}.tar.gz
199 + ${OVMF_PATCHSET_URI} )
200 + ${UPSTREAM_PATCHSET_URI}
201 + ${SECURITY_PATCHSET_URI}
202 + ${GENTOO_PATCHSET_URI}"
203 +
204 + S="${WORKDIR}/xen-${MY_PV}"
205 +fi
206 +
207 +DESCRIPTION="Xen tools including QEMU and xl"
208 +HOMEPAGE="https://www.xenproject.org"
209 +DOCS=( README )
210 +
211 +LICENSE="GPL-2"
212 +SLOT="0/$(ver_cut 1-2)"
213 +# Inclusion of IUSE ocaml on stabalizing requires maintainer of ocaml to (get off his hands and) make
214 +# >=dev-lang/ocaml-4 stable
215 +# Masked in profiles/eapi-5-files instead
216 +IUSE="api debug doc +hvm +ipxe ocaml ovmf +pam pygrub python +qemu +qemu-traditional +rombios screen selinux sdl static-libs system-ipxe system-qemu system-seabios"
217 +
218 +REQUIRED_USE="
219 + ${PYTHON_REQUIRED_USE}
220 + ipxe? ( rombios )
221 + ovmf? ( hvm )
222 + pygrub? ( python )
223 + rombios? ( hvm )
224 + system-ipxe? ( rombios )
225 + ?? ( ipxe system-ipxe )
226 + ?? ( qemu system-qemu )"
227 +
228 +COMMON_DEPEND="
229 + sys-apps/pciutils
230 + dev-libs/lzo:2
231 + dev-libs/glib:2
232 + dev-libs/yajl
233 + dev-libs/libaio
234 + dev-libs/libgcrypt:0
235 + sys-libs/zlib
236 + ${PYTHON_DEPS}
237 +"
238 +
239 +RDEPEND="${COMMON_DEPEND}
240 + sys-apps/iproute2[-minimal]
241 + net-misc/bridge-utils
242 + screen? (
243 + app-misc/screen
244 + app-admin/logrotate
245 + )
246 + selinux? ( sec-policy/selinux-xen )"
247 +
248 +DEPEND="${COMMON_DEPEND}
249 + app-misc/pax-utils
250 + >=sys-kernel/linux-headers-4.11
251 + x11-libs/pixman
252 + $(python_gen_cond_dep '
253 + dev-python/lxml[${PYTHON_USEDEP}]
254 + pam? ( dev-python/pypam[${PYTHON_USEDEP}] )
255 + ')
256 + x86? ( sys-devel/dev86
257 + system-ipxe? ( sys-firmware/ipxe[qemu] )
258 + sys-power/iasl )
259 + api? ( dev-libs/libxml2
260 + net-misc/curl )
261 +
262 + ovmf? (
263 + !arm? ( !arm64? ( dev-lang/nasm ) )
264 + $(python_gen_impl_dep sqlite)
265 + )
266 + !amd64? ( >=sys-apps/dtc-1.4.0 )
267 + amd64? ( sys-power/iasl
268 + system-seabios? ( sys-firmware/seabios )
269 + system-ipxe? ( sys-firmware/ipxe[qemu] )
270 + rombios? ( sys-devel/bin86 sys-devel/dev86 ) )
271 + doc? (
272 + app-text/ghostscript-gpl
273 + app-text/pandoc
274 + $(python_gen_cond_dep '
275 + dev-python/markdown[${PYTHON_USEDEP}]
276 + ')
277 + dev-texlive/texlive-latexextra
278 + media-gfx/transfig
279 + )
280 + hvm? ( x11-base/xorg-proto )
281 + qemu? (
282 + app-arch/snappy:=
283 + sdl? (
284 + media-libs/libsdl[X]
285 + media-libs/libsdl2[X]
286 + )
287 + )
288 + system-qemu? ( app-emulation/qemu[xen] )
289 + ocaml? ( dev-ml/findlib
290 + dev-lang/ocaml[ocamlopt] )
291 + python? ( >=dev-lang/swig-4.0.0 )"
292 +
293 +BDEPEND="dev-lang/perl
294 + sys-devel/bison
295 + sys-devel/gettext"
296 +
297 +# hvmloader is used to bootstrap a fully virtualized kernel
298 +# Approved by QA team in bug #144032
299 +QA_WX_LOAD="
300 + usr/libexec/xen/boot/hvmloader
301 + usr/libexec/xen/boot/xen-shim
302 + usr/share/qemu-xen/qemu/hppa-firmware.img
303 + usr/share/qemu-xen/qemu/s390-ccw.img
304 + usr/share/qemu-xen/qemu/u-boot.e500
305 +"
306 +
307 +QA_PREBUILT="
308 + usr/libexec/xen/bin/elf2dmp
309 + usr/libexec/xen/bin/ivshmem-client
310 + usr/libexec/xen/bin/ivshmem-server
311 + usr/libexec/xen/bin/qemu-edid
312 + usr/libexec/xen/bin/qemu-img
313 + usr/libexec/xen/bin/qemu-io
314 + usr/libexec/xen/bin/qemu-keymap
315 + usr/libexec/xen/bin/qemu-nbd
316 + usr/libexec/xen/bin/qemu-pr-helper
317 + usr/libexec/xen/bin/qemu-storage-daemon
318 + usr/libexec/xen/bin/qemu-system-i386
319 + usr/libexec/xen/bin/virtfs-proxy-helper
320 + usr/libexec/xen/boot/xen-shim
321 + usr/libexec/xen/libexec/qemu-pr-helper
322 + usr/libexec/xen/libexec/virtfs-proxy-helper
323 + usr/libexec/xen/libexec/virtiofsd
324 + usr/libexec/xen/libexec/xen-bridge-helper
325 + usr/share/qemu-xen/qemu/s390-ccw.img
326 + usr/share/qemu-xen/qemu/s390-netboot.img
327 + usr/share/qemu-xen/qemu/u-boot.e500
328 +"
329 +
330 +RESTRICT="test"
331 +
332 +PATCHES=( "${FILESDIR}/${PN}-4.15.0-fix-xenstat-python-bindings.patch" )
333 +
334 +pkg_setup() {
335 + python_setup
336 + export "CONFIG_LOMOUNT=y"
337 +
338 + #bug 522642, disable compile tools/tests
339 + export "CONFIG_TESTS=n"
340 +
341 + if [[ -z ${XEN_TARGET_ARCH} ]] ; then
342 + if use x86 && use amd64; then
343 + die "Confusion! Both x86 and amd64 are set in your use flags!"
344 + elif use x86; then
345 + export XEN_TARGET_ARCH="x86_32"
346 + elif use amd64 ; then
347 + export XEN_TARGET_ARCH="x86_64"
348 + elif use arm; then
349 + export XEN_TARGET_ARCH="arm32"
350 + elif use arm64; then
351 + export XEN_TARGET_ARCH="arm64"
352 + else
353 + die "Unsupported architecture!"
354 + fi
355 + fi
356 +}
357 +
358 +src_prepare() {
359 + local i
360 +
361 + # Upstream's patchset
362 + if [[ -n ${UPSTREAM_VER} ]]; then
363 + einfo "Try to apply Xen Upstream patch set"
364 + eapply "${WORKDIR}"/patches-upstream
365 + fi
366 +
367 + # Security patchset
368 + if [[ -n ${SECURITY_VER} ]]; then
369 + einfo "Try to apply Xen Security patch set"
370 + # apply main xen patches
371 + # Two parallel systems, both work side by side
372 + # Over time they may concdense into one. This will suffice for now
373 + EPATCH_SUFFIX="patch"
374 + EPATCH_FORCE="yes"
375 +
376 + source "${WORKDIR}"/patches-security/${PV}.conf || die
377 +
378 + for i in ${XEN_SECURITY_MAIN}; do
379 + eapply "${WORKDIR}"/patches-security/xen/$i
380 + done
381 +
382 + # apply qemu-xen/upstream patches
383 + pushd "${S}"/tools/qemu-xen/ > /dev/null
384 + for i in ${XEN_SECURITY_QEMUU}; do
385 + eapply "${WORKDIR}"/patches-security/qemuu/$i
386 + done
387 + popd > /dev/null
388 +
389 + # apply qemu-traditional patches
390 + pushd "${S}"/tools/qemu-xen-traditional/ > /dev/null
391 + for i in ${XEN_SECURITY_QEMUT}; do
392 + eapply "${WORKDIR}"/patches-security/qemut/$i
393 + done
394 + popd > /dev/null
395 + fi
396 +
397 + # move before Gentoo patch, one patch should apply to seabios, to fix gcc-4.5.x build err
398 + mv ../seabios-${SEABIOS_VER} tools/firmware/seabios-dir-remote || die
399 + pushd tools/firmware/ > /dev/null
400 + ln -s seabios-dir-remote seabios-dir || die
401 + popd > /dev/null
402 +
403 + # Gentoo's patchset
404 + if [[ -n ${GENTOO_VER} && -n ${GENTOO_GPV} ]]; then
405 + einfo "Try to apply Gentoo specific patch set"
406 + source "${FILESDIR}"/gentoo-patches.conf || die
407 + _gpv=_gpv_${PN/-/_}_${PV//./}_${GENTOO_GPV}
408 + for i in ${!_gpv}; do
409 + eapply "${WORKDIR}"/patches-gentoo/$i
410 + done
411 + fi
412 +
413 + # Ovmf's patchset
414 + if use ovmf; then
415 + if [[ -n ${OVMF_VER} ]];then
416 + einfo "Try to apply Ovmf patch set"
417 + pushd "${WORKDIR}"/edk2-*/ > /dev/null
418 + eapply "${WORKDIR}"/patches-ovmf
419 + popd > /dev/null
420 + fi
421 + mv ../edk2-${EDK2_COMMIT} tools/firmware/ovmf-dir-remote || die
422 + rm -r tools/firmware/ovmf-dir-remote/CryptoPkg/Library/OpensslLib/openssl || die
423 + rm -r tools/firmware/ovmf-dir-remote/ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3 || die
424 + rm -r tools/firmware/ovmf-dir-remote/BaseTools/Source/C/BrotliCompress/brotli || die
425 + rm -r tools/firmware/ovmf-dir-remote/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli || die
426 + mv ../openssl-OpenSSL_${EDK2_OPENSSL_VERSION} tools/firmware/ovmf-dir-remote/CryptoPkg/Library/OpensslLib/openssl || die
427 + mv ../berkeley-softfloat-3-${EDK2_SOFTFLOAT_COMMIT} tools/firmware/ovmf-dir-remote/ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3 || die
428 + cp -r ../brotli-${EDK2_BROTLI_COMMIT} tools/firmware/ovmf-dir-remote/BaseTools/Source/C/BrotliCompress/brotli || die
429 + cp -r ../brotli-${EDK2_BROTLI_COMMIT} tools/firmware/ovmf-dir-remote/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli || die
430 + cp tools/firmware/ovmf-makefile tools/firmware/ovmf-dir-remote/Makefile || die
431 +
432 + # Bug #816987
433 + pushd tools/firmware/ovmf-dir-remote/BaseTools/Source/C/BrotliCompress/brotli > /dev/null
434 + eapply "${FILESDIR}/${PN}-4.15.1-brotli-gcc11.patch"
435 + popd > /dev/null
436 +
437 + pushd tools/firmware/ovmf-dir-remote/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli > /dev/null
438 + eapply "${FILESDIR}/${PN}-4.15.1-brotli-gcc11.patch"
439 + popd > /dev/null
440 +
441 + pushd tools/firmware/ovmf-dir-remote > /dev/null
442 + eapply "${FILESDIR}/${PN}-4.15.1-edk2-python3.9.patch"
443 + popd > /dev/null
444 + fi
445 +
446 + # Fix building with ocaml 4.12 #818100
447 + eapply "${FILESDIR}/${PN}-4.15.1-ocaml-4.12.patch"
448 +
449 + # ipxe
450 + if use ipxe; then
451 + cp "${DISTDIR}/ipxe-git-${IPXE_COMMIT}.tar.gz" tools/firmware/etherboot/_ipxe.tar.gz || die
452 +
453 + # gcc 11
454 + cp "${WORKDIR}/patches-gentoo/${PN}-4.15.0-ipxe-gcc11.patch" tools/firmware/etherboot/patches/ipxe-gcc11.patch || die
455 + echo ipxe-gcc11.patch >> tools/firmware/etherboot/patches/series || die
456 + fi
457 +
458 + mv tools/qemu-xen/qemu-bridge-helper.c tools/qemu-xen/xen-bridge-helper.c || die
459 +
460 + # Fix texi2html build error with new texi2html, qemu.doc.html
461 + sed -i -e "/texi2html -monolithic/s/-number//" tools/qemu-xen-traditional/Makefile || die
462 +
463 + use api || sed -e "/SUBDIRS-\$(LIBXENAPI_BINDINGS) += libxen/d" -i tools/Makefile || die
464 + sed -e 's:$(MAKE) PYTHON=$(PYTHON) subdirs-$@:LC_ALL=C "$(MAKE)" PYTHON=$(PYTHON) subdirs-$@:' \
465 + -i tools/firmware/Makefile || die
466 +
467 + # Drop .config, fixes to gcc-4.6
468 + sed -e '/-include $(XEN_ROOT)\/.config/d' -i Config.mk || die "Couldn't drop"
469 +
470 + # drop flags
471 + unset CFLAGS
472 + unset LDFLAGS
473 + unset ASFLAGS
474 + unset CPPFLAGS
475 +
476 + if ! use pygrub; then
477 + sed -e '/^SUBDIRS-y += pygrub/d' -i tools/Makefile || die
478 + fi
479 +
480 + if ! use python; then
481 + sed -e '/^SUBDIRS-y += python$/d' -i tools/Makefile || die
482 + fi
483 +
484 + if ! use hvm; then
485 + sed -e '/SUBDIRS-$(CONFIG_X86) += firmware/d' -i tools/Makefile || die
486 + # Bug 351648
487 + elif ! use x86 && ! has x86 $(get_all_abis); then
488 + mkdir -p "${WORKDIR}"/extra-headers/gnu || die
489 + touch "${WORKDIR}"/extra-headers/gnu/stubs-32.h || die
490 + export CPATH="${WORKDIR}"/extra-headers
491 + fi
492 +
493 + if use qemu; then
494 + if use sdl; then
495 + sed -i -e "s:\$\$source/configure:\0 --enable-sdl:" \
496 + tools/Makefile || die
497 + else
498 + sed -i -e "s:\${QEMU_ROOT\:\-\.}/configure:\0 --disable-sdl:" \
499 + tools/qemu-xen-traditional/xen-setup || die
500 + sed -i -e "s:\$\$source/configure:\0 --disable-sdl:" \
501 + tools/Makefile || die
502 + fi
503 + else
504 + # Don't bother with qemu, only needed for fully virtualised guests
505 + sed -i '/SUBDIRS-$(CONFIG_QEMU_XEN)/s/^/#/g' tools/Makefile || die
506 + fi
507 +
508 + # Reset bash completion dir; Bug 472438
509 + sed -e "s:^BASH_COMPLETION_DIR ?= \$(CONFIG_DIR)/bash_completion.d:BASH_COMPLETION_DIR ?= $(get_bashcompdir):" \
510 + -i Config.mk || die
511 +
512 + # xencommons, Bug #492332, sed lighter weight than patching
513 + sed -e 's:\$QEMU_XEN -xen-domid:test -e "\$QEMU_XEN" \&\& &:' \
514 + -i tools/hotplug/Linux/init.d/xencommons.in || die
515 +
516 + # fix bashishm
517 + sed -e '/Usage/s/\$//g' \
518 + -i tools/hotplug/Linux/init.d/xendriverdomain.in || die
519 +
520 + # respect multilib, usr/lib/libcacard.so.0.0.0
521 + sed -e "/^libdir=/s/\/lib/\/$(get_libdir)/" \
522 + -i tools/qemu-xen/configure || die
523 +
524 + #bug 518136, don't build 32bit exactuable for nomultilib profile
525 + if [[ "${ARCH}" == 'amd64' ]] && ! has_multilib_profile; then
526 + sed -i -e "/x86_emulator/d" tools/tests/Makefile || die
527 + fi
528 +
529 + # uncomment lines in xl.conf
530 + sed -e 's:^#autoballoon=:autoballoon=:' \
531 + -e 's:^#lockfile=:lockfile=:' \
532 + -e 's:^#vif.default.script=:vif.default.script=:' \
533 + -i tools/examples/xl.conf || die
534 +
535 + # disable capstone (Bug #673474)
536 + sed -e "s:\$\$source/configure:\0 --disable-capstone:" \
537 + -i tools/Makefile || die
538 +
539 + # disable glusterfs
540 + sed -e "s:\$\$source/configure:\0 --disable-glusterfs:" \
541 + -i tools/Makefile || die
542 +
543 + # disable jpeg automagic
544 + sed -e "s:\$\$source/configure:\0 --disable-vnc-jpeg:" \
545 + -i tools/Makefile || die
546 +
547 + # disable png automagic
548 + sed -e "s:\$\$source/configure:\0 --disable-vnc-png:" \
549 + -i tools/Makefile || die
550 +
551 + # disable docker (Bug #732970)
552 + sed -e "s:\$\$source/configure:\0 --disable-containers:" \
553 + -i tools/Makefile || die
554 +
555 + # disable abi-dumper (Bug #791172)
556 + sed -e 's/$(ABI_DUMPER) /echo /g' \
557 + -i tools/libs/libs.mk || die
558 +
559 + default
560 +}
561 +
562 +src_configure() {
563 + local myconf="--prefix=${PREFIX}/usr \
564 + --libdir=${PREFIX}/usr/$(get_libdir) \
565 + --libexecdir=${PREFIX}/usr/libexec \
566 + --localstatedir=${EPREFIX}/var \
567 + --disable-golang \
568 + --disable-werror \
569 + --disable-xen \
570 + --enable-tools \
571 + --enable-docs \
572 + $(use_enable api xenapi) \
573 + $(use_enable ipxe) \
574 + $(usex system-ipxe '--with-system-ipxe=/usr/share/ipxe' '') \
575 + $(use_enable ocaml ocamltools) \
576 + $(use_enable ovmf) \
577 + $(use_enable pam) \
578 + $(use_enable rombios) \
579 + --with-xenstored=$(usex ocaml 'oxenstored' 'xenstored') \
580 + "
581 +
582 + use system-seabios && myconf+=" --with-system-seabios=/usr/share/seabios/bios.bin"
583 + use system-qemu && myconf+=" --with-system-qemu=/usr/bin/qemu-system-x86_64"
584 + use amd64 && myconf+=" $(use_enable qemu-traditional)"
585 + tc-ld-disable-gold # Bug 669570
586 + econf ${myconf}
587 +}
588 +
589 +src_compile() {
590 + local myopt
591 + use debug && myopt="${myopt} debug=y"
592 + use python && myopt="${myopt} XENSTAT_PYTHON_BINDINGS=y"
593 +
594 + if test-flag-CC -fno-strict-overflow; then
595 + append-flags -fno-strict-overflow
596 + fi
597 +
598 + emake CC="$(tc-getCC)" LD="$(tc-getLD)" AR="$(tc-getAR)" RANLIB="$(tc-getRANLIB)" build-tools ${myopt}
599 +
600 + if use doc; then
601 + emake -C docs build
602 + else
603 + emake -C docs man-pages
604 + fi
605 +}
606 +
607 +src_install() {
608 + # Override auto-detection in the build system, bug #382573
609 + export INITD_DIR=/tmp/init.d
610 + export CONFIG_LEAF_DIR=../tmp/default
611 +
612 + # Let the build system compile installed Python modules.
613 + local PYTHONDONTWRITEBYTECODE
614 + export PYTHONDONTWRITEBYTECODE
615 +
616 + emake DESTDIR="${ED}" DOCDIR="/usr/share/doc/${PF}" \
617 + XEN_PYTHON_NATIVE_INSTALL=y install-tools
618 +
619 + # Created at runtime
620 + rm -rv "${ED}/var/run" || die
621 +
622 + # Fix the remaining Python shebangs.
623 + python_fix_shebang "${D}"
624 +
625 + # Remove RedHat-specific stuff
626 + rm -rf "${D}"/tmp || die
627 +
628 + if use doc; then
629 + emake DESTDIR="${D}" DOCDIR="/usr/share/doc/${PF}" install-docs
630 + dodoc -r docs/{pdf,txt}
631 + else
632 + emake -C docs DESTDIR="${D}" DOCDIR="/usr/share/doc/${PF}" install-man-pages # Bug 668032
633 + fi
634 + dodoc ${DOCS[@]}
635 +
636 + newconfd "${FILESDIR}"/xendomains.confd xendomains
637 + newconfd "${FILESDIR}"/xenstored.confd xenstored
638 + newconfd "${FILESDIR}"/xenconsoled.confd xenconsoled
639 + newinitd "${FILESDIR}"/xendomains.initd-r2 xendomains
640 + newinitd "${FILESDIR}"/xenstored.initd-r1 xenstored
641 + newinitd "${FILESDIR}"/xenconsoled.initd xenconsoled
642 + newinitd "${FILESDIR}"/xencommons.initd xencommons
643 + newconfd "${FILESDIR}"/xencommons.confd xencommons
644 + newinitd "${FILESDIR}"/xenqemudev.initd xenqemudev
645 + newconfd "${FILESDIR}"/xenqemudev.confd xenqemudev
646 + newinitd "${FILESDIR}"/xen-watchdog.initd xen-watchdog
647 +
648 + if use screen; then
649 + cat "${FILESDIR}"/xendomains-screen.confd >> "${D}"/etc/conf.d/xendomains || die
650 + cp "${FILESDIR}"/xen-consoles.logrotate "${D}"/etc/xen/ || die
651 + keepdir /var/log/xen-consoles
652 + fi
653 +
654 + # For -static-libs wrt Bug 384355
655 + if ! use static-libs; then
656 + rm -f "${D}"/usr/$(get_libdir)/*.a "${D}"/usr/$(get_libdir)/ocaml/*/*.a
657 + fi
658 +
659 + # for xendomains
660 + keepdir /etc/xen/auto
661 +
662 + # Remove files failing QA AFTER emake installs them, avoiding seeking absent files
663 + find "${D}" \( -name openbios-sparc32 -o -name openbios-sparc64 \
664 + -o -name openbios-ppc -o -name palcode-clipper \) -delete || die
665 +
666 + keepdir /var/lib/xen/dump
667 + keepdir /var/lib/xen/xenpaging
668 + keepdir /var/lib/xenstored
669 + keepdir /var/log/xen
670 +
671 + if use python; then
672 + python_domodule "${S}/tools/libs/stat/bindings/swig/python/xenstat.py"
673 + python_domodule "${S}/tools/libs/stat/bindings/swig/python/_xenstat.so"
674 + fi
675 +
676 + python_optimize
677 +}
678 +
679 +pkg_postinst() {
680 + elog "Official Xen Guide and the offical wiki page:"
681 + elog "https://wiki.gentoo.org/wiki/Xen"
682 + elog "https://wiki.xen.org/wiki/Main_Page"
683 + elog ""
684 + elog "Recommended to utilise the xencommons script to config system at boot"
685 + elog "Add by use of rc-update on completion of the install"
686 +
687 + if ! use hvm; then
688 + echo
689 + elog "HVM (VT-x and AMD-V) support has been disabled. If you need hvm"
690 + elog "support enable the hvm use flag."
691 + elog "An x86 or amd64 system is required to build HVM support."
692 + fi
693 +
694 + if use qemu; then
695 + elog "The qemu-bridge-helper is renamed to the xen-bridge-helper in the in source"
696 + elog "build of qemu. This allows for app-emulation/qemu to be emerged concurrently"
697 + elog "with the qemu capable xen. It is up to the user to distinguish between and utilise"
698 + elog "the qemu-bridge-helper and the xen-bridge-helper. File bugs of any issues that arise"
699 + fi
700 +}