git: 9b9114f7e7c8 - main - www/tt-rss: Update to g20230509 and move database drivers to post config

From: Koichiro Iwao <meta_at_FreeBSD.org>
Date: Mon, 15 May 2023 04:36:23 UTC
The branch main has been updated by meta:

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

commit 9b9114f7e7c81d53d9dc1f261a6ff9cf92826176
Author:     Derek Schrock <dereks@lifeofadishwasher.com>
AuthorDate: 2023-05-13 21:20:07 +0000
Commit:     Koichiro Iwao <meta@FreeBSD.org>
CommitDate: 2023-05-15 04:34:57 +0000

    www/tt-rss: Update to g20230509 and move database drivers to post config
    
    - Update to g20230509 11946f014
    - Move php database drivers a post install operation allowing the port
      to support both databases without having to make option changes or
      rebuilds.
    - Update ttrssd to check for the configured driver
    
    PR:             271397
---
 UPDATING                               | 14 ++++++++++++++
 www/tt-rss/Makefile                    | 28 ++++++++++++++--------------
 www/tt-rss/distinfo                    |  6 +++---
 www/tt-rss/files/pkg-message.in        |  7 +++++++
 www/tt-rss/files/ttrss_db_check.php.in |  8 ++++++++
 www/tt-rss/files/ttrssd.in             | 25 +++++++++++++++++++++----
 www/tt-rss/pkg-plist                   |  1 +
 7 files changed, 68 insertions(+), 21 deletions(-)

diff --git a/UPDATING b/UPDATING
index a547fac9a729..de937c8f811b 100644
--- a/UPDATING
+++ b/UPDATING
@@ -5,6 +5,20 @@ they are unavoidable.
 You should get into the habit of checking this file for changes each time
 you update your ports collection, before attempting any port upgrades.
 
+20230513:
+  AFFECTS: users of www/tt-rss
+  AUTHOR: dereks@lifeofadishwasher.com
+
+  www/tt-rss now expects the user to install the database drivers by hand
+  allowing the port to be database independent however it would be best if you
+  mark the php driver packages as a non-automatic package such that
+  pkg-autoremove doesn't uninstall them.
+
+  Change 80 to your corresponding php version (80, 81, 82)
+
+  mysql: pkg set -yA 0 php80-mysqli php80-pdo_mysql;
+  pgsql: pkg set -yA 0 php80-pgsql php80-pdo_pgsql;
+
 20230511:
   AFFECTS: users of net-mgmt/py-netbox-secretstore
   AUTHOR: kai@FreeBSD.org
diff --git a/www/tt-rss/Makefile b/www/tt-rss/Makefile
index 95188b47f223..ec348958373c 100644
--- a/www/tt-rss/Makefile
+++ b/www/tt-rss/Makefile
@@ -1,5 +1,5 @@
 PORTNAME=	tt-rss
-PORTVERSION=	g20230413
+PORTVERSION=	g20230509
 PORTEPOCH=	2
 CATEGORIES=	www
 
@@ -15,7 +15,7 @@ USES=		gettext-tools php:cli,web shebangfix
 
 USE_GITLAB=	yes
 GL_SITE=	https://gitlab.tt-rss.org
-GL_COMMIT=	0578bf802571781a0a7e3debbbec66437a7d28b4
+GL_COMMIT=	11946f0148d0b8a76ecc120fd9c1dc0b7fa04664
 
 USE_PHP=	ctype dom exif fileinfo filter iconv intl mbstring openssl \
 		pcntl pdo phar posix session simplexml tokenizer xml xmlwriter \
@@ -29,18 +29,22 @@ REINPLACE_ARGS=	-i ""
 NO_ARCH=	yes
 NO_BUILD=	yes
 
