git: 079641ccb7fb - main - net-im/mastodon: Resurrect

From: Muhammad Moinur Rahman <bofh_at_FreeBSD.org>
Date: Tue, 06 Dec 2022 15:37:09 UTC
The branch main has been updated by bofh:

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

commit 079641ccb7fb642169e9143c8b13830cbd4aef0f
Author:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
AuthorDate: 2022-12-06 15:33:18 +0000
Commit:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
CommitDate: 2022-12-06 15:37:05 +0000

    net-im/mastodon: Resurrect
    
    Mastodon is an alternative implementation of GNU social, a free,
    open-source social network.  It is a decentralized alternative to
    commercial platforms based on ActivityStreams, Webfinger, PubsubHubbub
    and Salmon.  The project focuses on creating a clean REST API and a good
    user interface.  Ruby on Rails is used for the back-end, while React.js
    and Redux are used for the dynamic front-end.
    
    For easier maintenance of the port some part of the installation
    procedure remains to be completed by the end user. The main howto is
    available at https://wiki.freebsd.org/Ports/net-im/mastodon.
    
    A great thanks to Stefano Marinelli for the fabulous post on running
    Mastodon on a FreeBSD instance which helped a lot in porting this. The
    link to the original post is also available on the above mentioned wiki
    page.
    
    Sponsored by:   Nepustil
---
 MOVED                                       |  1 -
 net-im/Makefile                             |  1 +
 net-im/mastodon/Makefile                    | 71 +++++++++++++++++++++++++++++
 net-im/mastodon/distinfo                    |  3 ++
 net-im/mastodon/files/mastodon_sidekiq.in   | 45 ++++++++++++++++++
 net-im/mastodon/files/mastodon_streaming.in | 45 ++++++++++++++++++
 net-im/mastodon/files/mastodon_web.in       | 44 ++++++++++++++++++
 net-im/mastodon/files/patch-.profile        |  5 ++
 net-im/mastodon/files/patch-dist_nginx.conf | 46 +++++++++++++++++++
 net-im/mastodon/pkg-descr                   |  6 +++
 net-im/mastodon/pkg-message                 | 10 ++++
 11 files changed, 276 insertions(+), 1 deletion(-)

diff --git a/MOVED b/MOVED
index 6f7df459f967..282219db96dd 100644
--- a/MOVED
+++ b/MOVED
@@ -10216,7 +10216,6 @@ mail/p5-Mail-Cache||2018-07-16|Has expired: Unmaintained
 www/p5-ZConf-RSS||2018-07-16|Has expired: Unmaintained
 www/p5-ZConf-RSS-GUI-GTK||2018-07-16|Has expired: Unmaintained
 devel/p5-ZConf-GUI||2018-07-16|Has expired: Unmaintained
-net-im/mastodon||2018-07-16|Has expired: Breaks too frequently
 x11-fm/p5-PerlFM||2018-07-16|Has expired: Unmaintained
 astro/p5-ZConf-Weather||2018-07-16|Has expired: Unmaintained
 sysutils/p5-ZConf-Cron||2018-07-16|Has expired: Unmaintained
diff --git a/net-im/Makefile b/net-im/Makefile
index 670ef3853921..8ffa1680e2a3 100644
--- a/net-im/Makefile
+++ b/net-im/Makefile
@@ -70,6 +70,7 @@
     SUBDIR += libstrophe
     SUBDIR += loudmouth
     SUBDIR += lurch
+    SUBDIR += mastodon
     SUBDIR += matterbridge
     SUBDIR += matterhorn
     SUBDIR += matterircd
