1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 PYTHON_COMPAT=( python2_7 )
9 inherit eutils multilib mount-boot flag-o-matic python-any-r1 toolchain-funcs
14 if [[ $PV == *9999 ]]; then
17 EGIT_REPO_URI="git://xenbits.xen.org/xen.git"
20 KEYWORDS="~amd64 ~arm -x86"
25 [[ -n ${UPSTREAM_VER} ]] && \
26 UPSTREAM_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${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="http://bits.xensource.com/oss-xen/release/${MY_PV}/${MY_P}.tar.gz
32 ${UPSTREAM_PATCHSET_URI}
33 ${SECURITY_PATCHSET_URI}
34 ${GENTOO_PATCHSET_URI}"
37 DESCRIPTION="The Xen virtual machine monitor"
38 HOMEPAGE="http://xen.org/"
41 IUSE="custom-cflags debug efi flask"
43 DEPEND="${PYTHON_DEPS}
44 efi? ( >=sys-devel/binutils-2.22[multitarget] )
45 !efi? ( >=sys-devel/binutils-2.22 )"
47 PDEPEND="~app-emulation/xen-tools-${PV}"
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"
54 # Approved by QA team in bug #144032
55 QA_WX_LOAD="boot/xen-syms-${PV}"
57 REQUIRED_USE="arm? ( debug )"
59 S="${WORKDIR}/${MY_P}"
62 python-any-r1_pkg_setup
63 if [[ -z ${XEN_TARGET_ARCH} ]]; then
65 export XEN_TARGET_ARCH="x86_64"
67 export XEN_TARGET_ARCH="arm32"
69 export XEN_TARGET_ARCH="arm64"
71 die "Unsupported architecture!"
77 export "FLASK_ENABLE=y"
83 if [[ -n ${UPSTREAM_VER} ]]; then
84 EPATCH_SUFFIX="patch" \
87 epatch "${WORKDIR}"/patches-upstream
91 if [[ -n ${SECURITY_VER} ]]; then
92 einfo "Try to apply Xen Security patch set"
93 # apply main xen patches
94 # Two parallel systems, both work side by side
95 # Over time they may concdense into one. This will suffice for now
99 source "${WORKDIR}"/patches-security/${PV}.conf
101 for i in ${XEN_SECURITY_MAIN}; do
102 epatch "${WORKDIR}"/patches-security/xen/$i
107 if [[ -n ${GENTOO_VER} ]]; then
108 EPATCH_SUFFIX="patch" \
110 epatch "${WORKDIR}"/patches-gentoo
113 epatch "${FILESDIR}"/${PN}-4.6-efi.patch
116 sed -e '/-include $(XEN_ROOT)\/.config/d' -i Config.mk || die "Couldn't drop"
119 export EFI_VENDOR="gentoo"
120 export EFI_MOUNTPOINT="boot"
123 # if the user *really* wants to use their own custom-cflags, let them
124 if use custom-cflags; then
125 einfo "User wants their own CFLAGS - removing defaults"
126 # try and remove all the default custom-cflags
127 find "${S}" -name Makefile -o -name Rules.mk -o -name Config.mk -exec sed \
128 -e 's/CFLAGS\(.*\)=\(.*\)-O3\(.*\)/CFLAGS\1=\2\3/' \
129 -e 's/CFLAGS\(.*\)=\(.*\)-march=i686\(.*\)/CFLAGS\1=\2\3/' \
130 -e 's/CFLAGS\(.*\)=\(.*\)-fomit-frame-pointer\(.*\)/CFLAGS\1=\2\3/' \
131 -e 's/CFLAGS\(.*\)=\(.*\)-g3*\s\(.*\)/CFLAGS\1=\2 \3/' \
132 -e 's/CFLAGS\(.*\)=\(.*\)-O2\(.*\)/CFLAGS\1=\2\3/' \
133 -i {} \; || die "failed to re-set custom-cflags"
136 # remove -Werror for gcc-4.6's sake
137 find "${S}" -name 'Makefile*' -o -name '*.mk' -o -name 'common.make' | \
138 xargs sed -i 's/ *-Werror */ /'
139 # not strictly necessary to fix this
140 sed -i 's/, "-Werror"//' "${S}/tools/python/setup.py" || die "failed to re-set setup.py"
142 # Bug #575868 converted to a sed statement, typo of one char
143 sed -e "s:granter’s:granter's:" -i xen/include/public/grant_table.h || die
149 use arm && myopt="${myopt} CONFIG_EARLY_PRINTK=sun7i"
151 use debug && myopt="${myopt} debug=y"
153 if use custom-cflags; then
154 filter-flags -fPIE -fstack-protector
155 replace-flags -O3 -O2
164 # Send raw LDFLAGS so that --as-needed works
165 emake V=1 CC="$(tc-getCC)" LDFLAGS="$(raw-ldflags)" LD="$(tc-getLD)" -C xen ${myopt}
170 use debug && myopt="${myopt} debug=y"
172 # The 'make install' doesn't 'mkdir -p' the subdirs
174 mkdir -p "${D}"${EFI_MOUNTPOINT}/efi/${EFI_VENDOR} || die
177 emake LDFLAGS="$(raw-ldflags)" DESTDIR="${D}" -C xen ${myopt} install
179 # make install likes to throw in some extra EFI bits if it built
180 use efi || rm -rf "${D}/usr/$(get_libdir)/efi"
184 elog "Official Xen Guide and the unoffical wiki page:"
185 elog " https://wiki.gentoo.org/wiki/Xen"
186 elog " http://en.gentoo-wiki.com/wiki/Xen/"
188 use efi && einfo "The efi executable is installed in boot/efi/gentoo"
190 elog "You can optionally block the installation of /boot/xen-syms by an entry"
191 elog "in folder /etc/portage/env using the portage's feature INSTALL_MASK"
192 elog "e.g. echo ${msg} > /etc/portage/env/xen.conf"