# Contributor: Consus <consus@ftml.net>
# Maintainer: Consus <consus@ftml.net>
pkgname=prometheus-openrc-exporter
_pkgname=openrc-exporter
pkgver=0.0.2
pkgrel=19
pkgdesc="Prometheus exporter which exposes metrics on services managed by OpenRC"
url="https://git.sr.ht/~tomleb/openrc-exporter"
arch="all"
license="AGPL-3.0-only"
makedepends="go openrc-dev"
install="$pkgname.pre-install $pkgname.pre-upgrade"
subpackages="$pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://git.sr.ht/~tomleb/$_pkgname/archive/$pkgver.tar.gz
	update-go-mod.patch
	$_pkgname.initd
	$_pkgname.confd"
options="!check"
builddir="$srcdir/$_pkgname-$pkgver"

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

build() {
	make
}

package() {
	install -Dm 0755 cmd/$_pkgname/$_pkgname "$pkgdir"/usr/bin/openrc_exporter

	install -Dm 0755 "$srcdir"/$_pkgname.initd "$pkgdir"/etc/init.d/$_pkgname
	install -Dm 0644 "$srcdir"/$_pkgname.confd "$pkgdir"/etc/conf.d/$_pkgname
}

sha512sums="
f593bb6e9f462527cd0a527539be576cbab361911fc19c9170f3e2da64093011eefa5a28bd527e07b2fdb4b8143bbd59b2590f9be0305b7d909a9039366f6a54  prometheus-openrc-exporter-0.0.2.tar.gz
7ce6a92fa90a9a97734bdabc25539515d03582cb382596f9c74a836ed17190132424a7b77b68e05ece2217375d1e3e1f8837885c2d0839cde4417d21761afc41  update-go-mod.patch
ef0dfac536a3acbbdeabc8f19f97bd6e526af1d9d767b5960c24064feb871358db83f34c7db0f67fbfa5da00b3f32e82ae43d19d8b5fd2e61415f5e433de19b2  openrc-exporter.initd
4a82fecbb2914aee6cc8521f9e562c63d20794db3f54d8cc9187ce1a4eb4f974eb4091519b8d09d2bd879a921e751910cb7313a91079df435c7e2a5eca47f621  openrc-exporter.confd
"
