summaryrefslogtreecommitdiff
blob: dead9aa20ac7b4a10e860ae7d3d3d05375b15150 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=5

DESCRIPTION="tool for service discovery, monitoring and configuration."
HOMEPAGE="http://www.consul.io"
SRC_URI=""

EGIT_REPO_URI="git://github.com/hashicorp/consul.git"
S="${WORKDIR}/src/github.com/hashicorp/${PN}"

if [[ ${PV} == *9999 ]]; then
	KEYWORDS=""
else
	EGIT_COMMIT="v${PV}"
	KEYWORDS="~amd64 ~x86"
fi

inherit git-2 user

LICENSE="MPL-2.0"
SLOT="0"
IUSE="web"

DEPEND=">=dev-lang/go-1.4
	dev-vcs/git
	dev-vcs/mercurial
	web? ( dev-ruby/bundler dev-ruby/sass )"
RDEPEND="${DEPEND}"

pkg_setup() {
	enewgroup consul
	enewuser consul -1 -1 /var/lib/${PN} consul
}

src_compile() {
	# create a suitable GOPATH
	export GOPATH="${WORKDIR}"

	# let's do something fun
	emake

	# build the web UI
	if use web; then
		cd ui
		bundle
		emake dist
	fi
}

src_install() {
	dobin bin/consul

	dodir /etc/consul.d

	for x in /var/{lib,log}/${PN}; do
		keepdir "${x}"
		fowners consul:consul "${x}"
	done

	if use web; then
		insinto /var/lib/${PN}/ui
		doins -r ui/dist/*
	fi

	newinitd "${FILESDIR}/consul-agent.initd" "${PN}-agent"
	newconfd "${FILESDIR}/consul-agent.confd" "${PN}-agent"
}