app-emulation/xen-pvgrub: x86 stable wrt bug #615980
[gentoo.git] / app-emulation / xen-pvgrub / xen-pvgrub-4.8.0.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 PYTHON_COMPAT=( python2_7 )
7 PYTHON_REQ_USE='xml,threads'
8
9 inherit flag-o-matic eutils multilib python-single-r1 toolchain-funcs
10
11 XEN_EXTFILES_URL="http://xenbits.xensource.com/xen-extfiles"
12 LIBPCI_URL=ftp://atrey.karlin.mff.cuni.cz/pub/linux/pci
13 GRUB_URL=mirror://gnu-alpha/grub
14
15 UPSTREAM_VER=
16 [[ -n ${UPSTREAM_VER} ]] && \
17         UPSTREAM_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${P/-tools/}-upstream-patches-${UPSTREAM_VER}.tar.xz"
18
19 SRC_URI="
20                 http://bits.xensource.com/oss-xen/release/${PV}/xen-${PV}.tar.gz
21                 $GRUB_URL/grub-0.97.tar.gz
22                 $XEN_EXTFILES_URL/zlib-1.2.3.tar.gz
23                 $LIBPCI_URL/pciutils-2.2.9.tar.bz2
24                 $XEN_EXTFILES_URL/lwip-1.3.0.tar.gz
25                 $XEN_EXTFILES_URL/newlib/newlib-1.16.0.tar.gz
26                 $XEN_EXTFILES_URL/polarssl-1.1.4-gpl.tgz
27                 ${UPSTREAM_PATCHSET_URI}"
28
29 S="${WORKDIR}/xen-${PV}"
30
31 DESCRIPTION="allows to boot Xen domU kernels from a menu.lst laying inside guest filesystem"
32 HOMEPAGE="http://xen.org/"
33 LICENSE="GPL-2"
34 SLOT="0"
35 KEYWORDS="~amd64 ~x86"
36 IUSE="custom-cflags"
37
38 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
39
40 DEPEND="sys-devel/gettext
41         sys-devel/bin86
42         sys-apps/texinfo
43         x11-libs/pixman"
44
45 RDEPEND="${PYTHON_DEPS}
46         >=app-emulation/xen-tools-${PV}"
47
48 pkg_setup() {
49         python-single-r1_pkg_setup
50 }
51
52 retar-externals() {
53         # Purely to unclutter src_prepare
54         local set="grub-0.97.tar.gz lwip-1.3.0.tar.gz newlib-1.16.0.tar.gz polarssl-1.1.4-gpl.tgz zlib-1.2.3.tar.gz"
55
56         # epatch can't patch in $WORKDIR, requires a sed; Bug #455194. Patchable, but sed informative
57         sed -e s':AR=${AR-"ar rc"}:AR=${AR-"ar"}:' \
58                 -i "${WORKDIR}"/zlib-1.2.3/configure
59         sed -e 's:^AR=ar rc:AR=ar:' \
60                 -e s':$(AR) $@:$(AR) rc $@:' \
61                 -i "${WORKDIR}"/zlib-1.2.3/{Makefile,Makefile.in}
62         einfo "zlib Makefile edited"
63
64         cd "${WORKDIR}"
65         tar czp zlib-1.2.3 -f zlib-1.2.3.tar.gz
66         tar czp grub-0.97 -f grub-0.97.tar.gz
67         tar czp lwip -f lwip-1.3.0.tar.gz
68         tar czp newlib-1.16.0 -f newlib-1.16.0.tar.gz
69         tar czp polarssl-1.1.4 -f polarssl-1.1.4-gpl.tgz
70         mv $set "${S}"/stubdom/
71         einfo "tarballs moved to source"
72 }
73
74 src_prepare() {
75         # Upstream's patchset
76         if [[ -n ${UPSTREAM_VER} ]]; then
77                 einfo "Try to apply Xen Upstream patch set"
78                 EPATCH_SUFFIX="patch" \
79                 EPATCH_FORCE="yes" \
80                 EPATCH_OPTS="-p1" \
81                         epatch "${WORKDIR}"/patches-upstream
82         fi
83
84         # if the user *really* wants to use their own custom-cflags, let them
85         if use custom-cflags; then
86                 einfo "User wants their own CFLAGS - removing defaults"
87                 # try and remove all the default custom-cflags
88                 find "${S}" -name Makefile -o -name Rules.mk -o -name Config.mk -exec sed \
89                         -e 's/CFLAGS\(.*\)=\(.*\)-O3\(.*\)/CFLAGS\1=\2\3/' \
90                         -e 's/CFLAGS\(.*\)=\(.*\)-march=i686\(.*\)/CFLAGS\1=\2\3/' \
91                         -e 's/CFLAGS\(.*\)=\(.*\)-fomit-frame-pointer\(.*\)/CFLAGS\1=\2\3/' \
92                         -e 's/CFLAGS\(.*\)=\(.*\)-g3*\s\(.*\)/CFLAGS\1=\2 \3/' \
93                         -e 's/CFLAGS\(.*\)=\(.*\)-O2\(.*\)/CFLAGS\1=\2\3/' \
94                         -i {} \;
95         fi
96
97         # Patch the unmergeable newlib, fix most of the leftover gcc QA issues
98         cp "${FILESDIR}"/newlib-implicits.patch stubdom || die
99
100         # Patch stubdom/Makefile to patch insource newlib & prevent internal downloading
101         epatch "${FILESDIR}"/${PN/-pvgrub/}-4.3-externals.patch
102
103         # fix jobserver in Makefile
104         epatch "${FILESDIR}"/${PN}-4.8-jserver.patch
105
106         #Substitute for internal downloading. pciutils copied only due to the only .bz2
107         cp "${DISTDIR}"/pciutils-2.2.9.tar.bz2 ./stubdom/ || die "pciutils not copied to stubdom"
108         retar-externals || die "re-tar procedure failed"
109
110         epatch_user
111 }
112
113 src_configure() {
114         local myconf="--prefix=${PREFIX}/usr \
115                 --libdir=${PREFIX}/usr/$(get_libdir) \
116                 --libexecdir=${PREFIX}/usr/libexec \
117                 --disable-werror \
118                 --disable-xen"
119
120         econf ${myconf}
121 }
122
123 src_compile() {
124         use custom-cflags || unset CFLAGS
125         if test-flag-CC -fno-strict-overflow; then
126                 append-flags -fno-strict-overflow
127         fi
128
129         emake CC="$(tc-getCC)" LD="$(tc-getLD)" AR="$(tc-getAR)" -C tools/include
130
131         if use x86; then
132                 emake CC="$(tc-getCC)" LD="$(tc-getLD)" AR="$(tc-getAR)" \
133                 XEN_TARGET_ARCH="x86_32" -C stubdom pv-grub
134         elif use amd64; then
135                 emake CC="$(tc-getCC)" LD="$(tc-getLD)" AR="$(tc-getAR)" \
136                 XEN_TARGET_ARCH="x86_64" -C stubdom pv-grub
137                 if has_multilib_profile; then
138                         multilib_toolchain_setup x86
139                         emake CC="$(tc-getCC)" AR="$(tc-getAR)" \
140                         XEN_TARGET_ARCH="x86_32" -C stubdom pv-grub
141                 fi
142         fi
143 }
144
145 src_install() {
146         if use x86; then
147                 emake XEN_TARGET_ARCH="x86_32" DESTDIR="${D}" -C stubdom install-grub
148         fi
149         if use amd64; then
150                 emake XEN_TARGET_ARCH="x86_64" DESTDIR="${D}" -C stubdom install-grub
151                 if has_multilib_profile; then
152                         emake XEN_TARGET_ARCH="x86_32" DESTDIR="${D}" -C stubdom install-grub
153                 fi
154         fi
155 }
156
157 pkg_postinst() {
158         elog "Official Xen Guide and the offical wiki page:"
159         elog "https://wiki.gentoo.org/wiki/Xen"
160         elog "http://wiki.xen.org/wiki/Main_Page"
161 }