git: 7daf8a7b1613 - main - games/qwfwd: New port: QuakeWorld proxy

From: Vladimir Druzenko <vvd_at_FreeBSD.org>
Date: Thu, 20 Feb 2025 03:10:38 UTC
The branch main has been updated by vvd:

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

commit 7daf8a7b16137534ca39efe8a3b3aa078681bac1
Author:     Vladimir Druzenko <vvd@FreeBSD.org>
AuthorDate: 2025-02-20 03:07:00 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2025-02-20 03:09:18 +0000

    games/qwfwd: New port: QuakeWorld proxy
    
    QWFWD is a QuakeWorld proxy.
    Typically used to improve routing to the server, namely to reduce ping.
    https://github.com/QW-Group/qwfwd
---
 GIDs                       |   2 +-
 UIDs                       |   2 +-
 games/Makefile             |   1 +
 games/qwfwd/Makefile       |  41 ++++++++++++++++++
 games/qwfwd/distinfo       |   3 ++
 games/qwfwd/files/qwfwd.in | 106 +++++++++++++++++++++++++++++++++++++++++++++
 games/qwfwd/pkg-descr      |   2 +
 games/qwfwd/pkg-plist      |   2 +
 8 files changed, 157 insertions(+), 2 deletions(-)

diff --git a/GIDs b/GIDs
index 58cbe5ed30d2..5b9c791f1edc 100644
--- a/GIDs
+++ b/GIDs
@@ -441,7 +441,7 @@ openbao:*:482:
 rustypaste:*:498:
 # free: 499
 # free: 500
-# free: 501
+qwfwd:*:501:
 birdvty:*:502:
 # free: 503
 # free: 504
diff --git a/UIDs b/UIDs
index 4451ad11aa8b..abc54781310f 100644
--- a/UIDs
+++ b/UIDs
@@ -447,7 +447,7 @@ openbao:*:482:482:daemon:0:0:OpenBao Daemon:/nonexistent:/usr/sbin/nologin
 rustypaste:*:498:498::0:0:Minimal file upload/pastebin service:/nonexistent:/usr/sbin/nologin
 # free: 499
 # free: 500
-# free: 501
+qwfwd:*:501:501::0:0:QuakeWorld Proxy:/nonexistent:/usr/sbin/nologin
 # free: 502
 # free: 503
 # free: 504
diff --git a/games/Makefile b/games/Makefile
index 734d22b2edd1..31a4223df2f9 100644
--- a/games/Makefile
+++ b/games/Makefile
@@ -848,6 +848,7 @@
     SUBDIR += quetoo
     SUBDIR += quit
     SUBDIR += qwdtools
+    SUBDIR += qwfwd
     SUBDIR += r1q2
     SUBDIR += railroad-rampage
     SUBDIR += rawgl
