git: 0e4fb336cba5 - main - www/opengist: Build fixes and improvements

From: Santhosh Raju <fox_at_FreeBSD.org>
Date: Sun, 09 Mar 2025 00:57:22 UTC
The branch main has been updated by fox:

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

commit 0e4fb336cba5439a9f7f692df86c87a6dc1519f8
Author:     Dave Cottlehuber <dch@freebsd.org>
AuthorDate: 2025-03-09 00:45:26 +0000
Commit:     Santhosh Raju <fox@FreeBSD.org>
CommitDate: 2025-03-09 00:51:52 +0000

    www/opengist: Build fixes and improvements
    
    un-break arm64 by installing both esbuild arches
        - stop lang/go from fetching newer toolchains during build
        - pet port with portfmt & portclippy, fix pkg-plist
    
    run under non-root user by default
        - add UID, GID for opengist user
        - amend rc script to support user
    
    PR:             285179
    Reviewed by:    fox
    Sponsored by:   SkunkWerks, GmbH
---
 GIDs                           |  2 +-
 UIDs                           |  2 +-
 www/opengist/Makefile          | 45 ++++++++++++++++++++++++++++--------------
 www/opengist/distinfo          |  6 +++---
 www/opengist/files/opengist.in | 32 +++++++++++++++++++++++-------
 www/opengist/pkg-plist         |  7 +++----
 6 files changed, 63 insertions(+), 31 deletions(-)

diff --git a/GIDs b/GIDs
index db0429c94754..c3797e521400 100644
--- a/GIDs
+++ b/GIDs
@@ -306,7 +306,7 @@ readarr:*:362:
 victoria-logs:*:363:
 elog:*:364:
 gotify:*:365:
-# free: 366
+opengist:*:366:
 # free: 367
 # free: 368
 # free: 369
diff --git a/UIDs b/UIDs
index d29867210962..b2f2f4b4568f 100644
--- a/UIDs
+++ b/UIDs
@@ -312,7 +312,7 @@ readarr:*:362:362::0:0:Readarr Daemon:/nonexistent:/usr/sbin/nologin
 victoria-logs:*:363:363::0:0:VictoriaLogs Daemon:/nonexistent:/usr/sbin/nologin
 elog:*:364:364::0:0:Elog server:/nonexistent:/usr/sbin/nologin
 gotify:*:365:365::0:0:Gotify User:/var/db/gotify:/usr/sbin/nologin
-# free: 366
+opengist:*:366:366::0:0:OpenGist User:/var/db/opengist:/usr/sbin/nologin
 # free: 367
 # free: 368
 # free: 369
diff --git a/www/opengist/Makefile b/www/opengist/Makefile
index 8ed591351227..cf5acb6ddde2 100644
--- a/www/opengist/Makefile
+++ b/www/opengist/Makefile
@@ -1,9 +1,8 @@
 PORTNAME=	opengist
 PORTVERSION=	1.8.4
 DISTVERSIONPREFIX=	v
-PORTREVISION=	1
 CATEGORIES=	www textproc
-MASTER_SITES=	LOCAL/fox/:js
+MASTER_SITES=	LOCAL/dch/:js
 DISTFILES=	opengist-${DISTVERSION}-node_modules.tgz:js
 
 MAINTAINER=	fox@FreeBSD.org
@@ -12,23 +11,26 @@ WWW=		https://opengist.io/
 
 LICENSE=	AGPLv3
 
-BROKEN_aarch64=	fails to build
 BROKEN_i386=	fails to build
 
 BUILD_DEPENDS=	npm${NODEJS_SUFFIX}>0:www/npm${NODEJS_SUFFIX}
 RUN_DEPENDS=	git:devel/git
 
-USES=		go:modules nodejs:20,build
-USE_RC_SUBR=	opengist
+USES=		go:1.23,modules nodejs:20,build
 
 USE_GITHUB=	nodefault
 GH_ACCOUNT=	thomiceli
 GH_PROJECT=	opengist
+USE_RC_SUBR=	opengist
 
 GO_MODULE=	github.com/thomiceli/opengist
 GO_TARGET=	.
 GO_BUILDFLAGS=	-tags fs_embed \
 		-ldflags="-X github.com/thomiceli/opengist/internal/config.OpengistVersion=v${DISTVERSION}"
