Subject: [PATCH] community/alertmanager: new aport

From: Drew DeVault <[email-masked]>
Date: Mon, 6 Jan 2020 12:17:10 -0500

This package is running in production at SourceHut.
---
 community/alertmanager/APKBUILD           | 25 +++++++++++++++--------
 community/alertmanager/alertmanager.confd |  8 ++++++--
 community/alertmanager/alertmanager.initd | 14 +++++++------
 3 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/community/alertmanager/APKBUILD b/community/alertmanager/APKBUILD
index 8597bf8bb6..cb58d90e28 100644
--- a/community/alertmanager/APKBUILD
+++ b/community/alertmanager/APKBUILD
@@ -1,6 +1,6 @@
 # Maintainer: Drew DeVault <[email-masked]>
 pkgname=alertmanager
-pkgver=0.19.0
+pkgver=0.20.0
 pkgrel=0
 pkgdesc="Prometheus Alertmanager"
 url="https://github.com/prometheus/alertmanager"
@@ -15,18 +15,25 @@ source="
 "
 subpackages="$pkgname-openrc"
 builddir="$srcdir/$pkgname-$pkgver"
-options="!check" # timing-dependent upstream failures
+options="!check" # Requires us to use their weird build system
+
+prepare() {
+	default_prepare
+	go mod vendor
+}
 
 build() {
 	go build \
-		-gcflags "all=-trimpath=$PWD" \
-		-asmflags "all=-trimpath=$PWD" \
+		-trimpath \
+		-mod=vendor \
 		-ldflags "-extldflags $LDFLAGS" \
+		-tags netgo \
 		./cmd/alertmanager
 	go build \
-		-gcflags "all=-trimpath=$PWD" \
-		-asmflags "all=-trimpath=$PWD" \
+		-trimpath \
+		-mod=vendor \
 		-ldflags "-extldflags $LDFLAGS" \
+		-tags netgo \
 		./cmd/amtool
 }
 
@@ -48,6 +55,6 @@ package() {
 		"$pkgdir"/etc/alertmanager/alertmanager.yml
 }
 
-sha512sums="2c21bfbb1001e07e81b1115439ad15e7c0e7089839e56a19c445177e322b8ef9aa2b85e96478f3c3d709cbbd3a5447662a8c55da370b84aa4b6b24f83848744b  alertmanager-0.19.0.tar.gz
-58f59d1972af10659a5d44f3e005b28928082bac733d27b10238196f68f361cd472782a83b60522c850de7fe9cf502f688956e6e1a2bb64c8aead10dc1529266  alertmanager.confd
-92da9c8cdc10ec6cbfb07ae0710b56ab66260bfa78a1f40f0e4ac498cdd50bbbb0ddec2b53d16c1492a77755bfb2382478e22e2e08f0c0e6d421bc206a99e225  alertmanager.initd"
+sha512sums="4bb9353e6ce9b149c5f22a2c305829112dfdf87f9b74e6075a45be0e07fe0f17e869ef9be4bb5e9c53d215dd1f534b1b5a707dd981efce8c5bcae4c1d6ce18bb  alertmanager-0.20.0.tar.gz
+58420cf10ed51ec389d21ffdd5b4a0e588f0dc78b1069e32d0db1e0215f64c1c980d8f539ae902839f2f9342090b50ce1db756839f3676ee18b77548ce8f99c8  alertmanager.confd
+def36c9933e91a38d863c06679efd840952ba003a839afe5b5c6423fa6ee8f229755f758c5363564b433756af34509fef282b81dea2532500f1287c47c426787  alertmanager.initd"
diff --git a/community/alertmanager/alertmanager.confd b/community/alertmanager/alertmanager.confd
index c5d3a1812d..e2304e8691 100644
--- a/community/alertmanager/alertmanager.confd
+++ b/community/alertmanager/alertmanager.confd
@@ -1,2 +1,6 @@
-config_file=/etc/alertmanager/alertmanager.yml
-storage_path=/var/lib/alertmanager/data
+alertmanager_args=
+alertmanager_config_file=/etc/alertmanager/alertmanager.yml
+alertmanager_storage_path=/var/lib/alertmanager/data
+
+output_log=/var/log/alertmanager.log
+error_log=/var/log/alertmanager.log
diff --git a/community/alertmanager/alertmanager.initd b/community/alertmanager/alertmanager.initd
index 9a85721413..3359279440 100644
--- a/community/alertmanager/alertmanager.initd
+++ b/community/alertmanager/alertmanager.initd
@@ -2,15 +2,17 @@
 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_args="--config.file=$alertmanager_config_file \
+	--storage.path=$alertmanager_storage_path \
+	$alertmanager_args"
 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
+	[ -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 -d "$alertmanager_storage_path" -m 755 -o prometheus:prometheus
 }
-- 
2.24.1