# Maintainer: Will Sinatra <wpsinatra@gmail.com>
pkgname=pushgateway
pkgver=1.11.1
pkgrel=2
pkgdesc="Prometheus push acceptor for ephemeral and batch jobs"
url="https://github.com/prometheus/pushgateway"
license="Apache-2.0"
arch="all"
install="pushgateway.pre-install"
makedepends="go"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/prometheus/pushgateway/archive/v$pkgver.tar.gz
	pushgateway.confd
	pushgateway.initd
"
subpackages="$pkgname-openrc"
# net: go mods
options="net"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go mod vendor
	go build \
		-trimpath \
		-mod=vendor \
		-ldflags "-extldflags \"$LDFLAGS\""
}

check() {
	go test ./...
}

package() {
	install -Dm755 pushgateway "$pkgdir"/usr/bin/pushgateway

	install -Dm644 "$srcdir"/pushgateway.confd \
		"$pkgdir"/etc/conf.d/pushgateway
	install -Dm755 "$srcdir"/pushgateway.initd \
		"$pkgdir"/etc/init.d/pushgateway
}

sha512sums="
e26311bddf6b9d8419aa1ec2ee5204c4ee8c6b0ae95a1be6f3bd3bc5a8eb7302c59b21b12ea0f3824fef4513dc871e56b1573529275cb4eae531e6dad29946a7  pushgateway-1.11.1.tar.gz
39b797f6a38b02f84f94cfdbc5c860af060b044eaf98d7ec99909c4abcb9bf6112755bbd21460bfda9825b31715e403fedb6c88158072cd79d985429bcb5cf01  pushgateway.confd
8dec09ad9b420da54f6f9434307c07d905c4bb17c2bc68fc4863e2bc2288ae1c8faf5757485ad4b0ebb89a78e907f6ccaf11f8379e8ab71e5e88f7c741657f6f  pushgateway.initd
"
