~dricottone/huttese-apk

fe42a2f7f828e4f2db8c75af22052498add37e7b — Drew DeVault 5 years ago 06c053e
prometheus/prometheus: new APKBUILD
A prometheus/prometheus/APKBUILD => prometheus/prometheus/APKBUILD +54 -0
@@ 0,0 1,54 @@
# Maintainer: Drew DeVault <sir@cmpwn.com>
pkgname=prometheus
pkgver=2.9.1
pkgrel=0
pkgdesc="The Prometheus monitoring system and time series database"
url="https://github.com/prometheus/prometheus"
arch="all"
license="Apache-2.0"
install="prometheus.pre-install"
makedepends="go"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/prometheus/prometheus/archive/v$pkgver.tar.gz
	prometheus.confd
	prometheus.initd
"
subpackages="$pkgname-openrc"
builddir="$srcdir/$pkgname-$pkgver"

build() {
	cd "$builddir"
	go build \
		-gcflags "all=-trimpath=$PWD" \
		-asmflags "all=-trimpath=$PWD" \
		-ldflags "-extldflags $LDFLAGS" \
		./cmd/prometheus
	go build \
		-gcflags "all=-trimpath=$PWD" \
		-asmflags "all=-trimpath=$PWD" \
		-ldflags "-extldflags $LDFLAGS" \
		./cmd/promtool
}

check() {
	cd "$builddir"
	go test ./...
}

package() {
	cd "$builddir"
	install -Dm755 prometheus "$pkgdir"/usr/bin/prometheus
	install -Dm755 promtool "$pkgdir"/usr/bin/promtool

	install -Dm640 -t "$pkgdir"/etc/prometheus \
		documentation/examples/prometheus.yml

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

sha512sums="d9ae1078ab5b242020f00f5dfc154a75c3e1473be8f1fbecdf8f2589d55a09f8418cbf9aa189a9b2e61b4b5fca875735a26200496c02bb17793bbccbdc9f69cd  prometheus-2.9.1.tar.gz
82f90ef730935b9dfc67877098ab0dcada0da941e273b241826b1e9bd2474202f2df5dd976dbed016652219cf0cfd1d77b8df72367ed1ac15c6f0cc38800cac5  prometheus.confd
f70555c76e634b7bf594e7b5f8a17e8a3a549b55835ce51f34f357e317c009d14cd4212bb9eaaddc77a1a9f03a33ab94571e3f9252f8ffcb002560e672a3cc9d  prometheus.initd"

A prometheus/prometheus/prometheus.confd => prometheus/prometheus/prometheus.confd +2 -0
@@ 0,0 1,2 @@
config_file=/etc/prometheus/prometheus.yml
storage_path=/var/lib/prometheus/data

A prometheus/prometheus/prometheus.initd => prometheus/prometheus/prometheus.initd +15 -0
@@ 0,0 1,15 @@
#!/sbin/openrc-run
name="prometheus"
description="prometheus monitoring system & time series database"
supervisor=supervise-daemon
command=/usr/bin/prometheus
command_args="--config.file=$config_file \
	--storage.tsdb.path=$storage_path"
command_background=true
command_user="prometheus:prometheus"
pidfile="/run/${RC_SVCNAME}.pid"

start_pre() {
	checkpath -f "$config_file" -m 740 -o prometheus:prometheus
	checkpath -d "$storage_path" -m 755 -o prometheus:prometheus
}

A prometheus/prometheus/prometheus.pre-install => prometheus/prometheus/prometheus.pre-install +4 -0
@@ 0,0 1,4 @@
#!/bin/sh
grep '^prometheus' /etc/group >/dev/null || addgroup -S prometheus 2>/dev/null
grep '^prometheus' /etc/passwd >/dev/null || adduser -SDh/var/lib/prometheus \
	-s/sbin/nologin -Gprometheus -gprometheus prometheus prometheus 2>/dev/null