# Copyright 1999-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 EAPI=6 GIT_COMMIT="8aa2881" # Change this when you update the ebuild EGO_PN="github.com/hnlq715/${PN}" inherit golang-vcs-snapshot systemd user DESCRIPTION="A server that scrapes Nginx vts stats and exports them for Prometheus" HOMEPAGE="https://github.com/hnlq715/nginx-vts-exporter" SRC_URI="https://${EGO_PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz" RESTRICT="mirror" LICENSE="MIT" SLOT="0" KEYWORDS="~amd64" IUSE="pie" DOCS=( README.md ) QA_PRESTRIPPED="usr/bin/nginx-vts-exporter" G="${WORKDIR}/${P}" S="${G}/src/${EGO_PN}" pkg_setup() { enewgroup nginx-vts-exporter enewuser nginx-vts-exporter -1 -1 -1 nginx-vts-exporter } src_compile() { export GOPATH="${G}" local PROMU="${EGO_PN}/vendor/github.com/prometheus/common/version" local myldflags=( -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')" ) local mygoargs=( -v -work -x "-buildmode=$(usex pie pie default)" -asmflags "-trimpath=${S}" -gcflags "-trimpath=${S}" -ldflags "${myldflags[*]}" ) go build "${mygoargs[@]}" || die } src_install() { dobin nginx-vts-exporter einstalldocs newinitd "${FILESDIR}/${PN}.initd" "${PN}" newconfd "${FILESDIR}/${PN}.confd" "${PN}" systemd_dounit "${FILESDIR}/${PN}.service" diropts -o nginx-vts-exporter -g nginx-vts-exporter -m 0750 keepdir /var/log/nginx-vts-exporter }