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
This commit is contained in:
Dave Cottlehuber 2025-03-09 01:45:26 +01:00 committed by Santhosh Raju
parent 150647ebcb
commit 0e4fb336cb
6 changed files with 63 additions and 31 deletions

2
GIDs
View file

@ -306,7 +306,7 @@ readarr:*:362:
victoria-logs:*:363:
elog:*:364:
gotify:*:365:
# free: 366
opengist:*:366:
# free: 367
# free: 368
# free: 369

2
UIDs
View file

@ -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

View file

@ -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>

View file

@ -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

View file

@ -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}

View file

@ -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