-SUB_FILES=	config.php httpd-tt-rss.conf pkg-message
-SUB_LIST=	MYSQL=${MYSQL} \
-		PGSQL=${PGSQL} \
+# Instead of depending on the extact database driver list php packages that tt-rss
+# depends on during install pkg-message as a post install setup.
+# mysql: php-mysqli php-pdo_mysql
+# pgsql: php-pgsql php-pdo_pgsql
+#
+# from Mk/Uses/php.mk create sub vars for mysqli/pdo_mysql pgsql/pdo_pgsql values
+SUB_FILES=	config.php httpd-tt-rss.conf pkg-message ttrss_db_check.php
+SUB_LIST=	MYSQL_DEPS="${mysqli_DEPENDS:T} ${pdo_mysql_DEPENDS:T}" \
+		PGSQL_DEPS="${pgsql_DEPENDS:T} ${pdo_pgsql_DEPENDS:T}" \
 		WWWOWN=${WWWOWN}
 
 PLIST_SUB=	WWWGRP=${WWWGRP} \
 		WWWOWN=${WWWOWN}
 
 OPTIONS_DEFINE=		CURL GD
-OPTIONS_DEFAULT=	CURL GD MYSQL
-OPTIONS_SINGLE=		DB
-OPTIONS_SINGLE_DB=	MYSQL PGSQL
+OPTIONS_DEFAULT=	CURL GD
 
 CURL_DESC=	Use SimplePie instead of Magpie
 GD_DESC=	Use OTP QR code generation
@@ -48,12 +52,6 @@ GD_DESC=	Use OTP QR code generation
 CURL_USE=	PHP=curl
 GD_USE=		PHP=gd
 
-MYSQL_USE=	PHP=mysqli,pdo_mysql
-MYSQL_VARS_OFF=	MYSQL="\#"
-
-PGSQL_USE=	PHP=pdo_pgsql,pgsql
-PGSQL_VARS_OFF=	PGSQL="\#"
-
 do-install:
 	${MKDIR} \
 		${STAGEDIR}${WWWDIR} \
@@ -68,6 +66,8 @@ do-install:
 	${RM} ${STAGEDIR}${WWWDIR}/config.php-dist
 	${INSTALL_DATA} ${WRKDIR}/config.php \
 		${STAGEDIR}${WWWDIR}/config.php.sample
+	${INSTALL_DATA} ${WRKDIR}/ttrss_db_check.php \
+		${STAGEDIR}${WWWDIR}/ttrss_db_check.php
 	${INSTALL_DATA} ${FILESDIR}/newsyslog.sample \
 		${STAGEDIR}${EXAMPLESDIR}
 
diff --git a/www/tt-rss/distinfo b/www/tt-rss/distinfo
index bd1e0fbc5158..dbafe558bf0f 100644
--- a/www/tt-rss/distinfo
+++ b/www/tt-rss/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1682227775
-SHA256 (tt-rss-tt-rss-0578bf802571781a0a7e3debbbec66437a7d28b4_GL0.tar.gz) = 76ec95062cfe868f6530c790e93f2dfe8ad40019b1015ce0e5b1398abc08e5df
-SIZE (tt-rss-tt-rss-0578bf802571781a0a7e3debbbec66437a7d28b4_GL0.tar.gz) = 8489761
+TIMESTAMP = 1684011742
+SHA256 (tt-rss-tt-rss-11946f0148d0b8a76ecc120fd9c1dc0b7fa04664_GL0.tar.gz) = e561b30e047ad727a91eb8e8597add2d4210b46f5404855c5cf6a8a93cde5bc7
+SIZE (tt-rss-tt-rss-11946f0148d0b8a76ecc120fd9c1dc0b7fa04664_GL0.tar.gz) = 8490369
diff --git a/www/tt-rss/files/pkg-message.in b/www/tt-rss/files/pkg-message.in
index 34bf547f3560..a0602b7e0475 100644
--- a/www/tt-rss/files/pkg-message.in
+++ b/www/tt-rss/files/pkg-message.in
@@ -3,6 +3,13 @@
   message: <<EOM
 Tiny Tiny RSS is now installed, but it requires some additional setup.
 
+Install your corresponding php database drivers:
+
+       msyql: mysqli pdo_mysql
+              pkg install %%MYSQL_DEPS%%
+  postgresql: pgsql pdo_pgsql
+              pkg install %%PGSQL_DEPS%%
+
 You now need to create a database, a database user, configure the
 web server, and configure tt-rss.  Sample apache24 configs located
 at %%DATADIR%%/httpd-tt-rss.conf.
