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/${PN}.git"
20 KEYWORDS="~amd64 ~arm ~arm64 -x86"
23 # var set to reflect https://dev.gentoo.org/~idella4/
27 [[ -n ${UPSTREAM_VER} ]] && \
28 UPSTREAM_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${P}-upstream-patches-${UPSTREAM_VER}.tar.xz"
29 [[ -n ${SECURITY_VER} ]] && \
30 SECURITY_PATCHSET_URI="https://dev.gentoo.org/~idella4/distfiles/${PN/-tools}-security-patches-${SECURITY_VER}.tar.xz
31 https://dev.gentoo.org/~idella4/distfiles/${PN/-tools}-security-patches-${SEC_VER}.tar.gz"
32 [[ -n ${GENTOO_VER} ]] && \
33 GENTOO_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${PN}-gentoo-patches-${GENTOO_VER}.tar.xz"
34 SRC_URI="http://bits.xensource.com/oss-xen/release/${MY_PV}/${MY_P}.tar.gz
35 ${UPSTREAM_PATCHSET_URI}
36 ${SECURITY_PATCHSET_URI}
37 ${GENTOO_PATCHSET_URI}"
41 DESCRIPTION="The Xen virtual machine monitor"
42 HOMEPAGE="http://xen.org/"
45 IUSE="custom-cflags debug efi flask xsm"
47 DEPEND="${PYTHON_DEPS}
48 efi? ( >=sys-devel/binutils-2.22[multitarget] )
49 !efi? ( >=sys-devel/binutils-2.22[-multitarget] )"
51 PDEPEND="~app-emulation/xen-tools-${PV}"
55 # Approved by QA team in bug #144032
56 QA_WX_LOAD="boot/xen-syms-${PV}"
58 REQUIRED_USE="flask? ( xsm )
61 S="${WORKDIR}/${MY_P}"
64 python-any-r1_pkg_setup
65 if [[ -z ${XEN_TARGET_ARCH} ]]; then
66 if use x86 && use amd64; then
67 die "Confusion! Both x86 and amd64 are set in your use flags!"
69 export XEN_TARGET_ARCH="x86_32"
71 export XEN_TARGET_ARCH="x86_64"
73 export XEN_TARGET_ARCH="arm32"
75 export XEN_TARGET_ARCH="arm64"
77 die "Unsupported architecture!"
83 export "FLASK_ENABLE=y"
91 if [[ -n ${UPSTREAM_VER} ]]; then
92 EPATCH_SUFFIX="patch" \
95 epatch "${WORKDIR}"/patches-upstream
98 if [[ -n ${SECURITY_VER} ]]; then
99 einfo "Try to apply Xen Security patcheset"
100 # apply main xen patches
101 # Two parallel systems, both work side by side
102 # Over time they may concdense into one. This will suffice for now
103 EPATCH_SUFFIX="patch"
105 for i in ${XEN_SECURITY_MAIN}; do
106 epatch "${WORKDIR}"/patches-security/xen/$i
109 for i in "${WORKDIR}"/xen-sec/xsa*.patch; do
115 if [[ -n ${GENTOO_VER} ]]; then
116 EPATCH_SUFFIX="patch" \
118 epatch "${WORKDIR}"/patches-gentoo
122 sed -e '/-include $(XEN_ROOT)\/.config/d' -i Config.mk || die "Couldn't drop"
125 epatch "${FILESDIR}"/${PN}-4.5-efi.patch
126 export EFI_VENDOR="gentoo"
127 export EFI_MOUNTPOINT="boot"
130 # if the user *really* wants to use their own custom-cflags, let them
131 if use custom-cflags; then
132 einfo "User wants their own CFLAGS - removing defaults"
133 # try and remove all the default custom-cflags
134 find "${S}" -name Makefile -o -name Rules.mk -o -name Config.mk -exec sed \
135 -e 's/CFLAGS\(.*\)=\(.*\)-O3\(.*\)/CFLAGS\1=\2\3/' \
136 -e 's/CFLAGS\(.*\)=\(.*\)-march=i686\(.*\)/CFLAGS\1=\2\3/' \
137 -e 's/CFLAGS\(.*\)=\(.*\)-fomit-frame-pointer\(.*\)/CFLAGS\1=\2\3/' \
138 -e 's/CFLAGS\(.*\)=\(.*\)-g3*\s\(.*\)/CFLAGS\1=\2 \3/' \
139 -e 's/CFLAGS\(.*\)=\(.*\)-O2\(.*\)/CFLAGS\1=\2\3/' \
140 -i {} \; || die "failed to re-set custom-cflags"
143 # remove -Werror for gcc-4.6's sake
144 find "${S}" -name 'Makefile*' -o -name '*.mk' -o -name 'common.make' | \
145 xargs sed -i 's/ *-Werror */ /'
146 # not strictly necessary to fix this
147 sed -i 's/, "-Werror"//' "${S}/tools/python/setup.py" || die "failed to re-set setup.py"
153 use arm && myopt="${myopt} CONFIG_EARLY_PRINTK=sun7i"
155 use debug && myopt="${myopt} debug=y"
157 if use custom-cflags; then
158 filter-flags -fPIE -fstack-protector
159 replace-flags -O3 -O2
166 # Send raw LDFLAGS so that --as-needed works
167 emake V=1 CC="$(tc-getCC)" LDFLAGS="$(raw-ldflags)" LD="$(tc-getLD)" -C xen ${myopt}
172 use debug && myopt="${myopt} debug=y"
174 # The 'make install' doesn't 'mkdir -p' the subdirs
176 mkdir -p "${D}"${EFI_MOUNTPOINT}/efi/${EFI_VENDOR} || die
179 emake LDFLAGS="$(raw-ldflags)" DESTDIR="${D}" -C xen ${myopt} install
183 elog "Official Xen Guide and the unoffical wiki page:"
184 elog " https://wiki.gentoo.org/wiki/Xen"
185 elog " http://en.gentoo-wiki.com/wiki/Xen/"
187 use efi && einfo "The efi executable is installed in boot/efi/gentoo"
189 elog "You can optionally block the installation of /boot/xen-syms by an entry"
190 elog "in folder /etc/portage/env using the portage's feature INSTALL_MASK"
191 elog "e.g. echo ${msg} > /etc/portage/env/xen.conf"