Subject: [PATCH] community/gmnisrv: new aport

From: Drew DeVault <[email-masked]>
Date: Tue, 28 Sep 2021 14:54:45 +0200

This package has been in use in a third-party repo for some time and
should be able to safely skip testing.
---
 community/gmnisrv/APKBUILD            | 39 +++++++++++++++++++++++++++
 community/gmnisrv/gmnisrv.confd       |  4 +++
 community/gmnisrv/gmnisrv.initd       | 14 ++++++++++
 community/gmnisrv/gmnisrv.pre-install |  7 +++++
 4 files changed, 64 insertions(+)
 create mode 100644 community/gmnisrv/APKBUILD
 create mode 100644 community/gmnisrv/gmnisrv.confd
 create mode 100644 community/gmnisrv/gmnisrv.initd
 create mode 100644 community/gmnisrv/gmnisrv.pre-install

diff --git a/community/gmnisrv/APKBUILD b/community/gmnisrv/APKBUILD
new file mode 100644
index 0000000000..19e3c48e18
--- /dev/null
+++ b/community/gmnisrv/APKBUILD
@@ -0,0 +1,39 @@
+# Maintainer: Drew DeVault <[email-masked]>
+pkgname="gmnisrv"
+pkgver="1.0"
+pkgrel=0
+pkgdesc="A simple Gemini protocol server"
+url="gemini://drewdevault.com/gmnisrv.gmi"
+arch="all"
+license=" GPL-3.0-only"
+source="
+	$pkgname-$pkgver.tar.gz::https://git.sr.ht/~sircmpwn/gmnisrv/archive/$pkgver.tar.gz
+	gmnisrv.confd
+	gmnisrv.initd
+"
+install="$pkgname.pre-install"
+subpackages="$pkgname-doc $pkgname-openrc"
+depends="mailcap"
+makedepends="scdoc openssl1.1-compat-dev"
+options="!check" # no upstream tests
+
+build() {
+	./configure
+	make PREFIX=/usr
+}
+
+package() {
+	make PREFIX=/usr DESTDIR="$pkgdir" install
+	install -Dm644 config.ini \
+		"$pkgdir"/etc/gmnisrv.ini
+	install -Dm644 "$srcdir"/gmnisrv.confd \
+		"$pkgdir"/etc/conf.d/gmnisrv
+	install -Dm755 "$srcdir"/gmnisrv.initd \
+		"$pkgdir"/etc/init.d/gmnisrv
+}
+
+sha512sums="
+90ec9fdb2258a9b728d0eeebfaf5a6ca428321a9f54b865a762e979cc7c67c1eb414f5f02f8fe4e90f6aa4d2fd954712e63d33348629e05af20356fc4cefaabe  gmnisrv-1.0.tar.gz
+b11ec0422f495e8071bbcf9d5e5088b452dfbfe0b95ae7af6ee749fe70063460753d1bef81f2d957043035ea9fe41a59a99da0ad07199783993b896549512806  gmnisrv.confd
+b48895b478679b0239a261b8b075b942204cd15616dadebe93d05c423c388caa9deced8f50c1d44e51442cc850c48a5e5b3863ff8e2ae7beb8911276a36c847e  gmnisrv.initd
+"
diff --git a/community/gmnisrv/gmnisrv.confd b/community/gmnisrv/gmnisrv.confd
new file mode 100644
index 0000000000..73ab44eeb8
--- /dev/null
+++ b/community/gmnisrv/gmnisrv.confd
@@ -0,0 +1,4 @@
+gmnisrv_config=/etc/gmnisrv.ini
+
+output_log=/var/log/gmnisrv.log
+error_log=/var/log/gmnisrv.log
diff --git a/community/gmnisrv/gmnisrv.initd b/community/gmnisrv/gmnisrv.initd
new file mode 100644
index 0000000000..cc7c6df3e3
--- /dev/null
+++ b/community/gmnisrv/gmnisrv.initd
@@ -0,0 +1,14 @@
+#!/sbin/openrc-run
+name="gmnisrv"
+description="gemini server daemon"
+supervisor=supervise-daemon
+command=/usr/bin/gmnisrv
+command_args="-C $gmnisrv_config"
+command_user="gmnisrv:gmnisrv"
+
+start_pre() {
+	[ -n "$output_log" ] && checkpath -f "$output_log" -o gmnisrv:gmnisrv
+	[ -n "$error_log" ] && checkpath -f "$error_log" -o gmnisrv:gmnisrv
+	certs="$(grep '^store=' "$gmnisrv_config" | cut -d= -f2-)"
+	checkpath -d "$certs" -o gmnisrv:gmnisrv
+}
diff --git a/community/gmnisrv/gmnisrv.pre-install b/community/gmnisrv/gmnisrv.pre-install
new file mode 100644
index 0000000000..4b2cec9371
--- /dev/null
+++ b/community/gmnisrv/gmnisrv.pre-install
@@ -0,0 +1,7 @@
+#!/bin/sh
+grep '^gmnisrv:' /etc/group >/dev/null || addgroup -S gmnisrv 2>/dev/null
+grep '^gemini:' /etc/group >/dev/null || addgroup -S gemini 2>/dev/null
+grep '^gmnisrv:' /etc/passwd >/dev/null || adduser -SDh/srv/gemini \
+	-s/sbin/nologin -Ggemini -ggmnisrv gmnisrv gmnisrv 2>/dev/null
+install -dm755 -ggemini /srv/gemini
+install -dm755 -ggmnisrv /var/lib/gemini/certs
-- 
2.33.0