diff --git a/www/tt-rss/files/ttrss_db_check.php.in b/www/tt-rss/files/ttrss_db_check.php.in
new file mode 100644
index 000000000000..a8b72d8b76fe
--- /dev/null
+++ b/www/tt-rss/files/ttrss_db_check.php.in
@@ -0,0 +1,8 @@
+<?php
+chdir("%%WWWDIR%%");
+
+require_once "%%WWWDIR%%/classes/config.php";
+require_once "%%WWWDIR%%/include/functions.php";
+
+print(strtolower(Config::get(Config::DB_TYPE)));
+?>
diff --git a/www/tt-rss/files/ttrssd.in b/www/tt-rss/files/ttrssd.in
index 21bfde025c73..07b7a38e1c8e 100644
--- a/www/tt-rss/files/ttrssd.in
+++ b/www/tt-rss/files/ttrssd.in
@@ -23,6 +23,7 @@ load_rc_config "${name}"
 : ${ttrssd_local_db:="YES"}
 
 initdb_php="%%WWWDIR%%/update.php"
+dbcheck_php="%%WWWDIR%%/ttrss_db_check.php"
 required_files="%%WWWDIR%%/config.php"
 pidfile="/var/run/${name}.pid"
 ppidfile="/var/run/${name}_parent.pid"
@@ -37,10 +38,10 @@ start_precmd=${name}_prestart
 start_cmd=${name}_start
 stop_cmd=${name}_stop
 
-%%MYSQL%%CHECK_CMD="%%LOCALBASE%%/bin/mysqladmin -u mysqld ping"
-%%MYSQL%%CHECK_MSG="${name}: mysqladmin command failed; mysql not ready?"
-%%PGSQL%%CHECK_CMD="%%LOCALBASE%%/bin/pg_isready"
-%%PGSQL%%CHECK_MSG="${name}: postgresql status failed; postgresql not ready?"
+MYSQL_CHECK_CMD="%%LOCALBASE%%/bin/mysqladmin -u mysqld ping"
+MYSQL_CHECK_MSG="${name}: mysqladmin command failed; mysql not ready?"
+PGSQL_CHECK_CMD="%%LOCALBASE%%/bin/pg_isready"
+PGSQL_CHECK_MSG="${name}: postgresql status failed; postgresql not ready?"
 
 ttrssd_start() {
 	if ! [ -x $phpcli ]; then
@@ -75,6 +76,22 @@ ttrssd_prestart() {
 	if checkyesno ttrssd_local_db; then
 		# Wait for the local database to be started
 
+		database="$("$phpcli" -f "$dbcheck_php")"
+
+		case  "$database" in
+		    "mysql")
+			CHECK_CMD="$MYSQL_CHECK_CMD"
+			CHECK_MSG="$MYSQL_CHECK_MSG"
+			;;
+		    "pgsql")
+			CHECK_CMD="$PGSQL_CHECK_CMD"
+			CHECK_MSG="$PGSQL_CHECK_MSG"
+			;;
+		    *)
+			err 1 "Unknown database configured: $database"
+			;;
+		esac
+
 		for n in $(seq 1 10); do
 			if $CHECK_CMD > /dev/null 2>&1; then
 			    return
diff --git a/www/tt-rss/pkg-plist b/www/tt-rss/pkg-plist
index 257ffb6f3f02..3405bdf3b0a5 100644
--- a/www/tt-rss/pkg-plist
+++ b/www/tt-rss/pkg-plist
@@ -2017,6 +2017,7 @@
 %%WWWDIR%%/plugins/toggle_sidebar/init.php
 %%WWWDIR%%/prefs.php
 %%WWWDIR%%/public.php
+%%WWWDIR%%/ttrss_db_check.php
 %%WWWDIR%%/schema/ttrss_schema_mysql.sql
 %%WWWDIR%%/schema/ttrss_schema_pgsql.sql
 %%WWWDIR%%/sql/mysql/migrations/3.sql