diff --git a/net-im/mastodon/Makefile b/net-im/mastodon/Makefile
new file mode 100644
index 000000000000..eddd118e9063
--- /dev/null
+++ b/net-im/mastodon/Makefile
@@ -0,0 +1,71 @@
+PORTNAME=	mastodon
+DISTVERSIONPREFIX=	v
+DISTVERSION=	4.0.2
+CATEGORIES=	net-im www
+
+MAINTAINER=	bofh@FreeBSD.org
+COMMENT=	GNU Social-compatible microblogging server
+WWW=		https://github.com/tootsuite/mastodon
+
+LICENSE=	AGPLv3
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+LIB_DEPENDS=	libidn.so:dns/libidn
+RUN_DEPENDS=	autoconf>=2.71:devel/autoconf \
+		curl>0:ftp/curl \
+		ffmpeg>0:multimedia/ffmpeg \
+		git>=0:devel/git \
+		gmake>0:devel/gmake \
+		gnupg>0:security/gnupg \
+		redis>0:databases/redis \
+		rubygem-bundler>=0:sysutils/rubygem-bundler \
+		sudo>0:security/sudo \
+		wget>0:ftp/wget \
+		yarn>:www/yarn
+
+USES=		magick:7,run pgsql
+USE_GITHUB=	yes
+USE_RC_SUBR=	mastodon_sidekiq mastodon_streaming mastodon_web
+USE_RUBY=	yes
+
+NO_ARCH=	yes
+NO_BUILD=	yes
+
+USERS=		${PORTNAME}
+GROUPS=		${PORTNAME}
+
+RM_MASTODONFILES=	.dockerignore dist/mastodon-web.service \
+			dist/mastodon-sidekiq.service \
+			dist/mastodon-streaming.service
+RM_MASTODONDIRS=	.circleci .github
+
+post-extract:
+.for _F in ${RM_MASTODONFILES}
+	@${RM} ${WRKSRC}/${_F}
+.endfor
+.for _D in ${RM_MASTODONDIRS}
+	@${RM} -r ${WRKSRC}/${_D}
+.endfor
+
+post-patch:
+	@${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|'\
+		${WRKSRC}/dist/nginx.conf
+
+do-install:
+	${FIND} ${WRKSRC} -name '*.orig' -delete
+	${FIND} ${WRKSRC} -name '*.bak' -delete
+	${FIND} ${WRKSRC} -name '*.gitkeep' -delete
+	${FIND} ${WRKSRC} -name '*.gitignore' -delete
+	${MV} ${WRKSRC}/dist/nginx.conf ${WRKSRC}/dist/nginx.conf.sample
+	(cd ${WRKSRC} && ${COPYTREE_SHARE} . ${STAGEDIR}${PREFIX}/www/${PORTNAME})
+
+post-install:
+	@${ECHO_CMD} "@owner mastodon" >> ${TMPPLIST}
+	@${ECHO_CMD} "@group mastodon" >> ${TMPPLIST}
+	${FIND} -s ${STAGEDIR}${WWWDIR} -not -type d | ${SORT} | \
+		${SED} -e 's#^${STAGEDIR}${PREFIX}/##' | \
+		${SED} -E -e '/sample$$/ s#^#@sample #' >> ${TMPPLIST}
+	${FIND} -s ${STAGEDIR}${WWWDIR} -type d | ${SORT} | \
+		${SED} -e 's#^${STAGEDIR}${PREFIX}/#@dir #' >> ${TMPPLIST}
+
+.include <bsd.port.mk>
diff --git a/net-im/mastodon/distinfo b/net-im/mastodon/distinfo
new file mode 100644
index 000000000000..8869673daffd
--- /dev/null
+++ b/net-im/mastodon/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1669830294
+SHA256 (mastodon-mastodon-v4.0.2_GH0.tar.gz) = 70a4d9dcd9b746f6e9ced9b567ee5ad81e530cfaccb7f471259b917c20166309
+SIZE (mastodon-mastodon-v4.0.2_GH0.tar.gz) = 27934855
diff --git a/net-im/mastodon/files/mastodon_sidekiq.in b/net-im/mastodon/files/mastodon_sidekiq.in
new file mode 100644
index 000000000000..0b2bc18d803c
--- /dev/null
+++ b/net-im/mastodon/files/mastodon_sidekiq.in
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+# $FreeBSD$
+# PROVIDE: mastodon_sidekiq
+# REQUIRE: DAEMON postgresql
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name="mastodon_sidekiq"
+desc="Mastodon Sidekiq Service"
+rcvar="mastodon_sidekiq_enable"
+
+load_rc_config ${name}
+
+start_precmd="${name}_prestart"
+stop_cmd="${name}_stop"
+
+mastodon_sidekiq_user="mastodon"
+mastodon_sidekiq_chdir="%%WWWDIR%%"
+mastodon_sidekiq_env="RAILS_ENV=production \
+DB_POOL=25 \
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:%%PREFIX%%/sbin:%%PREFIX%%/bin:~/bin \
+MALLOC_ARENA_MAX=2"
+pidfile="/var/run/mastodon/${name##mastodon_}.pid"
+ppidfile="/var/run/mastodon/${name##mastodon_}_supervisor.pid"
+command="/usr/sbin/daemon"
+procname="%%PREFIX%%/bin/bundle"
+procname_args="exec sidekiq -c 25"
+command_args="-f -T ${name} -P ${ppidfile} -p ${pidfile} -S -r ${procname} ${procname_args}"
+
+mastodon_sidekiq_prestart()
+{
+	if [ ! -d "/var/run/mastodon" ]; then
+		install -d -o "${mastodon_sidekiq_user}" -g "${mastodon_sidekiq_user}" -m 750 "/var/run/mastodon"
+	fi
+}
+
+mastodon_sidekiq_stop()
+{
+	/bin/kill -9 `cat ${ppidfile}`
+	/bin/kill -15 `cat ${pidfile}`
+}
+
+run_rc_command "$1"
diff --git a/net-im/mastodon/files/mastodon_streaming.in b/net-im/mastodon/files/mastodon_streaming.in
new file mode 100644
index 000000000000..762d5eea8d45
--- /dev/null
+++ b/net-im/mastodon/files/mastodon_streaming.in
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+# $FreeBSD$
+# PROVIDE: mastodon_streaming
+# REQUIRE: DAEMON postgresql
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name="mastodon_streaming"
+desc="Mastodon Streaming Service"
+rcvar="mastodon_streaming_enable"
+
+load_rc_config ${name}
+
+start_precmd="${name}_prestart"
+stop_cmd="${name}_stop"
+
+mastodon_streaming_user="mastodon"
+mastodon_streaming_chdir="%%WWWDIR%%"
+mastodon_streaming_env="NODE_ENV=production \
+PORT=4000 \
+STREAMING_CLUSTER_NUM=1 \
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:%%PREFIX%%/sbin:%%PREFIX%%/bin:~/bin"
+pidfile="/var/run/mastodon/${name##mastodon_}.pid"
+ppidfile="/var/run/mastodon/${name##mastodon_}_supervisor.pid"
+command="/usr/sbin/daemon"
+procname="%%PREFIX%%/bin/node"
+procname_args="./streaming"
+command_args="-f -T ${name} -P ${ppidfile} -p ${pidfile} -S -r ${procname} ${procname_args}"
+
+mastodon_streaming_prestart()
+{
+	if [ ! -d "/var/run/mastodon" ]; then
+		install -d -o "${mastodon_streaming_user}" -g "${mastodon_streaming_user}" -m 750 "/var/run/mastodon"
+	fi
+}
+
+mastodon_streaming_stop()
+{
+	/bin/kill -9 `cat ${ppidfile}`
+	/bin/kill -15 `cat ${pidfile}`
+}
+
+run_rc_command "$1"
diff --git a/net-im/mastodon/files/mastodon_web.in b/net-im/mastodon/files/mastodon_web.in
new file mode 100644
index 000000000000..e72dbba7cd0e
--- /dev/null
+++ b/net-im/mastodon/files/mastodon_web.in
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# $FreeBSD$
+# PROVIDE: mastodon_web
+# REQUIRE: DAEMON postgresql
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name="mastodon_web"
+desc="Mastodon Web Service"
+rcvar="mastodon_web_enable"
+
+load_rc_config ${name}
+
+start_precmd="${name}_prestart"
+stop_cmd="${name}_stop"
+
+mastodon_web_user="mastodon"
+mastodon_web_chdir="%%WWWDIR%%"
+mastodon_web_env="RAILS_ENV=production \
+PORT=3000 \
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:%%PREFIX%%/sbin:%%PREFIX%%/bin:~/bin"
+pidfile="/var/run/mastodon/${name##mastodon_}.pid"
+ppidfile="/var/run/mastodon/${name##mastodon_}_supervisor.pid"
+command="/usr/sbin/daemon"
+procname="%%PREFIX%%/bin/bundle"
+procname_args="exec puma -C config/puma.rb"
+command_args="-f -T ${name} -P ${ppidfile} -p ${pidfile} -S -r ${procname} ${procname_args}"
+
+mastodon_web_prestart()
+{
+	if [ ! -d "/var/run/mastodon" ]; then
+		install -d -o "${mastodon_web_user}" -g "${mastodon_web_user}" -m 750 "/var/run/mastodon"
+	fi
+}
+
+mastodon_web_stop()
+{
+	/bin/kill -9 `cat ${ppidfile}`
+	/bin/kill -15 `cat ${pidfile}`
+}
+
+run_rc_command "$1"
diff --git a/net-im/mastodon/files/patch-.profile b/net-im/mastodon/files/patch-.profile
new file mode 100644
index 000000000000..ab2ad3170a9e
--- /dev/null
+++ b/net-im/mastodon/files/patch-.profile
@@ -0,0 +1,5 @@
+--- .profile.orig	2022-12-06 11:15:00 UTC
++++ .profile
+@@ -1 +1 @@
+-LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/app/.apt/lib/x86_64-linux-gnu:/app/.apt/usr/lib/x86_64-linux-gnu/mesa:/app/.apt/usr/lib/x86_64-linux-gnu/pulseaudio
++export LC_ALL="en_US.UTF-8"
diff --git a/net-im/mastodon/files/patch-dist_nginx.conf b/net-im/mastodon/files/patch-dist_nginx.conf
new file mode 100644
index 000000000000..4322a71e51a0
--- /dev/null
+++ b/net-im/mastodon/files/patch-dist_nginx.conf
@@ -0,0 +1,46 @@
+--- dist/nginx.conf.orig	2022-11-30 18:16:44 UTC
++++ dist/nginx.conf
+@@ -17,31 +17,32 @@ server {
+   listen 80;
+   listen [::]:80;
+   server_name example.com;
+-  root /home/mastodon/live/public;
++  root %%PREFIX%%/www/mastodon/public;
+   location /.well-known/acme-challenge/ { allow all; }
+   location / { return 301 https://$host$request_uri; }
+ }
+
+ server {
+-  listen 443 ssl http2;
+-  listen [::]:443 ssl http2;
+   server_name example.com;
++  # Uncomment these lines once you acquire a certificate:
++  # listen 443 ssl http2;
++  # listen [::]:443 ssl http2;
+
+-  ssl_protocols TLSv1.2 TLSv1.3;
+-  ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
+-  ssl_prefer_server_ciphers on;
+-  ssl_session_cache shared:SSL:10m;
+-  ssl_session_tickets off;
++  # ssl_protocols TLSv1.2 TLSv1.3;
++  # ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
++  # ssl_prefer_server_ciphers on;
++  # ssl_session_cache shared:SSL:10m;
++  # ssl_session_tickets off;
+
+   # Uncomment these lines once you acquire a certificate:
+-  # ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
+-  # ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
++  # ssl_certificate     %%PREFIX%%/etc/ssl/example.com/fullchain.pem;
++  # ssl_certificate_key %%PREFIX%%/etc/ssl/example.com/key.pem;
+
+   keepalive_timeout    70;
+   sendfile             on;
+   client_max_body_size 80m;
+
+-  root /home/mastodon/live/public;
++  root %%PREFIX%%/www/mastodon/public;
+
+   gzip on;
+   gzip_disable "msie6";
diff --git a/net-im/mastodon/pkg-descr b/net-im/mastodon/pkg-descr
new file mode 100644
index 000000000000..dcd902d1fe83
--- /dev/null
+++ b/net-im/mastodon/pkg-descr
@@ -0,0 +1,6 @@
+Mastodon is an alternative implementation of GNU social, a free,
+open-source social network.  It is a decentralized alternative to
+commercial platforms based on ActivityStreams, Webfinger, PubsubHubbub
+and Salmon.  The project focuses on creating a clean REST API and a good
+user interface.  Ruby on Rails is used for the back-end, while React.js
+and Redux are used for the dynamic front-end.
diff --git a/net-im/mastodon/pkg-message b/net-im/mastodon/pkg-message
new file mode 100644
index 000000000000..492b6a4b7474
--- /dev/null
+++ b/net-im/mastodon/pkg-message
@@ -0,0 +1,10 @@
+[
+{ type: install
+  message: <<EOM
+############################################################
+Visit this URL to get started with Mastodon.
+https://wiki.freebsd.org/Ports/net-im/mastodon
+############################################################
+EOM
+}
+]