+GO_ENV+=	GOTOOLCHAIN=local+path
+
+GROUP=		opengist
+USER=		opengist
 
 post-extract:
 	@${RLN} ${WRKDIR}/node_modules ${WRKSRC}/node_modules
@@ -38,18 +40,26 @@ post-patch:
 		${WRKSRC}/config.yml
 
 pre-build:
-	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} npx --offline vite -c public/vite.config.js build
-	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \
-	EMBED=1 npx --offline postcss 'public/assets/embed-*.css' -c public/postcss.config.js --replace
+	cd ${WRKSRC} && \
+		${SETENV} ${MAKE_ENV} npx --offline vite -c public/vite.config.js \
+		build
+	cd ${WRKSRC} && \
+		${SETENV} ${MAKE_ENV} EMBED=1 npx --offline postcss 'public/assets/embed-*.css' \
+		-c public/postcss.config.js --replace
 
 post-install:
 	${MKDIR} ${STAGEDIR}${PREFIX}/etc/${PORTNAME}
-	${INSTALL_DATA} ${WRKSRC}/config.yml ${STAGEDIR}${PREFIX}/etc/${PORTNAME}/config.yml.sample
+	${INSTALL_DATA} ${WRKSRC}/config.yml \
+		${STAGEDIR}${PREFIX}/etc/${PORTNAME}/config.yml.sample
 	${MKDIR} ${STAGEDIR}/var/db/${PORTNAME}
 	${MKDIR} ${STAGEDIR}/var/run/${PORTNAME}
 	${MKDIR} ${STAGEDIR}${WWWDIR}/assets
