xen-tools-4.8.0-r4.ebuild 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. PYTHON_COMPAT=( python2_7 )
  5. PYTHON_REQ_USE='ncurses,xml,threads'
  6. inherit eutils bash-completion-r1 flag-o-matic multilib python-single-r1 toolchain-funcs versionator
  7. MY_PV=${PV/_/-}
  8. MAJOR_V="$(get_version_component_range 1-2)"
  9. if [[ $PV == *9999 ]]; then
  10. inherit git-r3
  11. KEYWORDS=""
  12. REPO="xen.git"
  13. EGIT_REPO_URI="git://xenbits.xen.org/${REPO}"
  14. S="${WORKDIR}/${REPO}"
  15. else
  16. KEYWORDS="~amd64 ~arm ~arm64 ~x86"
  17. UPSTREAM_VER=
  18. SECURITY_VER=23
  19. # xen-tools's gentoo patches tarball
  20. GENTOO_VER=9
  21. # xen-tools's gentoo patches version which apply to this specific ebuild
  22. GENTOO_GPV=1
  23. # xen-tools ovmf's patches
  24. OVMF_VER=2
  25. SEABIOS_VER=1.10.0
  26. # OVMF upstream 52a99493cce88a9d4ec8a02d7f1bd1a1001ce60d
  27. OVMF_PV=20151110
  28. [[ -n ${UPSTREAM_VER} ]] && \
  29. UPSTREAM_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${P/-tools/}-upstream-patches-${UPSTREAM_VER}.tar.xz"
  30. [[ -n ${SECURITY_VER} ]] && \
  31. SECURITY_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${PN/-tools}-security-patches-${SECURITY_VER}.tar.xz"
  32. [[ -n ${GENTOO_VER} ]] && \
  33. GENTOO_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${PN/-tools}-gentoo-patches-${GENTOO_VER}.tar.xz"
  34. [[ -n ${OVMF_VER} ]] && \
  35. OVMF_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${PN/-tools}-ovmf-patches-${OVMF_VER}.tar.xz"
  36. SRC_URI="http://bits.xensource.com/oss-xen/release/${MY_PV}/xen-${MY_PV}.tar.gz
  37. http://code.coreboot.org/p/seabios/downloads/get/seabios-${SEABIOS_VER}.tar.gz
  38. https://dev.gentoo.org/~dlan/distfiles/seabios-${SEABIOS_VER}.tar.gz
  39. ovmf? ( https://dev.gentoo.org/~dlan/distfiles/ovmf-${OVMF_PV}.tar.bz2
  40. ${OVMF_PATCHSET_URI} )
  41. ${UPSTREAM_PATCHSET_URI}
  42. ${SECURITY_PATCHSET_URI}
  43. ${GENTOO_PATCHSET_URI}"
  44. S="${WORKDIR}/xen-${MY_PV}"
  45. fi
  46. DESCRIPTION="Xen tools including QEMU and xl"
  47. HOMEPAGE="http://xen.org/"
  48. DOCS=( README docs/README.xen-bugtool )
  49. LICENSE="GPL-2"
  50. SLOT="0/${MAJOR_V}"
  51. # Inclusion of IUSE ocaml on stabalizing requires maintainer of ocaml to (get off his hands and) make
  52. # >=dev-lang/ocaml-4 stable
  53. # Masked in profiles/eapi-5-files instead
  54. IUSE="api custom-cflags debug doc flask hvm +qemu ocaml ovmf +qemu-traditional +pam python pygrub screen sdl static-libs system-qemu system-seabios"
  55. REQUIRED_USE="
  56. ${PYTHON_REQUIRED_USE}
  57. pygrub? ( python )
  58. ovmf? ( hvm )
  59. ^^ ( qemu system-qemu )"
  60. COMMON_DEPEND="
  61. dev-libs/lzo:2
  62. dev-libs/glib:2
  63. dev-libs/yajl
  64. dev-libs/libaio
  65. dev-libs/libgcrypt:0
  66. sys-libs/zlib
  67. "
  68. DEPEND="${COMMON_DEPEND}
  69. dev-python/lxml[${PYTHON_USEDEP}]
  70. x86? ( sys-devel/dev86
  71. sys-power/iasl )
  72. pam? ( dev-python/pypam[${PYTHON_USEDEP}] )
  73. ${PYTHON_DEPS}
  74. api? ( dev-libs/libxml2
  75. net-misc/curl )
  76. ovmf? (
  77. !arm? ( dev-lang/nasm )
  78. $(python_gen_impl_dep sqlite)
  79. )
  80. !amd64? ( >=sys-apps/dtc-1.4.0 )
  81. amd64? ( sys-devel/bin86
  82. system-seabios? ( sys-firmware/seabios )
  83. sys-firmware/ipxe
  84. sys-devel/dev86
  85. sys-power/iasl )
  86. dev-lang/perl
  87. app-misc/pax-utils
  88. doc? (
  89. app-doc/doxygen
  90. dev-python/markdown[${PYTHON_USEDEP}]
  91. dev-tex/latex2html[png,gif]
  92. media-gfx/graphviz
  93. dev-tex/xcolor
  94. media-gfx/transfig
  95. dev-texlive/texlive-latexextra
  96. virtual/latex-base
  97. dev-tex/latexmk
  98. dev-texlive/texlive-latex
  99. dev-texlive/texlive-pictures
  100. dev-texlive/texlive-latexrecommended
  101. )
  102. hvm? ( x11-proto/xproto
  103. !net-libs/libiscsi )
  104. qemu? (
  105. x11-libs/pixman
  106. sdl? ( media-libs/libsdl[X] )
  107. )
  108. system-qemu? ( app-emulation/qemu[xen] )
  109. ocaml? ( dev-ml/findlib
  110. >=dev-lang/ocaml-4 )"
  111. RDEPEND="${COMMON_DEPEND}
  112. sys-apps/iproute2[-minimal]
  113. net-misc/bridge-utils
  114. screen? (
  115. app-misc/screen
  116. app-admin/logrotate
  117. )"
  118. # hvmloader is used to bootstrap a fully virtualized kernel
  119. # Approved by QA team in bug #144032
  120. QA_WX_LOAD="usr/lib/xen/boot/hvmloader
  121. usr/share/qemu-xen/qemu/s390-ccw.img"
  122. RESTRICT="test"
  123. pkg_setup() {
  124. python_setup
  125. export "CONFIG_LOMOUNT=y"
  126. #bug 522642, disable compile tools/tests
  127. export "CONFIG_TESTS=n"
  128. if [[ -z ${XEN_TARGET_ARCH} ]] ; then
  129. if use x86 && use amd64; then
  130. die "Confusion! Both x86 and amd64 are set in your use flags!"
  131. elif use x86; then
  132. export XEN_TARGET_ARCH="x86_32"
  133. elif use amd64 ; then
  134. export XEN_TARGET_ARCH="x86_64"
  135. elif use arm; then
  136. export XEN_TARGET_ARCH="arm32"
  137. elif use arm64; then
  138. export XEN_TARGET_ARCH="arm64"
  139. else
  140. die "Unsupported architecture!"
  141. fi
  142. fi
  143. }
  144. src_prepare() {
  145. # Upstream's patchset
  146. if [[ -n ${UPSTREAM_VER} ]]; then
  147. einfo "Try to apply Xen Upstream patch set"
  148. EPATCH_SUFFIX="patch" \
  149. EPATCH_FORCE="yes" \
  150. EPATCH_OPTS="-p1" \
  151. epatch "${WORKDIR}"/patches-upstream
  152. fi
  153. # Security patchset
  154. if [[ -n ${SECURITY_VER} ]]; then
  155. einfo "Try to apply Xen Security patch set"
  156. # apply main xen patches
  157. # Two parallel systems, both work side by side
  158. # Over time they may concdense into one. This will suffice for now
  159. EPATCH_SUFFIX="patch"
  160. EPATCH_FORCE="yes"
  161. source "${WORKDIR}"/patches-security/${PV}.conf
  162. for i in ${XEN_SECURITY_MAIN}; do
  163. epatch "${WORKDIR}"/patches-security/xen/$i
  164. done
  165. # apply qemu-xen/upstream patches
  166. pushd "${S}"/tools/qemu-xen/ > /dev/null
  167. for i in ${XEN_SECURITY_QEMUU}; do
  168. epatch "${WORKDIR}"/patches-security/qemuu/$i
  169. done
  170. popd > /dev/null
  171. # apply qemu-traditional patches
  172. pushd "${S}"/tools/qemu-xen-traditional/ > /dev/null
  173. for i in ${XEN_SECURITY_QEMUT}; do
  174. epatch "${WORKDIR}"/patches-security/qemut/$i
  175. done
  176. popd > /dev/null
  177. fi
  178. # move before Gentoo patch, one patch should apply to seabios, to fix gcc-4.5.x build err
  179. mv ../seabios-${SEABIOS_VER} tools/firmware/seabios-dir-remote || die
  180. pushd tools/firmware/ > /dev/null
  181. ln -s seabios-dir-remote seabios-dir || die
  182. popd > /dev/null
  183. # Gentoo's patchset
  184. if [[ -n ${GENTOO_VER} && -n ${GENTOO_GPV} ]]; then
  185. einfo "Try to apply Gentoo specific patch set"
  186. source "${FILESDIR}"/gentoo-patches.conf
  187. _gpv=_gpv_${PN/-/_}_${PV//./}_${GENTOO_GPV}
  188. for i in ${!_gpv}; do
  189. EPATCH_SUFFIX="patch" \
  190. EPATCH_FORCE="yes" \
  191. epatch "${WORKDIR}"/patches-gentoo/$i
  192. done
  193. fi
  194. # Ovmf's patchset
  195. if use ovmf; then
  196. if [[ -n ${OVMF_VER} ]];then
  197. einfo "Try to apply Ovmf patch set"
  198. pushd "${WORKDIR}"/ovmf-*/ > /dev/null
  199. EPATCH_SUFFIX="patch" \
  200. EPATCH_FORCE="yes" \
  201. EPATCH_OPTS="-p1" \
  202. epatch "${WORKDIR}"/patches-ovmf
  203. popd > /dev/null
  204. fi
  205. mv ../ovmf-${OVMF_PV} tools/firmware/ovmf-dir-remote || die
  206. fi
  207. mv tools/qemu-xen/qemu-bridge-helper.c tools/qemu-xen/xen-bridge-helper.c || die
  208. # Fix texi2html build error with new texi2html, qemu.doc.html
  209. sed -i -e "/texi2html -monolithic/s/-number//" tools/qemu-xen-traditional/Makefile || die
  210. use api || sed -e "/SUBDIRS-\$(LIBXENAPI_BINDINGS) += libxen/d" -i tools/Makefile || die
  211. sed -e 's:$(MAKE) PYTHON=$(PYTHON) subdirs-$@:LC_ALL=C "$(MAKE)" PYTHON=$(PYTHON) subdirs-$@:' \
  212. -i tools/firmware/Makefile || die
  213. # Drop .config, fixes to gcc-4.6
  214. sed -e '/-include $(XEN_ROOT)\/.config/d' -i Config.mk || die "Couldn't drop"
  215. # if the user *really* wants to use their own custom-cflags, let them
  216. if use custom-cflags; then
  217. einfo "User wants their own CFLAGS - removing defaults"
  218. # try and remove all the default cflags
  219. find "${S}" \( -name Makefile -o -name Rules.mk -o -name Config.mk \) \
  220. -exec sed \
  221. -e 's/CFLAGS\(.*\)=\(.*\)-O3\(.*\)/CFLAGS\1=\2\3/' \
  222. -e 's/CFLAGS\(.*\)=\(.*\)-march=i686\(.*\)/CFLAGS\1=\2\3/' \
  223. -e 's/CFLAGS\(.*\)=\(.*\)-fomit-frame-pointer\(.*\)/CFLAGS\1=\2\3/' \
  224. -e 's/CFLAGS\(.*\)=\(.*\)-g3*\s\(.*\)/CFLAGS\1=\2 \3/' \
  225. -e 's/CFLAGS\(.*\)=\(.*\)-O2\(.*\)/CFLAGS\1=\2\3/' \
  226. -i {} + || die "failed to re-set custom-cflags"
  227. else
  228. unset CFLAGS
  229. unset LDFLAGS
  230. unset ASFLAGS
  231. unset CPPFLAGS
  232. fi
  233. if ! use pygrub; then
  234. sed -e '/^SUBDIRS-y += pygrub/d' -i tools/Makefile || die
  235. fi
  236. if ! use python; then
  237. sed -e '/^SUBDIRS-y += python$/d' -i tools/Makefile || die
  238. fi
  239. if ! use hvm; then
  240. sed -e '/SUBDIRS-$(CONFIG_X86) += firmware/d' -i tools/Makefile || die
  241. # Bug 351648
  242. elif ! use x86 && ! has x86 $(get_all_abis); then
  243. mkdir -p "${WORKDIR}"/extra-headers/gnu || die
  244. touch "${WORKDIR}"/extra-headers/gnu/stubs-32.h || die
  245. export CPATH="${WORKDIR}"/extra-headers
  246. fi
  247. if use qemu; then
  248. if use sdl; then
  249. sed -i -e "s:\$\$source/configure:\0 --enable-sdl:" \
  250. tools/Makefile || die
  251. else
  252. sed -i -e "s:\${QEMU_ROOT\:\-\.}/configure:\0 --disable-sdl:" \
  253. tools/qemu-xen-traditional/xen-setup || die
  254. sed -i -e "s:\$\$source/configure:\0 --disable-sdl:" \
  255. tools/Makefile || die
  256. fi
  257. else
  258. # Don't bother with qemu, only needed for fully virtualised guests
  259. sed -e "s:install-tools\: tools/qemu-xen-traditional-dir:install-tools\: :g" -i Makefile || die
  260. fi
  261. # Reset bash completion dir; Bug 472438
  262. sed -e "s:^BASH_COMPLETION_DIR ?= \$(CONFIG_DIR)/bash_completion.d:BASH_COMPLETION_DIR ?= $(get_bashcompdir):" \
  263. -i Config.mk || die
  264. sed -i -e "/bash-completion/s/xl\.sh/xl/g" tools/libxl/Makefile || die
  265. # xencommons, Bug #492332, sed lighter weight than patching
  266. sed -e 's:\$QEMU_XEN -xen-domid:test -e "\$QEMU_XEN" \&\& &:' \
  267. -i tools/hotplug/Linux/init.d/xencommons.in || die
  268. # respect multilib, usr/lib/libcacard.so.0.0.0
  269. sed -e "/^libdir=/s/\/lib/\/$(get_libdir)/" \
  270. -i tools/qemu-xen/configure || die
  271. #bug 518136, don't build 32bit exactuable for nomultilib profile
  272. if [[ "${ARCH}" == 'amd64' ]] && ! has_multilib_profile; then
  273. sed -i -e "/x86_emulator/d" tools/tests/Makefile || die
  274. fi
  275. # use /var instead of /var/lib, consistat with previous ebuild
  276. sed -i -e "/XEN_LOCK_DIR=/s/\$localstatedir/\/var/g" \
  277. m4/paths.m4 configure tools/configure || die
  278. # use /run instead of /var/run
  279. sed -i -e "/XEN_RUN_DIR=/s/\$localstatedir//g" \
  280. m4/paths.m4 configure tools/configure || die
  281. # uncomment lines in xl.conf
  282. sed -e 's:^#autoballoon=:autoballoon=:' \
  283. -e 's:^#lockfile=:lockfile=:' \
  284. -e 's:^#vif.default.script=:vif.default.script=:' \
  285. -i tools/examples/xl.conf || die
  286. # Bug #575868 converted to a sed statement, typo of one char
  287. sed -e "s:granter’s:granter's:" -i xen/include/public/grant_table.h || die
  288. epatch_user
  289. }
  290. src_configure() {
  291. local myconf="--prefix=${PREFIX}/usr \
  292. --libdir=${PREFIX}/usr/$(get_libdir) \
  293. --libexecdir=${PREFIX}/usr/libexec \
  294. --disable-werror \
  295. --disable-xen \
  296. --enable-tools \
  297. --enable-docs \
  298. $(use_enable pam) \
  299. $(use_enable api xenapi) \
  300. $(use_enable ovmf) \
  301. $(use_enable ocaml ocamltools) \
  302. --with-xenstored=$(usex ocaml 'oxenstored' 'xenstored') \
  303. "
  304. use system-seabios && myconf+=" --with-system-seabios=/usr/share/seabios/bios.bin"
  305. use system-qemu && myconf+=" --with-system-qemu=/usr/bin/qemu-system-x86_64"
  306. use amd64 && myconf+=" $(use_enable qemu-traditional)"
  307. econf ${myconf}
  308. }
  309. src_compile() {
  310. export VARTEXFONTS="${T}/fonts"
  311. local myopt
  312. use debug && myopt="${myopt} debug=y"
  313. if test-flag-CC -fno-strict-overflow; then
  314. append-flags -fno-strict-overflow
  315. fi
  316. emake V=1 CC="$(tc-getCC)" LD="$(tc-getLD)" AR="$(tc-getAR)" RANLIB="$(tc-getRANLIB)" -C tools ${myopt}
  317. use doc && emake -C docs txt html
  318. emake -C docs man-pages
  319. }
  320. src_install() {
  321. # Override auto-detection in the build system, bug #382573
  322. export INITD_DIR=/tmp/init.d
  323. export CONFIG_LEAF_DIR=../tmp/default
  324. # Let the build system compile installed Python modules.
  325. local PYTHONDONTWRITEBYTECODE
  326. export PYTHONDONTWRITEBYTECODE
  327. emake DESTDIR="${ED}" DOCDIR="/usr/share/doc/${PF}" \
  328. XEN_PYTHON_NATIVE_INSTALL=y install-tools
  329. # Fix the remaining Python shebangs.
  330. python_fix_shebang "${D}"
  331. # Remove RedHat-specific stuff
  332. rm -rf "${D}"tmp || die
  333. if use doc; then
  334. emake DESTDIR="${D}" DOCDIR="/usr/share/doc/${PF}" install-docs
  335. dohtml -r docs/
  336. docinto pdf
  337. dodoc ${DOCS[@]}
  338. [ -d "${D}"/usr/share/doc/xen ] && mv "${D}"/usr/share/doc/xen/* "${D}"/usr/share/doc/${PF}/html
  339. fi
  340. rm -rf "${D}"/usr/share/doc/xen/
  341. doman docs/man?/*
  342. newconfd "${FILESDIR}"/xendomains.confd xendomains
  343. newconfd "${FILESDIR}"/xenstored.confd xenstored
  344. newconfd "${FILESDIR}"/xenconsoled.confd xenconsoled
  345. newinitd "${FILESDIR}"/xendomains.initd-r2 xendomains
  346. newinitd "${FILESDIR}"/xenstored.initd xenstored
  347. newinitd "${FILESDIR}"/xenconsoled.initd xenconsoled
  348. newinitd "${FILESDIR}"/xencommons.initd xencommons
  349. newconfd "${FILESDIR}"/xencommons.confd xencommons
  350. newinitd "${FILESDIR}"/xenqemudev.initd xenqemudev
  351. newconfd "${FILESDIR}"/xenqemudev.confd xenqemudev
  352. if use screen; then
  353. cat "${FILESDIR}"/xendomains-screen.confd >> "${D}"/etc/conf.d/xendomains || die
  354. cp "${FILESDIR}"/xen-consoles.logrotate "${D}"/etc/xen/ || die
  355. keepdir /var/log/xen-consoles
  356. fi
  357. # For -static-libs wrt Bug 384355
  358. if ! use static-libs; then
  359. rm -f "${D}"usr/$(get_libdir)/*.a "${D}"usr/$(get_libdir)/ocaml/*/*.a
  360. fi
  361. # for xendomains
  362. keepdir /etc/xen/auto
  363. # Remove files failing QA AFTER emake installs them, avoiding seeking absent files
  364. find "${D}" \( -name openbios-sparc32 -o -name openbios-sparc64 \
  365. -o -name openbios-ppc -o -name palcode-clipper \) -delete || die
  366. }
  367. pkg_postinst() {
  368. elog "Official Xen Guide and the offical wiki page:"
  369. elog "https://wiki.gentoo.org/wiki/Xen"
  370. elog "http://wiki.xen.org/wiki/Main_Page"
  371. elog ""
  372. elog "Recommended to utilise the xencommons script to config sytem At boot"
  373. elog "Add by use of rc-update on completion of the install"
  374. if ! use hvm; then
  375. echo
  376. elog "HVM (VT-x and AMD-V) support has been disabled. If you need hvm"
  377. elog "support enable the hvm use flag."
  378. elog "An x86 or amd64 system is required to build HVM support."
  379. fi
  380. if use qemu; then
  381. elog "The qemu-bridge-helper is renamed to the xen-bridge-helper in the in source"
  382. elog "build of qemu. This allows for app-emulation/qemu to be emerged concurrently"
  383. elog "with the qemu capable xen. It is up to the user to distinguish between and utilise"
  384. elog "the qemu-bridge-helper and the xen-bridge-helper. File bugs of any issues that arise"
  385. fi
  386. }