~alpine/aports

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

[PATCH v2] community/prometheus: new APKBUILD

Details
Message ID
<20191204152641.554-1-sir@cmpwn.com>
DKIM signature
missing
Download raw message
Patch: +79 -0
---
Updates per Konstantin's feedback:

* Use -trimpath for go build
* Prefix conf.d variable names with prometheus_
* Use error_log and output_log, drop supervise_daemon_args
* Drop pidfile
* Fix prometheus user/group creation in pre-install

 community/prometheus/APKBUILD               | 53 +++++++++++++++++++++
 community/prometheus/prometheus.confd       |  5 ++
 community/prometheus/prometheus.initd       | 17 +++++++
 community/prometheus/prometheus.pre-install |  4 ++
 4 files changed, 79 insertions(+)
 create mode 100644 community/prometheus/APKBUILD
 create mode 100644 community/prometheus/prometheus.confd
 create mode 100644 community/prometheus/prometheus.initd
 create mode 100644 community/prometheus/prometheus.pre-install

diff --git a/community/prometheus/APKBUILD b/community/prometheus/APKBUILD
new file mode 100644
index 0000000000..1e979b6c15
--- /dev/null
+++ b/community/prometheus/APKBUILD
@@ -0,0 +1,53 @@
# Maintainer: Drew DeVault <sir@cmpwn.com>
pkgname=prometheus
pkgver=2.14.0
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"
options="!check" # Broken by integrations we don't care about

build() {
	go build \
		-trimpath \
		-mod=vendor \
		-ldflags "-extldflags $LDFLAGS" \
		./cmd/prometheus
	go build \
		-trimpath \
		-mod=vendor \
		-ldflags "-extldflags $LDFLAGS" \
		./cmd/promtool
}

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

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

	install -Dm644 "$srcdir"/prometheus.confd \
		"$pkgdir"/etc/conf.d/prometheus
	install -Dm755 "$srcdir"/prometheus.initd \
		"$pkgdir"/etc/init.d/prometheus
	install -dm644 "$pkgdir"/var/lib/prometheus/data

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

sha512sums="077d83ef06a6ef77b6aa0d47ef0aa276f50b89c818f6cbe0163a4167d0ceb7fbcaf828a6341ba91cde303a0c6c7e2440de99ea0500a48a9059adb37a34a78a7a  prometheus-2.14.0.tar.gz
6e0edcae0c64b319926b2cbe92b59be51b00fde15f83098bfe9f622a71d60598aa87d26aaec802716ace17e399900cb05b106087ab28e5dd4eff5106c0f1cbfc  prometheus.confd
c1ea20d4ac29e193efd20ca814134913136cc7d67bc4ddc6c8cf07898764542565445b8d149bb56a84ca2fe8d4ad11caa66feb162e772df26f2411c59b0bc9d4  prometheus.initd"
diff --git a/community/prometheus/prometheus.confd b/community/prometheus/prometheus.confd
new file mode 100644
index 0000000000..75c0b5f3f6
--- /dev/null
+++ b/community/prometheus/prometheus.confd
@@ -0,0 +1,5 @@
prometheus_config_file=/etc/prometheus/prometheus.yml
prometheus_storage_path=/var/lib/prometheus/data

output_log=/var/log/prometheus.log
error_log=/var/log/prometheus.log
diff --git a/community/prometheus/prometheus.initd b/community/prometheus/prometheus.initd
new file mode 100644
index 0000000000..d41243e73c
--- /dev/null
+++ b/community/prometheus/prometheus.initd
@@ -0,0 +1,17 @@
#!/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_user="prometheus:prometheus"

start_pre() {
	[ -n "$output_log" ] && checkpath -f "$output_log" \
		-m 644 -o prometheus:prometheus
	[ -n "$error_log" ] && checkpath -f "$error_log" \
		-m 644 -o prometheus:prometheus
	checkpath -f "$prometheus_config_file" -m 740 -o prometheus:prometheus
	checkpath -d "$prometheus_storage_path" -m 755 -o prometheus:prometheus
}
diff --git a/community/prometheus/prometheus.pre-install b/community/prometheus/prometheus.pre-install
new file mode 100644
index 0000000000..004fd0bcb9
--- /dev/null
+++ b/community/prometheus/prometheus.pre-install
@@ -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
-- 
2.24.0
Reply to thread Export thread (mbox)