1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit git-r3 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"
13 EGIT_REPO_URI="git://${GO_PN}.git"
19 DEPEND=">=dev-lang/go-1.4:=
21 test? ( dev-go/go-tools )
30 S="${WORKDIR}/src/${GO_PN}"
31 EGIT_CHECKOUT_DIR="${S}"
35 enewuser consul -1 -1 /var/lib/${PN} consul
42 # Create a writable GOROOT in order to avoid sandbox violations
43 # or other interference from installed instances.
44 export GOPATH="${WORKDIR}:$(get_golibdir_gopath)" GOROOT="${WORKDIR}/goroot"
45 cp -sR "${EPREFIX}"/usr/lib/go "${GOROOT}" || die
47 # Use latest versions of some packages, in case of incompatible
49 rm -rf "${GOROOT}/src/${GO_PN%/*}" \
50 "${GOROOT}/pkg/linux_${ARCH}/${GO_PN%/*}" || die
55 # Avoid interference from installed instances
56 while read -r path; do
57 rm -rf "${GOROOT}/src/${path#${WORKDIR}/src}" \
58 "${GOROOT}/pkg/linux_${ARCH}/${path#${WORKDIR}/src}" || die
59 done < <(find "${WORKDIR}"/src -maxdepth 3 -mindepth 3 -type d)
63 # Disable tests that fail under network-sandbox
64 sed -e 's:TestServer_StartStop:_TestServer_StartStop:' \
65 -i consul/server_test.go || die
66 sed -e 's:TestRetryJoin(:_TestRetryJoin(:' \
67 -i command/agent/command_test.go || die
74 pushd ui >/dev/null || die
87 doins "${FILESDIR}/"*.json.example
89 for x in /var/{lib,log}/${PN}; do
91 fowners consul:consul "${x}"
95 insinto /var/lib/${PN}/ui
99 newinitd "${FILESDIR}/consul.initd" "${PN}"
100 newconfd "${FILESDIR}/consul.confd" "${PN}"
101 systemd_dounit "${FILESDIR}/consul.service"
103 find "${WORKDIR}"/{pkg,src} -name '.git*' -exec rm -rf {} \; 2>/dev/null
104 find "${WORKDIR}"/src/${GO_PN} -mindepth 1 -maxdepth 1 -type f -delete
105 while read -r -d '' x; do
106 x=${x#${WORKDIR}/src}
107 [[ -d ${WORKDIR}/pkg/${KERNEL}_${ARCH}/${x} ||
108 -f ${WORKDIR}/pkg/${KERNEL}_${ARCH}/${x}.a ]] && continue
109 rm -rf "${WORKDIR}"/src/${x}
110 done < <(find "${WORKDIR}"/src/${GO_PN} -mindepth 1 -maxdepth 1 -type d -print0)
111 insopts -m0644 -p # preserve timestamps for bug 551486
112 insinto /usr/lib/go/pkg/${KERNEL}_${ARCH}/${GO_PN%/*}
113 doins -r "${WORKDIR}"/pkg/${KERNEL}_${ARCH}/${GO_PN}
114 insinto /usr/lib/go/src/${GO_PN%/*}
115 doins -r "${WORKDIR}"/src/${GO_PN}