# Copyright 1999-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 EAPI=6 inherit golang-vcs-snapshot systemd user GIT_COMMIT="5643633ef83d61b99499f34591ea1005415bd927" EGO_PN="github.com/oliver006/${PN/prometheus-}" DESCRIPTION="A server that export Redis metrics for Prometheus consumption" HOMEPAGE="https://github.com/oliver006/redis_exporter" SRC_URI="https://${EGO_PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz ${EGO_VENDOR_URI}" RESTRICT="mirror strip" LICENSE="MIT" SLOT="0" KEYWORDS="~amd64" IUSE="test" DOCS=( README.md ) G="${WORKDIR}/${P}" S="${G}/src/${EGO_PN}" pkg_setup() { if use test; then has network-sandbox $FEATURES && \ die "The test phase requires 'network-sandbox' to be disabled in FEATURES" ewarn ewarn "The test phase requires a local Redis server running on the default port" ewarn fi enewgroup redis_exporter enewuser redis_exporter -1 -1 -1 redis_exporter } src_compile() { export GOPATH="${G}" local GOLDFLAGS="-s -w -X main.VERSION=${PV} -X main.COMMIT_SHA1=${GIT_COMMIT} -X main.BUILD_DATE=$(date +%F-%T)" go build -v -ldflags \ "${GOLDFLAGS}" || die } src_test() { go test -v ./... || die } src_install() { dobin redis_exporter einstalldocs newinitd "${FILESDIR}"/${PN}.initd ${PN} newconfd "${FILESDIR}"/${PN}.confd ${PN} systemd_dounit "${FILESDIR}"/${PN}.service insinto /usr/share/${PN} doins -r contrib/* docompress -x /usr/share/${PN} diropts -o redis_exporter -g redis_exporter -m 0750 keepdir /var/log/redis_exporter }