From b9d5efcb364d56b95da752ca34f9be0c2cecf590 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Manuel=20R=C3=BCger?= <mrueg@gentoo.org>
Date: Thu, 19 Oct 2017 20:34:32 +0200
Subject: [PATCH] net-analyzer/prometheus-alertmanager: Initial version

Package-Manager: Portage-2.3.11, Repoman-2.3.3
---
 net-analyzer/prometheus-alertmanager/Manifest |  1 +
 .../files/prometheus-alertmanager.confd       |  2 +
 .../files/prometheus-alertmanager.initd       | 19 +++++++
 .../prometheus-alertmanager/metadata.xml      | 11 ++++
 .../prometheus-alertmanager-0.9.1.ebuild      | 52 +++++++++++++++++++
 5 files changed, 85 insertions(+)
 create mode 100644 net-analyzer/prometheus-alertmanager/Manifest
 create mode 100644 net-analyzer/prometheus-alertmanager/files/prometheus-alertmanager.confd
 create mode 100644 net-analyzer/prometheus-alertmanager/files/prometheus-alertmanager.initd
 create mode 100644 net-analyzer/prometheus-alertmanager/metadata.xml
 create mode 100644 net-analyzer/prometheus-alertmanager/prometheus-alertmanager-0.9.1.ebuild

diff --git a/net-analyzer/prometheus-alertmanager/Manifest b/net-analyzer/prometheus-alertmanager/Manifest
new file mode 100644
index 000000000000..db386e831b06
--- /dev/null
+++ b/net-analyzer/prometheus-alertmanager/Manifest
@@ -0,0 +1 @@
+DIST prometheus-alertmanager-0.9.1.tar.gz 3671292 SHA256 067e00773efd0948918a30449d5e96b5cc9b0b9ecb1271d75bbd46ad3944a699 SHA512 423079c630466a6c3eeaab56d60bd9b7c77049955e9a67b703ef51665ccf7af0b319e8e3748c8e6d055dcf442173028cbe475181be08221d93a5ad3d20900c65 WHIRLPOOL 1fdf9803ffb99bda6ca49f250ff2895e29a6a77b17b1f38f47ca1f858262580f307f56bd95f0a6e97cd7a0a04e3b0df1fe28401cc6f66b71a72311df0971b970
diff --git a/net-analyzer/prometheus-alertmanager/files/prometheus-alertmanager.confd b/net-analyzer/prometheus-alertmanager/files/prometheus-alertmanager.confd
new file mode 100644
index 000000000000..a0ae34c4bc0d
--- /dev/null
+++ b/net-analyzer/prometheus-alertmanager/files/prometheus-alertmanager.confd
@@ -0,0 +1,2 @@
+# arguments for prometheus alertmanager
+command_args=""
diff --git a/net-analyzer/prometheus-alertmanager/files/prometheus-alertmanager.initd b/net-analyzer/prometheus-alertmanager/files/prometheus-alertmanager.initd
new file mode 100644
index 000000000000..ece8bf145876
--- /dev/null
+++ b/net-analyzer/prometheus-alertmanager/files/prometheus-alertmanager.initd
@@ -0,0 +1,19 @@
+#!/sbin/openrc-run
+# Copyright 2016-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+description="Prometheus alertmanager"
+pidfile=${pidfile:-"/run/${RC_SVCNAME}.pid"}
+user=${user:-${RC_SVCNAME}}
+group=${group:-${RC_SVCNAME}}
+
+command="/usr/bin/alertmanager"
+command_args="${command_args:--config.file=/etc/alertmanager/config.yml}"
+command_background="true"
+start_stop_daemon_args="--user ${user} --group ${group} \
+	--stdout /var/log/alertmanager/${RC_SVCNAME}.log \
+	--stderr /var/log/alertmanager/${RC_SVCNAME}.log"
+
+depend() {
+	after net
+}
diff --git a/net-analyzer/prometheus-alertmanager/metadata.xml b/net-analyzer/prometheus-alertmanager/metadata.xml
new file mode 100644
index 000000000000..714320b4f365
--- /dev/null
+++ b/net-analyzer/prometheus-alertmanager/metadata.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+	<maintainer type="person">
+		<email>mrueg@gentoo.org</email>
+		<name>Manuel Rüger</name>
+	</maintainer>
+	<upstream>
+		<remote-id type="github">prometheus/alertmanager</remote-id>
+	</upstream>
+</pkgmetadata>
diff --git a/net-analyzer/prometheus-alertmanager/prometheus-alertmanager-0.9.1.ebuild b/net-analyzer/prometheus-alertmanager/prometheus-alertmanager-0.9.1.ebuild
new file mode 100644
index 000000000000..d04d5de449d7
--- /dev/null
+++ b/net-analyzer/prometheus-alertmanager/prometheus-alertmanager-0.9.1.ebuild
@@ -0,0 +1,52 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+inherit user golang-build golang-vcs-snapshot
+
+EGO_PN="github.com/prometheus/alertmanager"
+EGIT_COMMIT="v${PV/_rc/-rc.}"
+ALERTMANAGER_COMMIT="9f5f4b2"
+ARCHIVE_URI="https://${EGO_PN}/archive/${EGIT_COMMIT}.tar.gz -> ${P}.tar.gz"
+KEYWORDS="~amd64"
+
+DESCRIPTION="Alertmanager for alerts sent by client applications such as Prometheus"
+HOMEPAGE="https://github.com/prometheus/alertmanager"
+SRC_URI="${ARCHIVE_URI}"
+LICENSE="Apache-2.0"
+SLOT="0"
+IUSE=""
+
+DEPEND="dev-util/promu"
+
+RESTRICT="test"
+
+pkg_setup() {
+	enewgroup ${PN}
+	enewuser ${PN} -1 -1 -1 ${PN}
+}
+
+src_prepare() {
+	default
+	sed -i -e "s/{{.Revision}}/${ALERTMANAGER_COMMIT}/" src/${EGO_PN}/.promu.yml || die
+}
+
+src_compile() {
+	pushd src/${EGO_PN} || die
+	mkdir -p bin || die
+	GOPATH="${S}" promu build -v --prefix alertmanager || die
+	popd || die
+}
+
+src_install() {
+	pushd src/${EGO_PN} || die
+	dobin alertmanager/alertmanager
+	dodoc {README,CHANGELOG,CONTRIBUTING}.md
+	insinto /etc/alertmanager/
+	newins doc/examples/simple.yml config.yml.example
+	popd || die
+	keepdir /var/lib/alertmanager /var/log/alertmanager
+	fowners ${PN}:${PN} /var/lib/alertmanager /var/log/alertmanager
+	newinitd "${FILESDIR}"/${PN}.initd ${PN}
+	newconfd "${FILESDIR}"/${PN}.confd ${PN}
+}
-- 
2.26.2