Subject: [PATCH 1/2] community/prometheus: new APKBUILD

From: Drew DeVault <[email-masked]>
Date: Wed, 27 Nov 2019 20:57:41 -0500

---
 community/prometheus/APKBUILD               | 53 +++++++++++++++++++++
 community/prometheus/prometheus.confd       |  2 +
 community/prometheus/prometheus.initd       | 16 +++++++
 community/prometheus/prometheus.pre-install |  4 ++
 4 files changed, 75 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..c081b427f6
--- /dev/null
+++ b/community/prometheus/APKBUILD
@@ -0,0 +1,53 @@
+# Maintainer: Drew DeVault <[email-masked]>
+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 \
+		-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() {
+	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
+82f90ef730935b9dfc67877098ab0dcada0da941e273b241826b1e9bd2474202f2df5dd976dbed016652219cf0cfd1d77b8df72367ed1ac15c6f0cc38800cac5  prometheus.confd
+3eaf6183a3dcf39169383861eff0e15dba16cbd08673815bf936a55ef17803a283c871f1f4534a61d1d0349227122e64a1cf5dac1b10adc504107aba869fff1c  prometheus.initd"
diff --git a/community/prometheus/prometheus.confd b/community/prometheus/prometheus.confd
new file mode 100644
index 0000000000..193f4adc64
--- /dev/null
+++ b/community/prometheus/prometheus.confd
@@ -0,0 +1,2 @@
+config_file=/etc/prometheus/prometheus.yml
+storage_path=/var/lib/prometheus/data
diff --git a/community/prometheus/prometheus.initd b/community/prometheus/prometheus.initd
new file mode 100644
index 0000000000..7ea45cf26d
--- /dev/null
+++ b/community/prometheus/prometheus.initd
@@ -0,0 +1,16 @@
+#!/sbin/openrc-run
+name="prometheus"
+description="prometheus monitoring system & time series database"
+supervisor=supervise-daemon
+supervise_daemon_args="-1 /var/log/prometheus.log -2 /var/log/prometheus.log"
+command=/usr/bin/prometheus
+command_args="--config.file=$config_file \
+	--storage.tsdb.path=$storage_path"
+command_user="prometheus:prometheus"
+pidfile="/run/${RC_SVCNAME}.pid"
+
+start_pre() {
+	checkpath -f "/var/log/prometheus.log" -m 644 -o prometheus:prometheus
+	checkpath -f "$config_file" -m 740 -o prometheus:prometheus
+	checkpath -d "$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..379f50ae8c
--- /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

---

From: Drew DeVault <[email-masked]>
Date: Wed, 27 Nov 2019 20:57:42 -0500

---
 community/alertmanager/APKBUILD               | 53 +++++++++++++++++++
 community/alertmanager/alertmanager.confd     |  2 +
 community/alertmanager/alertmanager.initd     | 16 ++++++
 .../alertmanager/alertmanager.pre-install     |  4 ++
 4 files changed, 75 insertions(+)
 create mode 100644 community/alertmanager/APKBUILD
 create mode 100644 community/alertmanager/alertmanager.confd
 create mode 100644 community/alertmanager/alertmanager.initd
 create mode 100644 community/alertmanager/alertmanager.pre-install

diff --git a/community/alertmanager/APKBUILD b/community/alertmanager/APKBUILD
new file mode 100644
index 0000000000..8597bf8bb6
--- /dev/null
+++ b/community/alertmanager/APKBUILD
@@ -0,0 +1,53 @@
+# Maintainer: Drew DeVault <[email-masked]>
+pkgname=alertmanager
+pkgver=0.19.0
+pkgrel=0
+pkgdesc="Prometheus Alertmanager"
+url="https://github.com/prometheus/alertmanager"
+arch="all"
+license="Apache-2.0"
+install="$pkgname.pre-install"
+makedepends="go bzr"
+source="
+	$pkgname-$pkgver.tar.gz::https://github.com/prometheus/alertmanager/archive/v$pkgver.tar.gz
+	alertmanager.confd
+	alertmanager.initd
+"
+subpackages="$pkgname-openrc"
+builddir="$srcdir/$pkgname-$pkgver"
+options="!check" # timing-dependent upstream failures
+
+build() {
+	go build \
+		-gcflags "all=-trimpath=$PWD" \
+		-asmflags "all=-trimpath=$PWD" \
+		-ldflags "-extldflags $LDFLAGS" \
+		./cmd/alertmanager
+	go build \
+		-gcflags "all=-trimpath=$PWD" \
+		-asmflags "all=-trimpath=$PWD" \
+		-ldflags "-extldflags $LDFLAGS" \
+		./cmd/amtool
+}
+
+check() {
+	go test ./...
+}
+
+package() {
+	install -Dm755 alertmanager "$pkgdir"/usr/bin/alertmanager
+	install -Dm755 amtool "$pkgdir"/usr/bin/amtool
+
+	install -Dm755 "$srcdir"/alertmanager.initd \
+		"$pkgdir"/etc/init.d/alertmanager
+	install -Dm644 "$srcdir"/alertmanager.confd \
+		"$pkgdir"/etc/conf.d/alertmanager
+	install -dm644 "$pkgdir"/var/lib/alertmanager/data
+
+	install -Dm644 examples/ha/alertmanager.yml \
+		"$pkgdir"/etc/alertmanager/alertmanager.yml
+}
+
+sha512sums="2c21bfbb1001e07e81b1115439ad15e7c0e7089839e56a19c445177e322b8ef9aa2b85e96478f3c3d709cbbd3a5447662a8c55da370b84aa4b6b24f83848744b  alertmanager-0.19.0.tar.gz
+58f59d1972af10659a5d44f3e005b28928082bac733d27b10238196f68f361cd472782a83b60522c850de7fe9cf502f688956e6e1a2bb64c8aead10dc1529266  alertmanager.confd
+92da9c8cdc10ec6cbfb07ae0710b56ab66260bfa78a1f40f0e4ac498cdd50bbbb0ddec2b53d16c1492a77755bfb2382478e22e2e08f0c0e6d421bc206a99e225  alertmanager.initd"
diff --git a/community/alertmanager/alertmanager.confd b/community/alertmanager/alertmanager.confd
new file mode 100644
index 0000000000..c5d3a1812d
--- /dev/null
+++ b/community/alertmanager/alertmanager.confd
@@ -0,0 +1,2 @@
+config_file=/etc/alertmanager/alertmanager.yml
+storage_path=/var/lib/alertmanager/data
diff --git a/community/alertmanager/alertmanager.initd b/community/alertmanager/alertmanager.initd
new file mode 100644
index 0000000000..9a85721413
--- /dev/null
+++ b/community/alertmanager/alertmanager.initd
@@ -0,0 +1,16 @@
+#!/sbin/openrc-run
+name="alertmanager"
+description="alert manager for the prometheus monitoring system"
+supervisor=supervise-daemon
+supervise_daemon_args="-1 /var/log/alertmanager.log -2 /var/log/alertmanager.log"
+command=/usr/bin/alertmanager
+command_args="--config.file=$config_file \
+	--storage.path=$storage_path"
+command_user="prometheus:prometheus"
+pidfile="/run/${RC_SVCNAME}.pid"
+
+start_pre() {
+	checkpath -f "/var/log/alertmanager.initd" -m 644 -o prometheus:prometheus
+	checkpath -f "$config_file" -m 740 -o prometheus:prometheus
+	checkpath -d "$storage_path" -m 755 -o prometheus:prometheus
+}
diff --git a/community/alertmanager/alertmanager.pre-install b/community/alertmanager/alertmanager.pre-install
new file mode 100644
index 0000000000..379f50ae8c
--- /dev/null
+++ b/community/alertmanager/alertmanager.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