# Copyright 1999-2019 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=7 # Change this when you update the ebuild GIT_COMMIT="567e41ff6b096a478333c804d5c18264050bc3f8" EGO_PN="github.com/hashicorp/${PN}" inherit golang-vcs-snapshot-r1 systemd user DESCRIPTION="A tool for service discovery, monitoring and configuration" HOMEPAGE="https://www.consul.io" SRC_URI="https://${EGO_PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz" RESTRICT="mirror test" LICENSE="MPL-2.0" SLOT="0" KEYWORDS="~amd64" IUSE="debug pie static" DOCS=( CHANGELOG.md README.md ) QA_PRESTRIPPED="usr/bin/.*" G="${WORKDIR}/${P}" S="${G}/src/${EGO_PN}" pkg_setup() { enewgroup consul enewuser consul -1 -1 /var/lib/consul consul } src_compile() { export GOPATH="${G}" export CGO_CFLAGS="${CFLAGS}" export CGO_LDFLAGS="${LDFLAGS}" (use static && ! use pie) && export CGO_ENABLED=0 (use static && use pie) && CGO_LDFLAGS+=" -static" local myldflags=( "$(usex !debug '-s -w' '')" -X "${EGO_PN}/version.GitCommit=${GIT_COMMIT:0:7}" -X "${EGO_PN}/version.GitDescribe=v${PV/_*}" ) local mygoargs=( -v -work -x -buildmode "$(usex pie pie exe)" -asmflags "all=-trimpath=${S}" -gcflags "all=-trimpath=${S}" -ldflags "${myldflags[*]}" -tags "$(usex static 'netgo' '')" -installsuffix "$(usex static 'netgo' '')" ) go build "${mygoargs[@]}" || die } src_install() { dobin consul use debug && dostrip -x /usr/bin/consul einstalldocs newinitd "${FILESDIR}/${PN}.initd" "${PN}" newconfd "${FILESDIR}/${PN}.confd" "${PN}" systemd_dounit "${FILESDIR}/${PN}.service" insinto /etc/consul.d doins "${FILESDIR}"/*.example insinto /etc/logrotate.d newins "${FILESDIR}/${PN}.logrotate" "${PN}" diropts -o consul -g consul -m 0750 keepdir /var/log/consul }