diff --git a/games/qwfwd/Makefile b/games/qwfwd/Makefile
new file mode 100644
index 000000000000..d5ea311191c3
--- /dev/null
+++ b/games/qwfwd/Makefile
@@ -0,0 +1,41 @@
+PORTNAME=	qwfwd
+DISTVERSION=	1.2.20240216
+CATEGORIES=	games
+
+MAINTAINER=	vvd@FreeBSD.org
+COMMENT=	QuakeWorld proxy
+WWW=		https://github.com/QW-Group/qwfwd/
+
+LICENSE=	GPLv2
+LICENSE_FILE=	${WRKSRC}/LICENSE.md
+
+USES=		cmake
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	QW-Group
+GH_TAGNAME=	f657ff7
+USE_RC_SUBR=	${PORTNAME}
+
+EXTRACT_AFTER_ARGS=	--exclude .git* \
+			--exclude */.git* \
+			--exclude build_cmake.sh \
+			--exclude tools*
+
+SUB_LIST=	QWUSER=${USERS}
+USERS=		qwfwd
+GROUPS=		qwfwd
+PORTDOCS=	README.md
+
+OPTIONS_DEFINE=	DOCS
+
+do-install:
+	${INSTALL_PROGRAM} ${BUILD_WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/bin
+	${MKDIR} ${STAGEDIR}${ETCDIR}
+	${INSTALL_DATA} ${WRKSRC}/resources/example-configs/${PORTNAME}.cfg \
+		${STAGEDIR}${ETCDIR}/${PORTNAME}.cfg.sample
+
+do-install-DOCS-on:
+	${MKDIR} ${STAGEDIR}${DOCSDIR}
+	${INSTALL_DATA} ${PORTDOCS:S,^,${WRKSRC}/,} ${STAGEDIR}${DOCSDIR}
+
+.include <bsd.port.mk>
diff --git a/games/qwfwd/distinfo b/games/qwfwd/distinfo
new file mode 100644
index 000000000000..4e0024a01541
--- /dev/null
+++ b/games/qwfwd/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1739926256
+SHA256 (QW-Group-qwfwd-1.2.20240216-f657ff7_GH0.tar.gz) = 8052eb5b756574c580a49d30502cb31397324dd4bdce7979534ec34478055385
+SIZE (QW-Group-qwfwd-1.2.20240216-f657ff7_GH0.tar.gz) = 55473
diff --git a/games/qwfwd/files/qwfwd.in b/games/qwfwd/files/qwfwd.in
new file mode 100755
index 000000000000..8f774379cf98
--- /dev/null
+++ b/games/qwfwd/files/qwfwd.in
@@ -0,0 +1,106 @@
+#!/bin/sh
+
+# PROVIDE: qwfwd
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf or /etc/rc.conf.local to
+# enable qwfwd:
+# qwfwd_(instance_)?enable (bool):	Set to "NO" by default.
+#					Set it to "YES" to enable qwfwd.
+# qwfwd_(instance_)?args (str):		Custom additional arguments to be passed
+#					to ${__qwfwd} (default empty).
+# qwfwd_(instance_)?user (str):		User to run ${__qwserver} as. Default
+#					to "%%QWUSER%%" created by the port.
+# qwfwd_(instance_)?log (path):		Console log file (default
+#					/var/log/${name}_(instance)?.log).
+# qwfwd_(instance_)?configdir (path):	Path to config file qwfwd.cfg
+#					(default "%%ETCDIR%%").
+# qwfwd_instances (str):		Set to "" by default.
+#					If defined, list of instances to enable.
+
+. /etc/rc.subr
+
+case $0 in
+/etc/rc*)
+	# during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown),
+	# so get the name of the script from $_file
+	name=$_file
+        ;;
+*)
+	name=$0
+	;;
+esac
+
+name=${name##*/}
+rcvar="${name}_enable"
+
+load_rc_config "${name}"
+
+eval "${rcvar}=\${${rcvar}:-'NO'}"
+eval "__args=\${${name}_args:-''}"
+eval "__user=\${${name}_user:-'%%QWUSER%%'}"
+eval "__log=\${${name}_log:-/var/log/${name}.log}"
+eval "__configdir=\${${name}_configdir:-'%%ETCDIR%%'}"
+eval "${name}_chdir=${__configdir}"
+eval "__instances=\${${name}_instances:-''}"
+
+pidfiledir="/var/run"
+pidfile="${pidfiledir}/${name}.pid"
+
+if [ -n "$2" ]; then
+        instance="$2"
+	load_rc_config ${name}_${instance}
+	case "${__instances}" in
+	"$2 "*|*" $2 "*|*" $2"|"$2")
+		eval "__args=\${${name}_${instance}_args:-${__args}}"
+		eval "__user=\${${name}_${instance}_user:-${__user}}"
+		eval "__log=\${${name}_${instance}_log:-/var/log/${name}_${instance}.log}"
+		eval "__configdir=\${${name}_${instance}_configdir:-${__configdir}}"
+		eval "${name}_chdir=${__configdir}"
+		pidfile="${pidfiledir}/${name}_${instance}.pid"
+	;;
+	*)
+		err 1 "$2 not found in ${name}_instances" ;;
+	esac
+else
+	if [ -n "${__instances}" -a -n "$1" ]; then
+		for instance in ${__instances}; do
+			eval "_enable=\${${name}_${instance}_enable}"
+			eval "__enable=\${_enable:-\${${name}_enable}}"
+			case "${__enable}" in
+			[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
+				continue
+			;;
+			[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+			;;
+			*)
+				if [ -z "${_enable}" ]; then
+					_var=${name}_enable
+				else
+					_var=${name}_${instance}_enable
+				fi
+				warn "Bad value '${__enable}' for ${_var}. " \
+					"Instance ${instance} skipped."
+				continue
+			;;
+			esac
+			echo "===> ${name} instance: ${instance}"
+			%%PREFIX%%/etc/rc.d/${name} $1 ${instance}
+			retcode="$?"
+			if [ "0${retcode}" -eq 0 ]; then
+				success="${instance} ${success}"
+			else
+				failed="${instance} (retcode=${retcode}) ${failed}"
+			fi
+		done
+		echo "===> ${name} instances success: ${success}"
+		echo "===> ${name} instances failed: ${failed}"
+		exit 0
+	fi
+fi
+
+command="/usr/sbin/daemon"
+command_args="-P ${pidfile} -u ${__user} -R 5 -f -H -o ${__log} -m 3 %%PREFIX%%/bin/qwfwd ${__args}"
+
+run_rc_command "$1"
diff --git a/games/qwfwd/pkg-descr b/games/qwfwd/pkg-descr
new file mode 100644
index 000000000000..f379273cae1f
--- /dev/null
+++ b/games/qwfwd/pkg-descr
@@ -0,0 +1,2 @@
+QWFWD is a QuakeWorld proxy.
+Typically used to improve routing to the server, namely to reduce ping.
diff --git a/games/qwfwd/pkg-plist b/games/qwfwd/pkg-plist
new file mode 100644
index 000000000000..0cef21aceee5
--- /dev/null
+++ b/games/qwfwd/pkg-plist
@@ -0,0 +1,2 @@
+bin/qwfwd
+@sample %%ETCDIR%%/qwfwd.cfg.sample