-	cd ${WRKSRC} && ${INSTALL_DATA} public/assets/* ${STAGEDIR}${WWWDIR}/assets
-	cd ${WRKSRC} && ${INSTALL_DATA} public/manifest.json ${STAGEDIR}${WWWDIR}
+	cd ${WRKSRC} && \
+		${INSTALL_DATA} public/assets/* \
+		${STAGEDIR}${WWWDIR}/assets
+	cd ${WRKSRC} && \
+		${INSTALL_DATA} public/manifest.json \
+		${STAGEDIR}${WWWDIR}
 
 #
 # To update the opengist-${DISTVERSION}-node_modules.tgz archive:
@@ -62,9 +72,14 @@ post-install:
 
 regenerate-node_modules-distfile: patch
 	cd ${WRKSRC} && \
-	${RM} -r node_modules && \
-	${MAKE_ENV} npm install --prefix ${WRKSRC} && \
-	${TAR} czf ${DISTDIR}/opengist-${DISTVERSION}-node_modules.tgz node_modules && \
-	${ECHO} "Please upload the file ${DISTDIR}/opengist-${DISTVERSION}-node_modules.tgz"
+		${RM} -r node_modules && \
+		${MAKE_ENV} npm install --prefix ${WRKSRC} && \
+		${MAKE_ENV} npm install --prefix ${WRKSRC} --os freebsd --cpu \
+		amd64 esbuild@0.18.20 && \
+		${MAKE_ENV} npm install --prefix ${WRKSRC} --os freebsd --cpu \
+		arm64 esbuild@0.18.20 && \
+		${TAR} czf ${DISTDIR}/opengist-${DISTVERSION}-node_modules.tgz \
+		node_modules && \
+		${ECHO} "Please upload the file ${DISTDIR}/opengist-${DISTVERSION}-node_modules.tgz"
 
 .include <bsd.port.mk>
diff --git a/www/opengist/distinfo b/www/opengist/distinfo
index 04f3196b3b13..4559945d6e54 100644
--- a/www/opengist/distinfo
+++ b/www/opengist/distinfo
@@ -1,6 +1,6 @@
-TIMESTAMP = 1735040783
-SHA256 (go/www_opengist/opengist-v1.8.4/opengist-1.8.4-node_modules.tgz) = 5fea4ceb76e5654a0ddc704cd212764f8a85663f569670b8750e16c8918a465c
-SIZE (go/www_opengist/opengist-v1.8.4/opengist-1.8.4-node_modules.tgz) = 22568160
+TIMESTAMP = 1741184663
+SHA256 (go/www_opengist/opengist-v1.8.4/opengist-1.8.4-node_modules.tgz) = 8aa17fda03b079a33a547a18bdd18e9792da02257bfb3c0ded442270d9efd044
+SIZE (go/www_opengist/opengist-v1.8.4/opengist-1.8.4-node_modules.tgz) = 26305117
 SHA256 (go/www_opengist/opengist-v1.8.4/v1.8.4.mod) = e23e2417d8d5b9b0cfee169732e45679fe2cda94d3153c9edb51cc56ce7343ec
 SIZE (go/www_opengist/opengist-v1.8.4/v1.8.4.mod) = 5060
 SHA256 (go/www_opengist/opengist-v1.8.4/v1.8.4.zip) = 40454c34f595bba558c294bd65aeaf15efd97bb2aa07f78afcbb6b08582227e2
diff --git a/www/opengist/files/opengist.in b/www/opengist/files/opengist.in
index 9681c7d7fd1a..8249f946c892 100644
--- a/www/opengist/files/opengist.in
+++ b/www/opengist/files/opengist.in
@@ -4,15 +4,33 @@
 # REQUIRE: LOGIN NETWORKING
 # KEYWORD: shutdown
 #
+# Add the following lines to /etc/rc.conf to run opengist:
+#
+# opengist_enable (bool):			Set it to "YES" to enable opengist server.
+# 						Default is "NO".
+# opengist_home (str):				Set the home directory for opengist server.
+#						Default is "%%WWWDIR%%".
+# opengist_user (str):				Set the user for running opengist server.
+#						Default is "opengist".
+# opengist_config_file (str):			Set config file location for opengist server.
+#						Default is "%%PREFIX%%/etc/${name}/config.yml".
+# opengist_syslog_output_enable (bool):		Set it to "YES" for enabling output to syslogd(8)
+#						Default is "NO"
+# opengist_syslog_output_priority (str):	Set logging priority.
+#						Default is "info"
+# opengist_syslog_output_facility (str):	Set logging facility
+#						Default is "daemon"
 
 . /etc/rc.subr
 
 name=opengist
 rcvar=opengist_enable
 
-load_rc_config $name
+load_rc_config ${name}
 
 : ${opengist_enable:="NO"}
+: ${opengist_user:="opengist"}
+: ${opengist_files:="/var/db/opengist/"}
 : ${opengist_home:="%%WWWDIR%%"}
 : ${opengist_config_file:="%%PREFIX%%/etc/${name}/config.yml"}
 : ${opengist_syslog_output_enable:="NO"}
@@ -39,18 +57,18 @@ start_precmd="${name}_precmd"
 
 opengist_precmd()
 {
-	if [ ! -f ${opengist_config_file} ]
-	then
+	if [ ! -f ${opengist_config_file} ]; then
 		echo ${opengist_config_file} missing.
 		return 1
 	fi
 }
 
 opengist_start() {
-        /usr/sbin/daemon -f ${opengist_syslog_output_flags} -p ${pidfile} \
-                /usr/bin/env -i \
-                "PATH=%%PREFIX%%/bin:${PATH}" \
-                ${procname} -c ${opengist_config_file}
+	echo "Starting opengist."
+	/usr/sbin/daemon -f ${opengist_syslog_output_flags} -p ${pidfile} \
+		/usr/bin/env -i \
+		"PATH=%%PREFIX%%/bin:${PATH}" \
+		${procname} -c ${opengist_config_file}
 }
 
 cd ${opengist_home}
diff --git a/www/opengist/pkg-plist b/www/opengist/pkg-plist
index a5bbab4c2094..7881d75cf384 100644
--- a/www/opengist/pkg-plist
+++ b/www/opengist/pkg-plist
@@ -1,6 +1,5 @@
 bin/opengist
-%%ETCDIR%%/config.yml.sample
-etc/rc.d/opengist
+@sample(opengist,opengist,640) %%ETCDIR%%/config.yml.sample
 %%WWWDIR%%/assets/admin-f49fd6c0.js
 %%WWWDIR%%/assets/default-f34219fc.png
 %%WWWDIR%%/assets/editor-dd91ca8c.js
@@ -13,5 +12,5 @@ etc/rc.d/opengist
 %%WWWDIR%%/assets/opengist-85b89b9c.svg
 %%WWWDIR%%/assets/webauthn-da047c6d.js
 %%WWWDIR%%/manifest.json
-@dir /var/db/opengist
-@dir /var/run/opengist
+@dir(opengist,opengist,640) /var/db/opengist
+@dir(opengist,opengist,600) /var/run/opengist