app-emulation/rkt: fix kvm when coreos stage1 is disabled, + makefile tweaks
[gentoo.git] / app-emulation / rkt / rkt-0.8.0.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 AUTOTOOLS_AUTORECONF=yes
8 AUTOTOOLS_IN_SOURCE_BUILD=yes
9
10 inherit autotools-utils flag-o-matic systemd toolchain-funcs
11
12 KEYWORDS="~amd64"
13
14 PXE_VERSION="738.1.0"
15 PXE_URI="http://alpha.release.core-os.net/amd64-usr/${PXE_VERSION}/coreos_production_pxe_image.cpio.gz"
16 PXE_FILE="${PN}-pxe-${PXE_VERSION}.img"
17
18 SRC_URI="https://github.com/coreos/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz
19 rkt_stage1_coreos? ( $PXE_URI -> $PXE_FILE )"
20
21 DESCRIPTION="A CLI for running app containers, and an implementation of the App
22 Container Spec."
23 HOMEPAGE="https://github.com/coreos/rkt"
24
25 LICENSE="Apache-2.0"
26 SLOT="0"
27 IUSE="doc examples +rkt_stage1_coreos rkt_stage1_src +actool systemd"
28 REQUIRED_USE="^^ ( rkt_stage1_coreos rkt_stage1_src )"
29
30 DEPEND=">=dev-lang/go-1.4.1
31         app-arch/cpio
32         sys-fs/squashfs-tools
33         dev-perl/Capture-Tiny
34         rkt_stage1_src? (
35                 >=sys-apps/systemd-222
36                 app-shells/bash:0
37         )"
38 RDEPEND="!app-emulation/rocket"
39
40 BUILDDIR="build-${P}"
41
42 src_configure() {
43         local myeconfargs=(
44                 --with-stage1-image-path="/usr/share/rkt/stage1.aci"
45         )
46
47         if use rkt_stage1_src; then
48                 myeconfargs+=( --with-stage1="src" )
49         elif use rkt_stage1_coreos; then
50                 myeconfargs+=( --with-stage1="coreos" )
51                 mkdir -p "${BUILDDIR}/tmp/usr_from_coreos/" || die
52                 cp "${DISTDIR}/${PXE_FILE}" "${BUILDDIR}/tmp/usr_from_coreos/pxe.img" || die
53         fi
54
55         # Go's 6l linker does not support PIE, disable so cgo binaries
56         # which use 6l+gcc for linking can be built correctly.
57         if gcc-specs-pie; then
58                 append-ldflags -nopie
59         fi
60
61         export CC=$(tc-getCC)
62         export CGO_ENABLED=1
63         export CGO_CFLAGS="${CFLAGS}"
64         export CGO_CPPFLAGS="${CPPFLAGS}"
65         export CGO_CXXFLAGS="${CXXFLAGS}"
66         export CGO_LDFLAGS="${LDFLAGS}"
67         export BUILDDIR
68
69         autotools-utils_src_configure
70 }
71
72 src_install() {
73         dodoc README.md
74         use doc && dodoc -r Documentation
75         use examples && dodoc -r examples
76         use actool && dobin "${S}/${BUILDDIR}/bin/actool"
77
78         dobin "${S}/${BUILDDIR}/bin/rkt"
79
80         insinto /usr/share/rkt/
81         doins "${S}/${BUILDDIR}/bin/stage1.aci"
82
83         systemd_dounit "${S}"/dist/init/systemd/${PN}-gc.service
84         systemd_dounit "${S}"/dist/init/systemd/${PN}-gc.timer
85         systemd_dounit "${S}"/dist/init/systemd/${PN}-metadata.service
86         systemd_dounit "${S}"/dist/init/systemd/${PN}-metadata.socket
87 }