1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit golang-base systemd user
10 DESCRIPTION="A tool for service discovery, monitoring and configuration"
11 HOMEPAGE="http://www.consul.io"
12 GO_PN="github.com/hashicorp/consul"
18 DEPEND=">=dev-lang/go-1.4:=
20 test? ( dev-go/go-tools )
27 SRC_URI="https://github.com/hashicorp/consul/archive/v0.5.2.tar.gz -> ${P}.tar.gz
28 https://github.com/armon/circbuf/archive/f092b4f207b6e5cce0569056fba9e1a2735cb6cf.tar.gz -> circbuf-f092b4f207b6e5cce0569056fba9e1a2735cb6cf.tar.gz
29 https://github.com/armon/go-metrics/archive/a54701ebec11868993bc198c3f315353e9de2ed6.tar.gz -> go-metrics-a54701ebec11868993bc198c3f315353e9de2ed6.tar.gz
30 https://github.com/armon/go-radix/archive/0bab926c3433cfd6490c6d3c504a7b471362390c.tar.gz -> go-radix-0bab926c3433cfd6490c6d3c504a7b471362390c.tar.gz
31 https://github.com/armon/gomdb/archive/151f2e08ef45cb0e57d694b2562f351955dff572.tar.gz -> gomdb-151f2e08ef45cb0e57d694b2562f351955dff572.tar.gz
32 https://github.com/boltdb/bolt/archive/2c04100eb9793f2b8541d243494e2909d2112325.tar.gz -> bolt-2c04100eb9793f2b8541d243494e2909d2112325.tar.gz
33 https://github.com/hashicorp/consul-migrate/archive/v0.1.0.tar.gz -> consul-migrate-0.1.0.tar.gz
34 https://github.com/hashicorp/go-checkpoint/archive/88326f6851319068e7b34981032128c0b1a6524d.tar.gz -> go-checkpoint-88326f6851319068e7b34981032128c0b1a6524d.tar.gz
35 https://github.com/hashicorp/go-msgpack/archive/71c2886f5a673a35f909803f38ece5810165097b.tar.gz -> go-msgpack-71c2886f5a673a35f909803f38ece5810165097b.tar.gz
36 https://github.com/hashicorp/go-multierror/archive/fcdddc395df1ddf4247c69bd436e84cfa0733f7e.tar.gz -> go-multierror-fcdddc395df1ddf4247c69bd436e84cfa0733f7e.tar.gz
37 https://github.com/hashicorp/go-syslog/archive/42a2b573b664dbf281bd48c3cc12c086b17a39ba.tar.gz -> go-syslog-42a2b573b664dbf281bd48c3cc12c086b17a39ba.tar.gz
38 https://github.com/hashicorp/golang-lru/archive/995efda3e073b6946b175ed93901d729ad47466a.tar.gz -> golang-lru-995efda3e073b6946b175ed93901d729ad47466a.tar.gz
39 https://github.com/hashicorp/hcl/archive/513e04c400ee2e81e97f5e011c08fb42c6f69b84.tar.gz -> hcl-513e04c400ee2e81e97f5e011c08fb42c6f69b84.tar.gz
40 https://github.com/hashicorp/logutils/archive/367a65d59043b4f846d179341d138f01f988c186.tar.gz -> logutils-367a65d59043b4f846d179341d138f01f988c186.tar.gz
41 https://github.com/hashicorp/memberlist/archive/6025015f2dc659ca2c735112d37e753bda6e329d.tar.gz -> memberlist-6025015f2dc659ca2c735112d37e753bda6e329d.tar.gz
42 https://github.com/hashicorp/net-rpc-msgpackrpc/archive/d377902b7aba83dd3895837b902f6cf3f71edcb2.tar.gz -> net-rpc-msgpackrpc-d377902b7aba83dd3895837b902f6cf3f71edcb2.tar.gz
43 https://github.com/hashicorp/raft/archive/a8065f298505708bf60f518c09178149f3c06f21.tar.gz -> raft-a8065f298505708bf60f518c09178149f3c06f21.tar.gz
44 https://github.com/hashicorp/raft-boltdb/archive/d1e82c1ec3f15ee991f7cc7ffd5b67ff6f5bbaee.tar.gz -> raft-boltdb-d1e82c1ec3f15ee991f7cc7ffd5b67ff6f5bbaee.tar.gz
45 https://github.com/hashicorp/raft-mdb/archive/4ec3694ffbc74d34f7532e70ef2e9c3546a0c0b0.tar.gz -> raft-mdb-4ec3694ffbc74d34f7532e70ef2e9c3546a0c0b0.tar.gz
46 https://github.com/hashicorp/scada-client/archive/c26580cfe35393f6f4bf1b9ba55e6afe33176bae.tar.gz -> scada-client-c26580cfe35393f6f4bf1b9ba55e6afe33176bae.tar.gz
47 https://github.com/hashicorp/serf/archive/558a6876882b2c5c61df29fd3990fb1765fd71d3.tar.gz -> serf-558a6876882b2c5c61df29fd3990fb1765fd71d3.tar.gz
48 https://github.com/hashicorp/yamux/archive/b2e55852ddaf823a85c67f798080eb7d08acd71d.tar.gz -> yamux-b2e55852ddaf823a85c67f798080eb7d08acd71d.tar.gz
49 https://github.com/inconshreveable/muxado/archive/f693c7e88ba316d1a0ae3e205e22a01aa3ec2848.tar.gz -> muxado-f693c7e88ba316d1a0ae3e205e22a01aa3ec2848.tar.gz
50 https://github.com/miekg/dns/archive/bb1103f648f811d2018d4bedcb2d4b2bce34a0f1.tar.gz -> dns-bb1103f648f811d2018d4bedcb2d4b2bce34a0f1.tar.gz
51 https://github.com/mitchellh/cli/archive/6cc8bc522243675a2882b81662b0b0d2e04b99c9.tar.gz -> cli-6cc8bc522243675a2882b81662b0b0d2e04b99c9.tar.gz
52 https://github.com/mitchellh/mapstructure/archive/442e588f213303bec7936deba67901f8fc8f18b1.tar.gz -> mapstructure-442e588f213303bec7936deba67901f8fc8f18b1.tar.gz
53 https://github.com/ryanuber/columnize/archive/44cb4788b2ec3c3d158dd3d1b50aba7d66f4b59a.tar.gz -> columnize-44cb4788b2ec3c3d158dd3d1b50aba7d66f4b59a.tar.gz"
56 S="${WORKDIR}/src/${GO_PN}"
60 enewuser consul -1 -1 /var/lib/${PN} consul
63 get_archive_go_package() {
64 local archive=${1} uri x
65 for x in ${SRC_URI}; do
66 if [[ ${x} == http* ]]; then
68 elif [[ ${x} == ${archive} ]]; then
73 echo ${uri%/archive/*}
76 unpack_go_packages() {
78 # Unpack packages to appropriate locations for GOPATH
81 if [[ ${x} == *.tar.gz ]]; then
82 go_package=$(get_archive_go_package ${x})
83 mkdir -p src/${go_package%/*}
84 mv ${go_package##*/}-* src/${go_package} || die
91 # Create a writable GOROOT in order to avoid sandbox violations
92 # or other interference from installed instances.
93 export GOPATH="${WORKDIR}:$(get_golibdir_gopath)" GOROOT="${WORKDIR}/goroot"
94 cp -sR "${EPREFIX}"/usr/lib/go "${GOROOT}" || die
95 while read -r path; do
96 rm -rf "${GOROOT}/src/${path#${WORKDIR}/src}" \
97 "${GOROOT}/pkg/linux_${ARCH}/${path#${WORKDIR}/src}" || die
98 done < <(find "${WORKDIR}"/src -maxdepth 3 -mindepth 3 -type d)
102 # Avoid the need to have a git checkout
103 sed -e 's:^GIT.*::' \
104 -e 's:-X main.GitCommit.*:" \\:' \
105 -i scripts/build.sh || die
107 # Disable tests that fail under network-sandbox
108 sed -e 's:TestServer_StartStop:_TestServer_StartStop:' \
109 -i consul/server_test.go || die
110 sed -e 's:TestRetryJoin(:_TestRetryJoin(:' \
111 -i command/agent/command_test.go || die
118 pushd ui >/dev/null || die
129 keepdir /etc/consul.d
130 insinto /etc/consul.d
131 doins "${FILESDIR}/"*.json.example
133 for x in /var/{lib,log}/${PN}; do
135 fowners consul:consul "${x}"
139 insinto /var/lib/${PN}/ui
143 newinitd "${FILESDIR}/consul.initd" "${PN}"
144 newconfd "${FILESDIR}/consul.confd" "${PN}"
145 systemd_dounit "${FILESDIR}/consul.service"
147 find "${WORKDIR}"/{pkg,src} -name '.git*' -exec rm -rf {} \; 2>/dev/null
148 find "${WORKDIR}"/src/${GO_PN} -mindepth 1 -maxdepth 1 -type f -delete
149 while read -r -d '' x; do
150 x=${x#${WORKDIR}/src}
151 [[ -d ${WORKDIR}/pkg/${KERNEL}_${ARCH}/${x} ||
152 -f ${WORKDIR}/pkg/${KERNEL}_${ARCH}/${x}.a ]] && continue
153 rm -rf "${WORKDIR}"/src/${x}
154 done < <(find "${WORKDIR}"/src/${GO_PN} -mindepth 1 -maxdepth 1 -type d -print0)
155 insopts -m0644 -p # preserve timestamps for bug 551486
156 insinto /usr/lib/go/pkg/${KERNEL}_${ARCH}/${GO_PN%/*}
157 doins -r "${WORKDIR}"/pkg/${KERNEL}_${ARCH}/${GO_PN}
158 insinto /usr/lib/go/src/${GO_PN%/*}
159 doins -r "${WORKDIR}"/src/${GO_PN}