git: c39afa6d9312 - main - net-im/snac: new port

From: Kurt Jaeger <pi_at_FreeBSD.org>
Date: Mon, 28 Oct 2024 19:20:59 UTC
The branch main has been updated by pi:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c39afa6d93121276520e56609de8fa02c393fa80

commit c39afa6d93121276520e56609de8fa02c393fa80
Author:     Matthew Phillips <matthew@matthewphillips.info>
AuthorDate: 2024-10-28 19:18:54 +0000
Commit:     Kurt Jaeger <pi@FreeBSD.org>
CommitDate: 2024-10-28 19:20:36 +0000

    net-im/snac: new port
    
    Snac is a simple, minimalistic ActivityPub instance.
    
    It features:
    
    - Lightweight, minimal dependencies
    - Extensive support of ActivityPub operations.
    - Multiuser
    - Mastodon API support, so Mastodon-compatible apps can be used
    - Simple but effective web interface
    - Easily-accessed MUTE button
    - Tested interoperability with related software
    - No database needed
    - Totally JavaScript-free
    
    PR:             278385
    Reviewed by:    bofh
---
 GIDs                             |  2 +-
 UIDs                             |  1 +
 net-im/Makefile                  |  1 +
 net-im/snac/Makefile             | 40 ++++++++++++++++++++++++++
 net-im/snac/distinfo             |  3 ++
 net-im/snac/files/patch-Makefile | 33 +++++++++++++++++++++
 net-im/snac/files/pkg-message.in | 27 +++++++++++++++++
 net-im/snac/files/snac.in        | 62 ++++++++++++++++++++++++++++++++++++++++
 net-im/snac/pkg-descr            | 13 +++++++++
 9 files changed, 181 insertions(+), 1 deletion(-)

diff --git a/GIDs b/GIDs
index 11a30a83f8d9..31b9594c7217 100644
--- a/GIDs
+++ b/GIDs
@@ -276,7 +276,7 @@ keycloak:*:332:
 honeytrap:*:333:
 percona:*:334:
 benthos:*:335:
-# free: 336
+snac:*:336:
 daapd:*:337:
 murmur:*:338:
 mumble-server:*:339:
diff --git a/UIDs b/UIDs
index 18cad1c4c511..b0da39669ba4 100644
--- a/UIDs
+++ b/UIDs
@@ -281,6 +281,7 @@ keycloak:*:332:332::0:0:keycloak server:/nonexistent:/usr/sbin/nologin
 honeytrap:*:333:333::0:0:HoneyTrap Daemon:/nonexistent:/usr/sbin/nologin
 percona:*:334:334::0:0:Percona Daemons:/nonexistent:/usr/sbin/nologin
 benthos:*:335:335::0:0:Benthos Daemon:/nonexistent:/usr/sbin/nologin
+snac:*:336:336::0:0:Snac Daemon:/nonexistent:/usr/sbin/nologin
 _pma:*:336:80::0:0:phpMyAdmin Owner:/nonexistent:/usr/sbin/nologin
 daapd:*:337:337::0:0:daapd User:/nonexistent:/usr/sbin/nologin
 murmur:*:338:338::0:0:& User:/nonexistent:/usr/sbin/nologin
diff --git a/net-im/Makefile b/net-im/Makefile
index f511d41bba5b..4078aac2565a 100644
--- a/net-im/Makefile
+++ b/net-im/Makefile
@@ -141,6 +141,7 @@
     SUBDIR += signal-desktop
     SUBDIR += signald
     SUBDIR += slack-term
+    SUBDIR += snac
     SUBDIR += spectral
     SUBDIR += ssh-chat
     SUBDIR += sshout
