app-emulation/xen-tools: bump to 4.13.0
[gentoo.git] / app-emulation / xen / xen-4.13.0_rc5.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python2_7 )
7
8 inherit flag-o-matic mount-boot multilib python-any-r1 toolchain-funcs
9
10 MY_PV=${PV/_/-}
11 MY_P=${PN}-${MY_PV}
12
13 if [[ $PV == *9999 ]]; then
14         inherit git-r3
15         EGIT_REPO_URI="git://xenbits.xen.org/xen.git"
16         SRC_URI=""
17 else
18         #KEYWORDS="~amd64 ~arm -x86"
19         KEYWORDS=""
20         UPSTREAM_VER=
21         SECURITY_VER=
22         GENTOO_VER=
23
24         [[ -n ${UPSTREAM_VER} ]] && \
25                 UPSTREAM_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${P}-upstream-patches-${UPSTREAM_VER}.tar.xz
26                 https://github.com/hydrapolic/gentoo-dist/raw/master/xen/${P}-upstream-patches-${UPSTREAM_VER}.tar.xz"
27         [[ -n ${SECURITY_VER} ]] && \
28                 SECURITY_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${PN}-security-patches-${SECURITY_VER}.tar.xz"
29         [[ -n ${GENTOO_VER} ]] && \
30                 GENTOO_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${PN}-gentoo-patches-${GENTOO_VER}.tar.xz"
31         SRC_URI="https://downloads.xenproject.org/release/xen/${MY_PV}/${MY_P}.tar.gz
32                 ${UPSTREAM_PATCHSET_URI}
33                 ${SECURITY_PATCHSET_URI}
34                 ${GENTOO_PATCHSET_URI}"
35 fi
36
37 DESCRIPTION="The Xen virtual machine monitor"
38 HOMEPAGE="https://www.xenproject.org"
39 LICENSE="GPL-2"
40 SLOT="0"
41 IUSE="debug efi flask"
42
43 DEPEND="${PYTHON_DEPS}
44         efi? ( >=sys-devel/binutils-2.22[multitarget] )
45         !efi? ( >=sys-devel/binutils-2.22 )"
46 RDEPEND=""
47 PDEPEND="~app-emulation/xen-tools-${PV}"
48
49 # no tests are available for the hypervisor
50 # prevent the silliness of /usr/lib/debug/usr/lib/debug files
51 # prevent stripping of the debug info from the /usr/lib/debug/xen-syms
52 RESTRICT="test splitdebug strip"
53
54 # Approved by QA team in bug #144032
55 QA_WX_LOAD="boot/xen-syms-${PV}"
56
57 REQUIRED_USE="arm? ( debug )"
58
59 S="${WORKDIR}/${MY_P}"
60
61 pkg_setup() {
62         python-any-r1_pkg_setup
63         if [[ -z ${XEN_TARGET_ARCH} ]]; then
64                 if use amd64; then
65                         export XEN_TARGET_ARCH="x86_64"
66                 elif use arm; then
67                         export XEN_TARGET_ARCH="arm32"
68                 elif use arm64; then
69                         export XEN_TARGET_ARCH="arm64"
70                 else
71                         die "Unsupported architecture!"
72                 fi
73         fi
74
75         if use flask ; then
76                 export "XSM_ENABLE=y"
77                 export "FLASK_ENABLE=y"
78         fi
79 }
80
81 src_prepare() {
82         # Upstream's patchset
83         [[ -n ${UPSTREAM_VER} ]] && eapply "${WORKDIR}"/patches-upstream
84
85         # Security patchset
86         if [[ -n ${SECURITY_VER} ]]; then
87         einfo "Try to apply Xen Security patch set"
88                 # apply main xen patches
89                 # Two parallel systems, both work side by side
90                 # Over time they may concdense into one. This will suffice for now
91                 source "${WORKDIR}"/patches-security/${PV}.conf
92
93                 local i
94                 for i in ${XEN_SECURITY_MAIN}; do
95                         eapply "${WORKDIR}"/patches-security/xen/$i
96                 done
97         fi
98
99         # Gentoo's patchset
100         [[ -n ${GENTOO_VER} ]] && eapply "${WORKDIR}"/patches-gentoo
101
102         eapply "${FILESDIR}"/${PN}-4.6-efi.patch
103
104         # Drop .config
105         sed -e '/-include $(XEN_ROOT)\/.config/d' -i Config.mk || die "Couldn't drop"
106
107         if use efi; then
108                 export EFI_VENDOR="gentoo"
109                 export EFI_MOUNTPOINT="/boot"
110         fi
111
112         default
113 }
114
115 src_configure() {
116         use arm && myopt="${myopt} CONFIG_EARLY_PRINTK=sun7i"
117
118         use debug && myopt="${myopt} debug=y"
119
120         # remove flags
121         unset CFLAGS
122         unset LDFLAGS
123         unset ASFLAGS
124 }
125
126 src_compile() {
127         # Send raw LDFLAGS so that --as-needed works
128         emake V=1 CC="$(tc-getCC)" LDFLAGS="$(raw-ldflags)" LD="$(tc-getLD)" -C xen ${myopt}
129 }
130
131 src_install() {
132         local myopt
133         use debug && myopt="${myopt} debug=y"
134
135         # The 'make install' doesn't 'mkdir -p' the subdirs
136         if use efi; then
137                 mkdir -p "${D}"${EFI_MOUNTPOINT}/efi/${EFI_VENDOR} || die
138         fi
139
140         emake LDFLAGS="$(raw-ldflags)" DESTDIR="${D}" -C xen ${myopt} install
141
142         # make install likes to throw in some extra EFI bits if it built
143         use efi || rm -rf "${D}/usr/$(get_libdir)/efi"
144 }
145
146 pkg_postinst() {
147         elog "Official Xen Guide:"
148         elog " https://wiki.gentoo.org/wiki/Xen"
149
150         use efi && einfo "The efi executable is installed in /boot/efi/gentoo"
151
152         elog "You can optionally block the installation of /boot/xen-syms by an entry"
153         elog "in folder /etc/portage/env using the portage's feature INSTALL_MASK"
154         elog "e.g. echo ${msg} > /etc/portage/env/xen.conf"
155 }