dev-cpp/pangomm: stable 2.42.1 for hppa, bug #717144
[gentoo.git] / app-emulation / xen-tools / xen-tools-4.13.1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python3_{6,7,8} )
7 PYTHON_REQ_USE='ncurses,xml,threads(+)'
8
9 inherit bash-completion-r1 flag-o-matic multilib python-single-r1 toolchain-funcs
10
11 MY_PV=${PV/_/-}
12
13 if [[ $PV == *9999 ]]; then
14         inherit git-r3
15         REPO="xen.git"
16         EGIT_REPO_URI="git://xenbits.xen.org/${REPO}"
17         S="${WORKDIR}/${REPO}"
18 else
19         KEYWORDS="~amd64 ~arm ~arm64 ~x86"
20         UPSTREAM_VER=
21         SECURITY_VER=
22         # xen-tools's gentoo patches tarball
23         GENTOO_VER=21
24         # xen-tools's gentoo patches version which apply to this specific ebuild
25         GENTOO_GPV=0
26         # xen-tools ovmf's patches
27         OVMF_VER=
28
29         SEABIOS_VER="1.12.1"
30         EDK2_COMMIT="20d2e5a125e34fc8501026613a71549b2a1a3e54"
31         EDK2_OPENSSL_VERSION="1_1_1b"
32         EDK2_SOFTFLOAT_COMMIT="b64af41c3276f97f0e181920400ee056b9c88037"
33         IPXE_COMMIT="1dd56dbd11082fb622c2ed21cfaced4f47d798a6"
34
35         [[ -n ${UPSTREAM_VER} ]] && \
36                 UPSTREAM_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${P/-tools/}-upstream-patches-${UPSTREAM_VER}.tar.xz
37                 https://github.com/hydrapolic/gentoo-dist/raw/master/xen/${P/-tools/}-upstream-patches-${UPSTREAM_VER}.tar.xz"
38         [[ -n ${SECURITY_VER} ]] && \
39                 SECURITY_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${PN/-tools}-security-patches-${SECURITY_VER}.tar.xz"
40         [[ -n ${GENTOO_VER} ]] && \
41                 GENTOO_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${PN/-tools}-gentoo-patches-${GENTOO_VER}.tar.xz
42                 https://github.com/hydrapolic/gentoo-dist/raw/master/xen/${PN/-tools/}-gentoo-patches-${GENTOO_VER}.tar.xz"
43         [[ -n ${OVMF_VER} ]] && \
44                 OVMF_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${PN/-tools}-ovmf-patches-${OVMF_VER}.tar.xz"
45
46         SRC_URI="https://downloads.xenproject.org/release/xen/${MY_PV}/xen-${MY_PV}.tar.gz
47         https://github.com/qemu/seabios/archive/rel-${SEABIOS_VER}.tar.gz -> seabios-${SEABIOS_VER}.tar.gz
48         ipxe? ( http://xenbits.xen.org/xen-extfiles/ipxe-git-${IPXE_COMMIT}.tar.gz )
49         ovmf? ( https://github.com/tianocore/edk2/archive/${EDK2_COMMIT}.tar.gz -> edk2-${EDK2_COMMIT}.tar.gz
50                 https://github.com/openssl/openssl/archive/OpenSSL_${EDK2_OPENSSL_VERSION}.tar.gz
51                 https://github.com/ucb-bar/berkeley-softfloat-3/archive/${EDK2_SOFTFLOAT_COMMIT}.tar.gz -> berkeley-softfloat-${EDK2_SOFTFLOAT_COMMIT}.tar.gz
52                 ${OVMF_PATCHSET_URI} )
53         ${UPSTREAM_PATCHSET_URI}
54         ${SECURITY_PATCHSET_URI}
55         ${GENTOO_PATCHSET_URI}"
56
57         S="${WORKDIR}/xen-${MY_PV}"
58 fi
59
60 DESCRIPTION="Xen tools including QEMU and xl"
61 HOMEPAGE="https://www.xenproject.org"
62 DOCS=( README )
63
64 LICENSE="GPL-2"
65 SLOT="0/$(ver_cut 1-2)"
66 # Inclusion of IUSE ocaml on stabalizing requires maintainer of ocaml to (get off his hands and) make
67 # >=dev-lang/ocaml-4 stable
68 # Masked in profiles/eapi-5-files instead
69 IUSE="api debug doc flask +hvm +ipxe ocaml ovmf +pam pygrub python +qemu +qemu-traditional +rombios screen sdl static-libs system-ipxe system-qemu system-seabios"
70
71 REQUIRED_USE="
72         ${PYTHON_REQUIRED_USE}
73         ipxe? ( rombios )
74         ovmf? ( hvm )
75         pygrub? ( python )
76         rombios? ( hvm )
77         system-ipxe? ( rombios )
78         ?? ( ipxe system-ipxe )
79         ?? ( qemu system-qemu )"
80
81 COMMON_DEPEND="
82         sys-apps/pciutils
83         dev-libs/lzo:2
84         dev-libs/glib:2
85         dev-libs/yajl
86         dev-libs/libaio
87         dev-libs/libgcrypt:0
88         sys-libs/zlib
89         ${PYTHON_DEPS}
90 "
91
92 DEPEND="${COMMON_DEPEND}
93         >=sys-kernel/linux-headers-4.11
94         $(python_gen_cond_dep '
95                 dev-python/lxml[${PYTHON_MULTI_USEDEP}]
96                 pam? ( dev-python/pypam[${PYTHON_MULTI_USEDEP}] )
97         ')
98         x86? ( sys-devel/dev86
99                 system-ipxe? ( sys-firmware/ipxe[qemu] )
100                 sys-power/iasl )
101         api? ( dev-libs/libxml2
102                 net-misc/curl )
103
104         ovmf? (
105                 !arm? ( !arm64? ( dev-lang/nasm ) )
106                 $(python_gen_impl_dep sqlite)
107                 )
108         !amd64? ( >=sys-apps/dtc-1.4.0 )
109         amd64? ( sys-power/iasl
110                 system-seabios? ( sys-firmware/seabios )
111                 system-ipxe? ( sys-firmware/ipxe[qemu] )
112                 rombios? ( sys-devel/bin86 sys-devel/dev86 ) )
113         dev-lang/perl
114         app-misc/pax-utils
115         doc? (
116                 app-text/ghostscript-gpl
117                 app-text/pandoc
118                 $(python_gen_cond_dep '
119                         dev-python/markdown[${PYTHON_MULTI_USEDEP}]
120                 ')
121                 dev-texlive/texlive-latexextra
122                 media-gfx/transfig
123         )
124         hvm? ( x11-base/xorg-proto )
125         qemu? (
126                 app-arch/snappy:=
127                 x11-libs/pixman
128                 sdl? (
129                         media-libs/libsdl[X]
130                         media-libs/libsdl2[X]
131                 )
132         )
133         system-qemu? ( app-emulation/qemu[xen] )
134         ocaml? ( dev-ml/findlib
135                 >=dev-lang/ocaml-4 )
136         python? ( >=dev-lang/swig-4.0.0 )"
137
138 RDEPEND="${COMMON_DEPEND}
139         sys-apps/iproute2[-minimal]
140         net-misc/bridge-utils
141         screen? (
142                 app-misc/screen
143                 app-admin/logrotate
144         )"
145
146 # hvmloader is used to bootstrap a fully virtualized kernel
147 # Approved by QA team in bug #144032
148 QA_WX_LOAD="
149         usr/libexec/xen/boot/hvmloader
150         usr/share/qemu-xen/qemu/hppa-firmware.img
151         usr/share/qemu-xen/qemu/s390-ccw.img
152         usr/share/qemu-xen/qemu/u-boot.e500
153 "
154
155 QA_PREBUILT="
156         usr/libexec/xen/bin/elf2dmp
157         usr/libexec/xen/bin/ivshmem-client
158         usr/libexec/xen/bin/ivshmem-server
159         usr/libexec/xen/bin/qemu-edid
160         usr/libexec/xen/bin/qemu-img
161         usr/libexec/xen/bin/qemu-io
162         usr/libexec/xen/bin/qemu-keymap
163         usr/libexec/xen/bin/qemu-nbd
164         usr/libexec/xen/bin/qemu-pr-helper
165         usr/libexec/xen/bin/qemu-system-i386
166         usr/libexec/xen/bin/virtfs-proxy-helper
167         usr/libexec/xen/libexec/xen-bridge-helper
168         usr/share/qemu-xen/qemu/s390-ccw.img
169         usr/share/qemu-xen/qemu/s390-netboot.img
170         usr/share/qemu-xen/qemu/u-boot.e500
171 "
172
173 RESTRICT="test"
174
175 pkg_setup() {
176         python_setup
177         export "CONFIG_LOMOUNT=y"
178
179         #bug 522642, disable compile tools/tests
180         export "CONFIG_TESTS=n"
181
182         if [[ -z ${XEN_TARGET_ARCH} ]] ; then
183                 if use x86 && use amd64; then
184                         die "Confusion! Both x86 and amd64 are set in your use flags!"
185                 elif use x86; then
186                         export XEN_TARGET_ARCH="x86_32"
187                 elif use amd64 ; then
188                         export XEN_TARGET_ARCH="x86_64"
189                 elif use arm; then
190                         export XEN_TARGET_ARCH="arm32"
191                 elif use arm64; then
192                         export XEN_TARGET_ARCH="arm64"
193                 else
194                         die "Unsupported architecture!"
195                 fi
196         fi
197 }
198
199 src_prepare() {
200         local i
201
202         # Upstream's patchset
203         if [[ -n ${UPSTREAM_VER} ]]; then
204                 einfo "Try to apply Xen Upstream patch set"
205                 eapply "${WORKDIR}"/patches-upstream
206         fi
207
208         # Security patchset
209         if [[ -n ${SECURITY_VER} ]]; then
210         einfo "Try to apply Xen Security patch set"
211                 # apply main xen patches
212                 # Two parallel systems, both work side by side
213                 # Over time they may concdense into one. This will suffice for now
214                 EPATCH_SUFFIX="patch"
215                 EPATCH_FORCE="yes"
216
217                 source "${WORKDIR}"/patches-security/${PV}.conf || die
218
219                 for i in ${XEN_SECURITY_MAIN}; do
220                         eapply "${WORKDIR}"/patches-security/xen/$i
221                 done
222
223                 # apply qemu-xen/upstream patches
224                 pushd "${S}"/tools/qemu-xen/ > /dev/null
225                 for i in ${XEN_SECURITY_QEMUU}; do
226                         eapply "${WORKDIR}"/patches-security/qemuu/$i
227                 done
228                 popd > /dev/null
229
230                 # apply qemu-traditional patches
231                 pushd "${S}"/tools/qemu-xen-traditional/ > /dev/null
232                 for i in ${XEN_SECURITY_QEMUT}; do
233                         eapply "${WORKDIR}"/patches-security/qemut/$i
234                 done
235                 popd > /dev/null
236         fi
237
238         # move before Gentoo patch, one patch should apply to seabios, to fix gcc-4.5.x build err
239         mv ../seabios-rel-${SEABIOS_VER} tools/firmware/seabios-dir-remote || die
240         pushd tools/firmware/ > /dev/null
241         ln -s seabios-dir-remote seabios-dir || die
242         popd > /dev/null
243
244         # Gentoo's patchset
245         if [[ -n ${GENTOO_VER} && -n ${GENTOO_GPV} ]]; then
246                 einfo "Try to apply Gentoo specific patch set"
247                 source "${FILESDIR}"/gentoo-patches.conf || die
248                 _gpv=_gpv_${PN/-/_}_${PV//./}_${GENTOO_GPV}
249                 for i in ${!_gpv}; do
250                         eapply "${WORKDIR}"/patches-gentoo/$i
251                 done
252         fi
253
254         # Ovmf's patchset
255         if use ovmf; then
256                 if [[ -n ${OVMF_VER} ]];then
257                         einfo "Try to apply Ovmf patch set"
258                         pushd "${WORKDIR}"/edk2-*/ > /dev/null
259                         eapply "${WORKDIR}"/patches-ovmf
260                         popd > /dev/null
261                 fi
262                 mv ../edk2-${EDK2_COMMIT} tools/firmware/ovmf-dir-remote || die
263                 rm -r tools/firmware/ovmf-dir-remote/CryptoPkg/Library/OpensslLib/openssl || die
264                 rm -r tools/firmware/ovmf-dir-remote/ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3 || die
265                 mv ../openssl-OpenSSL_${EDK2_OPENSSL_VERSION} tools/firmware/ovmf-dir-remote/CryptoPkg/Library/OpensslLib/openssl || die
266                 mv ../berkeley-softfloat-3-${EDK2_SOFTFLOAT_COMMIT} tools/firmware/ovmf-dir-remote/ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3 || die
267                 cp tools/firmware/ovmf-makefile tools/firmware/ovmf-dir-remote/Makefile || die
268         fi
269
270         # ipxe
271         if use ipxe; then
272                 cp "${DISTDIR}/ipxe-git-${IPXE_COMMIT}.tar.gz" tools/firmware/etherboot/_ipxe.tar.gz || die
273
274                 # gcc 10
275                 cp "${WORKDIR}/patches-gentoo/xen-tools-4.13.0-ipxe-gcc10.patch" tools/firmware/etherboot/patches/ipxe-gcc10.patch || die
276                 echo ipxe-gcc10.patch >> tools/firmware/etherboot/patches/series || die
277         fi
278
279         mv tools/qemu-xen/qemu-bridge-helper.c tools/qemu-xen/xen-bridge-helper.c || die
280
281         # Fix texi2html build error with new texi2html, qemu.doc.html
282         sed -i -e "/texi2html -monolithic/s/-number//" tools/qemu-xen-traditional/Makefile || die
283
284         use api || sed -e "/SUBDIRS-\$(LIBXENAPI_BINDINGS) += libxen/d" -i tools/Makefile || die
285         sed -e 's:$(MAKE) PYTHON=$(PYTHON) subdirs-$@:LC_ALL=C "$(MAKE)" PYTHON=$(PYTHON) subdirs-$@:' \
286                 -i tools/firmware/Makefile || die
287
288         # Drop .config, fixes to gcc-4.6
289         sed -e '/-include $(XEN_ROOT)\/.config/d' -i Config.mk || die "Couldn't drop"
290
291         # drop flags
292         unset CFLAGS
293         unset LDFLAGS
294         unset ASFLAGS
295         unset CPPFLAGS
296
297         if ! use pygrub; then
298                 sed -e '/^SUBDIRS-y += pygrub/d' -i tools/Makefile || die
299         fi
300
301         if ! use python; then
302                 sed -e '/^SUBDIRS-y += python$/d' -i tools/Makefile || die
303         fi
304
305         if ! use hvm; then
306                 sed -e '/SUBDIRS-$(CONFIG_X86) += firmware/d' -i tools/Makefile || die
307         # Bug 351648
308         elif ! use x86 && ! has x86 $(get_all_abis); then
309                 mkdir -p "${WORKDIR}"/extra-headers/gnu || die
310                 touch "${WORKDIR}"/extra-headers/gnu/stubs-32.h || die
311                 export CPATH="${WORKDIR}"/extra-headers
312         fi
313
314         if use qemu; then
315                 if use sdl; then
316                         sed -i -e "s:\$\$source/configure:\0 --enable-sdl:" \
317                                 tools/Makefile || die
318                 else
319                         sed -i -e "s:\${QEMU_ROOT\:\-\.}/configure:\0 --disable-sdl:" \
320                                 tools/qemu-xen-traditional/xen-setup || die
321                         sed -i -e "s:\$\$source/configure:\0 --disable-sdl:" \
322                                 tools/Makefile || die
323                 fi
324         else
325                 # Don't bother with qemu, only needed for fully virtualised guests
326                 sed -i '/SUBDIRS-$(CONFIG_QEMU_XEN)/s/^/#/g' tools/Makefile || die
327         fi
328
329         # Reset bash completion dir; Bug 472438
330         sed -e "s:^BASH_COMPLETION_DIR ?= \$(CONFIG_DIR)/bash_completion.d:BASH_COMPLETION_DIR ?= $(get_bashcompdir):" \
331                 -i Config.mk || die
332         sed -i -e "/bash-completion/s/xl\.sh/xl/g" tools/libxl/Makefile || die
333
334         # xencommons, Bug #492332, sed lighter weight than patching
335         sed -e 's:\$QEMU_XEN -xen-domid:test -e "\$QEMU_XEN" \&\& &:' \
336                 -i tools/hotplug/Linux/init.d/xencommons.in || die
337
338         # fix bashishm
339         sed -e '/Usage/s/\$//g' \
340                 -i tools/hotplug/Linux/init.d/xendriverdomain.in || die
341
342         # respect multilib, usr/lib/libcacard.so.0.0.0
343         sed -e "/^libdir=/s/\/lib/\/$(get_libdir)/" \
344                 -i tools/qemu-xen/configure || die
345
346         #bug 518136, don't build 32bit exactuable for nomultilib profile
347         if [[ "${ARCH}" == 'amd64' ]] && ! has_multilib_profile; then
348                 sed -i -e "/x86_emulator/d" tools/tests/Makefile || die
349         fi
350
351         # uncomment lines in xl.conf
352         sed -e 's:^#autoballoon=:autoballoon=:' \
353                 -e 's:^#lockfile=:lockfile=:' \
354                 -e 's:^#vif.default.script=:vif.default.script=:' \
355                 -i tools/examples/xl.conf  || die
356
357         # disable capstone (Bug #673474)
358         sed -e "s:\$\$source/configure:\0 --disable-capstone:" \
359                 -i tools/Makefile || die
360
361         # disable glusterfs
362         sed -e "s:\$\$source/configure:\0 --disable-glusterfs:" \
363                 -i tools/Makefile || die
364
365         default
366 }
367
368 src_configure() {
369         local myconf="--prefix=${PREFIX}/usr \
370                 --libdir=${PREFIX}/usr/$(get_libdir) \
371                 --libexecdir=${PREFIX}/usr/libexec \
372                 --localstatedir=${EPREFIX}/var \
373                 --disable-werror \
374                 --disable-xen \
375                 --enable-tools \
376                 --enable-docs \
377                 $(use_enable api xenapi) \
378                 $(use_enable ipxe) \
379                 $(usex system-ipxe '--with-system-ipxe=/usr/share/ipxe' '') \
380                 $(use_enable ocaml ocamltools) \
381                 $(use_enable ovmf) \
382                 $(use_enable pam) \
383                 $(use_enable rombios) \
384                 --with-xenstored=$(usex ocaml 'oxenstored' 'xenstored') \
385                 "
386
387         use system-seabios && myconf+=" --with-system-seabios=/usr/share/seabios/bios.bin"
388         use system-qemu && myconf+=" --with-system-qemu=/usr/bin/qemu-system-x86_64"
389         use amd64 && myconf+=" $(use_enable qemu-traditional)"
390         tc-ld-disable-gold # Bug 669570
391         econf ${myconf}
392 }
393
394 src_compile() {
395         local myopt
396         use debug && myopt="${myopt} debug=y"
397         use python && myopt="${myopt} XENSTAT_PYTHON_BINDINGS=y"
398
399         if test-flag-CC -fno-strict-overflow; then
400                 append-flags -fno-strict-overflow
401         fi
402
403         emake CC="$(tc-getCC)" LD="$(tc-getLD)" AR="$(tc-getAR)" RANLIB="$(tc-getRANLIB)" build-tools ${myopt}
404
405         if use doc; then
406                 emake -C docs build
407         else
408                 emake -C docs man-pages
409         fi
410 }
411
412 src_install() {
413         # Override auto-detection in the build system, bug #382573
414         export INITD_DIR=/tmp/init.d
415         export CONFIG_LEAF_DIR=../tmp/default
416
417         # Let the build system compile installed Python modules.
418         local PYTHONDONTWRITEBYTECODE
419         export PYTHONDONTWRITEBYTECODE
420
421         emake DESTDIR="${ED}" DOCDIR="/usr/share/doc/${PF}" \
422                 XEN_PYTHON_NATIVE_INSTALL=y install-tools
423
424         # Created at runtime
425         rm -rv "${ED}/var/run" || die
426
427         # Fix the remaining Python shebangs.
428         python_fix_shebang "${D}"
429
430         # Remove RedHat-specific stuff
431         rm -rf "${D}"/tmp || die
432
433         if use doc; then
434                 emake DESTDIR="${D}" DOCDIR="/usr/share/doc/${PF}" install-docs
435                 dodoc -r docs/{pdf,txt}
436         else
437                 emake -C docs DESTDIR="${D}" DOCDIR="/usr/share/doc/${PF}" install-man-pages # Bug 668032
438         fi
439         dodoc ${DOCS[@]}
440
441         newconfd "${FILESDIR}"/xendomains.confd xendomains
442         newconfd "${FILESDIR}"/xenstored.confd xenstored
443         newconfd "${FILESDIR}"/xenconsoled.confd xenconsoled
444         newinitd "${FILESDIR}"/xendomains.initd-r2 xendomains
445         newinitd "${FILESDIR}"/xenstored.initd-r1 xenstored
446         newinitd "${FILESDIR}"/xenconsoled.initd xenconsoled
447         newinitd "${FILESDIR}"/xencommons.initd xencommons
448         newconfd "${FILESDIR}"/xencommons.confd xencommons
449         newinitd "${FILESDIR}"/xenqemudev.initd xenqemudev
450         newconfd "${FILESDIR}"/xenqemudev.confd xenqemudev
451         newinitd "${FILESDIR}"/xen-watchdog.initd xen-watchdog
452
453         if use screen; then
454                 cat "${FILESDIR}"/xendomains-screen.confd >> "${D}"/etc/conf.d/xendomains || die
455                 cp "${FILESDIR}"/xen-consoles.logrotate "${D}"/etc/xen/ || die
456                 keepdir /var/log/xen-consoles
457         fi
458
459         # For -static-libs wrt Bug 384355
460         if ! use static-libs; then
461                 rm -f "${D}"/usr/$(get_libdir)/*.a "${D}"/usr/$(get_libdir)/ocaml/*/*.a
462         fi
463
464         # for xendomains
465         keepdir /etc/xen/auto
466
467         # Remove files failing QA AFTER emake installs them, avoiding seeking absent files
468         find "${D}" \( -name openbios-sparc32 -o -name openbios-sparc64 \
469                 -o -name openbios-ppc -o -name palcode-clipper \) -delete || die
470
471         keepdir /var/lib/xen/dump
472         keepdir /var/lib/xen/xenpaging
473         keepdir /var/lib/xenstored
474         keepdir /var/log/xen
475
476         if use python; then
477                 python_domodule "${S}/tools/xenstat/libxenstat/bindings/swig/python/xenstat.py"
478                 python_domodule "${S}/tools/xenstat/libxenstat/bindings/swig/python/_xenstat.so"
479         fi
480
481         python_optimize
482 }
483
484 pkg_postinst() {
485         elog "Official Xen Guide and the offical wiki page:"
486         elog "https://wiki.gentoo.org/wiki/Xen"
487         elog "https://wiki.xen.org/wiki/Main_Page"
488         elog ""
489         elog "Recommended to utilise the xencommons script to config system at boot"
490         elog "Add by use of rc-update on completion of the install"
491
492         if ! use hvm; then
493                 echo
494                 elog "HVM (VT-x and AMD-V) support has been disabled. If you need hvm"
495                 elog "support enable the hvm use flag."
496                 elog "An x86 or amd64 system is required to build HVM support."
497         fi
498
499         if use qemu; then
500                 elog "The qemu-bridge-helper is renamed to the xen-bridge-helper in the in source"
501                 elog "build of qemu.  This allows for app-emulation/qemu to be emerged concurrently"
502                 elog "with the qemu capable xen.  It is up to the user to distinguish between and utilise"
503                 elog "the qemu-bridge-helper and the xen-bridge-helper. File bugs of any issues that arise"
504         fi
505 }