diff --git a/net-im/snac/Makefile b/net-im/snac/Makefile
new file mode 100644
index 000000000000..c03d0ff8d652
--- /dev/null
+++ b/net-im/snac/Makefile
@@ -0,0 +1,40 @@
+PORTNAME=	snac
+DISTVERSION=	2.57
+CATEGORIES=	net-im www
+MASTER_SITES=	https://codeberg.org/grunfink/snac2/archive/${DISTVERSIONFULL}${EXTRACT_SUFX}?dummy=/
+
+MAINTAINER=	matthew@matthewphillips.info
+COMMENT=	Simple, minimalistic ActivityPub instance written in portable C
+WWW=		https://codeberg.org/grunfink/snac2
+
+LICENSE=	MIT
+
+LIB_DEPENDS=	libcurl.so:ftp/curl
+
+USES=		ssl
+USE_RC_SUBR=	snac
+
+SUB_FILES=	pkg-message \
+		snac
+SUB_LIST=	SNACDATADIR="${SNACDATADIR}" \
+		GROUP="${GROUPS}" \
+		USER="${USERS}"
+
+SNACDATADIR=	/var/db/snac
+
+WRKSRC=		${WRKDIR}/snac2
+
+USERS=		snac
+GROUPS=		snac
+
+PKGMESSAGE=	${FILESDIR}/pkg-message
+
+PLIST_FILES=	bin/snac \
+		share/man/man1/snac.1.gz \
+		share/man/man5/snac.5.gz \
+		share/man/man8/snac.8.gz
+
+post-install:
+	${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/snac
+
+.include <bsd.port.mk>
diff --git a/net-im/snac/distinfo b/net-im/snac/distinfo
new file mode 100644
index 000000000000..a23a446b8b06
--- /dev/null
+++ b/net-im/snac/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1724244538
+SHA256 (snac-2.57.tar.gz) = 16e25990391b04079caadeea6a5c24656a0df5ed5e7500516402c1cca21e831e
+SIZE (snac-2.57.tar.gz) = 180441
diff --git a/net-im/snac/files/patch-Makefile b/net-im/snac/files/patch-Makefile
new file mode 100644
index 000000000000..ba602c012f66
--- /dev/null
+++ b/net-im/snac/files/patch-Makefile
@@ -0,0 +1,33 @@
+--- Makefile.orig	2024-04-04 08:13:06 UTC
++++ Makefile
+@@ -1,5 +1,5 @@
+-PREFIX=/usr/local
+-PREFIX_MAN=$(PREFIX)/man
++PREFIX:=$(PREFIX)
++PREFIX_MAN=$(PREFIX)/share/man
+ CFLAGS?=-g -Wall -Wextra
+ 
+ all: snac
+@@ -18,14 +18,14 @@ install:
+ 	$(CC) -I/usr/local/include -MM *.c > makefile.depend
+ 
+ install:
+-	mkdir -p -m 755 $(PREFIX)/bin
+-	install -m 755 snac $(PREFIX)/bin/snac
+-	mkdir -p -m 755 $(PREFIX_MAN)/man1
+-	install -m 644 doc/snac.1 $(PREFIX_MAN)/man1/snac.1
+-	mkdir -p -m 755 $(PREFIX_MAN)/man5
+-	install -m 644 doc/snac.5 $(PREFIX_MAN)/man5/snac.5
+-	mkdir -p -m 755 $(PREFIX_MAN)/man8
+-	install -m 644 doc/snac.8 $(PREFIX_MAN)/man8/snac.8
++	mkdir -p -m 755 $(DESTDIR)$(PREFIX)/bin
++	install -m 755 snac $(DESTDIR)$(PREFIX)/bin/snac
++	mkdir -p -m 755 $(DESTDIR)$(PREFIX_MAN)/man1
++	install -m 644 doc/snac.1 $(DESTDIR)$(PREFIX_MAN)/man1/snac.1
++	mkdir -p -m 755 $(DESTDIR)$(PREFIX_MAN)/man5
++	install -m 644 doc/snac.5 $(DESTDIR)$(PREFIX_MAN)/man5/snac.5
++	mkdir -p -m 755 $(DESTDIR)$(PREFIX_MAN)/man8
++	install -m 644 doc/snac.8 $(DESTDIR)$(PREFIX_MAN)/man8/snac.8
+ 
+ uninstall:
+ 	rm $(PREFIX)/bin/snac
diff --git a/net-im/snac/files/pkg-message.in b/net-im/snac/files/pkg-message.in
new file mode 100644
index 000000000000..fca59f2128c1
--- /dev/null
+++ b/net-im/snac/files/pkg-message.in
@@ -0,0 +1,27 @@
+[
+{ type: install
+  message: <<EOM
+
+To use snac, enable it in rc.conf using
+
+  sysrc snac_enable=yes
+
+To initialize the data, run
+
+  service snac init
+
+You can then start snac by running:
+
+  service snac start
+
+You can add a user by running:
+
+  service snac run adduser <name>
+
+Data is stored at %%SNACDATADIR%%/data. For convenience the service includes
+a `run` command for executing snac commands against this directory, such as
+the `adduser` command shown above. See `snac --help` for a full list of
+commands.
+EOM
+}
+]
diff --git a/net-im/snac/files/snac.in b/net-im/snac/files/snac.in
new file mode 100644
index 000000000000..8e4078220597
--- /dev/null
+++ b/net-im/snac/files/snac.in
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+# PROVIDE: snac
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+#
+# Add these lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable this service:
+#
+# snac_enable (bool):	Set to NO by default.
+#			Set it to YES to enable snac.
+# snac_user   (user):	Set user to run snac.
+# 			Default is "snac".
+# snac_group  (group):	Set group to run snac.
+# 			Default is "snac".
+# snac_dir    (dir):	Set data storage dir.
+# 			Default is /var/db/snac/".
+
+. /etc/rc.subr
+
+name=snac
+rcvar=snac_enable
+desc="Simple fediverse server"
+
+start_precmd="${name}_prestart"
+extra_commands="init run"
+init_cmd="snac_init"
+run_cmd="snac_run"
+
+load_rc_config $name
+
+: ${snac_enable:=NO}
+: ${snac_user=%%USER%%}
+: ${snac_group=%%GROUP%%}
+: ${snac_dir=%%SNACDATADIR%%}
+
+procname="%%PREFIX%%/bin/${name}"
+command=/usr/sbin/daemon
+command_args="-c -S -T ${name} ${procname} httpd ${snac_dir}/data"
+
+snac_prestart()
+{
+    if [ ! -d "${snac_dir}/data" ]; then
+        echo "The snac data directory does not exist. Please run: service snac init"
+    fi
+}
+
+snac_init()
+{
+    mkdir -p "${snac_dir}"
+    ${procname} init "${snac_dir}/data"
+    chown -R ${snac_user}:${snac_group} "${snac_dir}/data"
+}
+
+snac_run()
+{
+    snaccmd="$1"
+    shift
+    ${procname} $snaccmd "${snac_dir}/data" $@
+}
+
+run_rc_command "$@"
diff --git a/net-im/snac/pkg-descr b/net-im/snac/pkg-descr
new file mode 100644
index 000000000000..5d6e845abf75
--- /dev/null
+++ b/net-im/snac/pkg-descr
@@ -0,0 +1,13 @@
+Snac is a simple, minimalistic ActivityPub instance.
+
+It features:
+
+- Lightweight, minimal dependencies
+- Extensive support of ActivityPub operations.
+- Multiuser
+- Mastodon API support, so Mastodon-compatible apps can be used
+- Simple but effective web interface
+- Easily-accessed MUTE button
+- Tested interoperability with related software
+- No database needed
+- Totally JavaScript-free