# Copyright 1999-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 EAPI=6 EGO_PN="github.com/prometheus/${PN}" GIT_COMMIT="c93e278" # Change this when you update the ebuild inherit golang-vcs-snapshot systemd user DESCRIPTION="Push acceptor for ephemeral and batch jobs to expose their metrics to Prometheus" HOMEPAGE="https://prometheus.io" SRC_URI="https://${EGO_PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz" RESTRICT="mirror" LICENSE="Apache-2.0" SLOT="0" KEYWORDS="~amd64" IUSE="pie" DOCS=( NOTICE {CHANGELOG,README}.md ) QA_PRESTRIPPED="usr/bin/pushgateway" G="${WORKDIR}/${P}" S="${G}/src/${EGO_PN}" pkg_setup() { enewgroup pushgateway enewuser pushgateway -1 -1 -1 pushgateway } src_compile() { export GOPATH="${G}" local PROMU="${EGO_PN}/vendor/${EGO_PN%/*}/common/version" # shellcheck disable=SC2207 local mygoargs=( -v -work -x $(usex pie '-buildmode=pie' '') -asmflags "-trimpath=${S}" -gcflags "-trimpath=${S}" -ldflags "-s -w -X ${PROMU}.Version=${PV} -X ${PROMU}.Revision=${GIT_COMMIT} -X ${PROMU}.Branch=non-git -X ${PROMU}.BuildUser=$(id -un)@$(hostname -f) -X ${PROMU}.BuildDate=$(date -u '+%Y%m%d-%I:%M:%S')" ) go build "${mygoargs[@]}" || die } src_test() { go test -v ./... || die } src_install() { dobin pushgateway einstalldocs newinitd "${FILESDIR}/${PN}.initd" "${PN}" newconfd "${FILESDIR}/${PN}.confd" "${PN}" systemd_dounit "${FILESDIR}/${PN}.service" diropts -o pushgateway -g pushgateway -m 0750 keepdir /var/{lib,log}/pushgateway }