git: 2043de1ccc78 - main - www/angie-module-postgres: Angie postgres dynamic module

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Sun, 10 Sep 2023 16:13:47 UTC
The branch main has been updated by fuz:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2043de1ccc788dae5a870aac0d57fce1c7521f06

commit 2043de1ccc788dae5a870aac0d57fce1c7521f06
Author:     Oleg A. Mamontov <oleg@mamontov.net>
AuthorDate: 2023-08-30 21:00:56 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-09-10 16:13:01 +0000

    www/angie-module-postgres: Angie postgres dynamic module
    
    This is an upstream module that allows Angie to communicate directly with
    PostgreSQL database.
    
    PR:             Angie postgres dynamic module
---
 www/Makefile                                       |  1 +
 www/angie-module-postgres/Makefile                 | 24 ++++++++++++++++++++
 .../files/patch-ngx_postgres-default_port          | 17 ++++++++++++++
 .../files/patch-ngx_postgres-dynamic               | 26 ++++++++++++++++++++++
 .../files/patch-ngx_postgres-subrequest_in_memory  | 18 +++++++++++++++
 www/angie-module-postgres/files/pkg-message.in     | 15 +++++++++++++
 www/angie-module-postgres/pkg-descr                |  2 ++
 www/angie-module-postgres/pkg-plist                |  3 +++
 8 files changed, 106 insertions(+)

diff --git a/www/Makefile b/www/Makefile
index ab07dfcccc79..1dab0aa27334 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -42,6 +42,7 @@
     SUBDIR += angie-module-ndk
     SUBDIR += angie-module-njs
     SUBDIR += angie-module-perl
+    SUBDIR += angie-module-postgres
     SUBDIR += angie-module-redis2
     SUBDIR += angie-module-xslt
     SUBDIR += anyremote2html
diff --git a/www/angie-module-postgres/Makefile b/www/angie-module-postgres/Makefile
new file mode 100644
index 000000000000..b672ce013b86
--- /dev/null
+++ b/www/angie-module-postgres/Makefile
@@ -0,0 +1,24 @@
+PORTNAME=	angie-module-postgres
+GH_TUPLE=	FRiCKLE:ngx_postgres:1.0rc7:module
+
+COMMENT=	Angie postgres dynamic module
+
+USES=		pgsql
+
+MASTERDIR=	${.CURDIR}/../../www/angie
+
+do-install:
+	${MKDIR} ${STAGEDIR}${DOCSDIR}
+	${MKDIR} ${STAGEDIR}${MODDIR}
+
+	${INSTALL_LIB} ${WRKSRC}/objs/ngx_postgres_module.so \
+	    ${STAGEDIR}${MODDIR}
+
+	${INSTALL_MAN} ${WRKSRC_module}/README.md ${STAGEDIR}${DOCSDIR}
+
+do-install-DEBUG-on:
+	${INSTALL} ${COPY} -m ${_SHAREMODE} \
+	    ${WRKSRC_DEBUG}/objs/ngx_postgres_module.so \
+	    ${STAGEDIR}${MODDIR}/ngx_postgres_module-debug.so
+
+.include "${MASTERDIR}/Makefile"
diff --git a/www/angie-module-postgres/files/patch-ngx_postgres-default_port b/www/angie-module-postgres/files/patch-ngx_postgres-default_port
new file mode 100644
index 000000000000..3dbdf4e7c71c
--- /dev/null
+++ b/www/angie-module-postgres/files/patch-ngx_postgres-default_port
@@ -0,0 +1,17 @@
+--- ../ngx_postgres-1.0rc7/src/ngx_postgres_module.c.orig
++++ ../ngx_postgres-1.0rc7/src/ngx_postgres_module.c
+@@ -1320,12 +1320,14 @@
+             continue;
+         }
+ 
++#if (nginx_version < 1011006)
+         if (uscfp[i]->default_port && url->default_port
+             && (uscfp[i]->default_port != url->default_port))
+         {
+             dd("default_port doesn't match");
+             continue;
+         }
++#endif
+ 
+         dd("returning");
+         return uscfp[i];
diff --git a/www/angie-module-postgres/files/patch-ngx_postgres-dynamic b/www/angie-module-postgres/files/patch-ngx_postgres-dynamic
new file mode 100644
index 000000000000..596d3eb3bba9
--- /dev/null
+++ b/www/angie-module-postgres/files/patch-ngx_postgres-dynamic
@@ -0,0 +1,26 @@
+--- ../ngx_postgres-1.0rc7/config.orig
++++ ../ngx_postgres-1.0rc7/config
+@@ -205,6 +205,16 @@
+
+ ngx_addon_name=ngx_postgres
+
++if [ -f auto/module ] ; then
++    ngx_module_type=HTTP
++    ngx_module_name=ngx_postgres_module
++    ngx_module_incs=$ngx_feature_path
++    ngx_module_libs=$ngx_feature_libs
++    ngx_module_srcs="$NGX_ADDON_SRCS $ngx_addon_dir/src/ngx_postgres_escape.c $ngx_addon_dir/src/ngx_postgres_handler.c $ngx_addon_dir/src/ngx_postgres_keepalive.c $ngx_addon_dir/src/ngx_postgres_module.c $ngx_addon_dir/src/ngx_postgres_output.c $ngx_addon_dir/src/ngx_postgres_processor.c $ngx_addon_dir/src/ngx_postgres_rewrite.c $ngx_addon_dir/src/ngx_postgres_upstream.c $ngx_addon_dir/src/ngx_postgres_util.c $ngx_addon_dir/src/ngx_postgres_variable.c"
++    . auto/module
++
++else
++
+ HTTP_MODULES="$HTTP_MODULES ngx_postgres_module"
+
+ CORE_INCS="$CORE_INCS $ngx_feature_path"
+@@ -213,4 +223,6 @@
+ NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/src/ngx_postgres_escape.c $ngx_addon_dir/src/ngx_postgres_handler.c $ngx_addon_dir/src/ngx_postgres_keepalive.c $ngx_addon_dir/src/ngx_postgres_module.c $ngx_addon_dir/src/ngx_postgres_output.c $ngx_addon_dir/src/ngx_postgres_processor.c $ngx_addon_dir/src/ngx_postgres_rewrite.c $ngx_addon_dir/src/ngx_postgres_upstream.c $ngx_addon_dir/src/ngx_postgres_util.c $ngx_addon_dir/src/ngx_postgres_variable.c"
+ NGX_ADDON_DEPS="$NGX_ADDON_DEPS $ngx_addon_dir/src/ngx_postgres_escape.h $ngx_addon_dir/src/ngx_postgres_handler.h $ngx_addon_dir/src/ngx_postgres_keepalive.h $ngx_addon_dir/src/ngx_postgres_module.h $ngx_addon_dir/src/ngx_postgres_output.h $ngx_addon_dir/src/ngx_postgres_processor.h $ngx_addon_dir/src/ngx_postgres_rewrite.h $ngx_addon_dir/src/ngx_postgres_upstream.h $ngx_addon_dir/src/ngx_postgres_util.h $ngx_addon_dir/src/ngx_postgres_variable.h $ngx_addon_dir/src/ngx_postgres_ddebug.h $ngx_addon_dir/src/resty_dbd_stream.h"
+
++fi
++
+ have=NGX_POSTGRES_MODULE . auto/have
diff --git a/www/angie-module-postgres/files/patch-ngx_postgres-subrequest_in_memory b/www/angie-module-postgres/files/patch-ngx_postgres-subrequest_in_memory
new file mode 100644
index 000000000000..045f74357b47
--- /dev/null
+++ b/www/angie-module-postgres/files/patch-ngx_postgres-subrequest_in_memory
@@ -0,0 +1,18 @@
+--- ../ngx_postgres-1.0rc7/src/ngx_postgres_handler.c.orig
++++ ../ngx_postgres-1.0rc7/src/ngx_postgres_handler.c
+@@ -52,6 +52,7 @@
+
+     dd("entering");
+
++#if defined(nginx_version) && (nginx_version < 13010)
+     if (r->subrequest_in_memory) {
+         /* TODO: add support for subrequest in memory by
+          * emitting output into u->buffer instead */
+@@ -63,6 +64,7 @@
+         dd("returning NGX_HTTP_INTERNAL_SERVER_ERROR");
+         return NGX_HTTP_INTERNAL_SERVER_ERROR;
+     }
++#endif
+
+     pglcf = ngx_http_get_module_loc_conf(r, ngx_postgres_module);
+
diff --git a/www/angie-module-postgres/files/pkg-message.in b/www/angie-module-postgres/files/pkg-message.in
new file mode 100644
index 000000000000..b3a2a5f4c6d7
--- /dev/null
+++ b/www/angie-module-postgres/files/pkg-message.in
@@ -0,0 +1,15 @@
+[
+{ type: install
+  message: <<EOM
+
+The postgres dynamic module for Angie has been installed.
+To enable this module, add the following to %%PREFIX%%/etc/angie/angie.conf
+and reload angie:
+
+    load_module modules/ngx_postgres_module.so;
+
+Please refer to the module documentation for further details:
+https://github.com/FRiCKLE/ngx_postgres
+EOM
+}
+]
diff --git a/www/angie-module-postgres/pkg-descr b/www/angie-module-postgres/pkg-descr
new file mode 100644
index 000000000000..96bf9efd2ba6
--- /dev/null
+++ b/www/angie-module-postgres/pkg-descr
@@ -0,0 +1,2 @@
+This is an upstream module that allows Angie to communicate directly with
+PostgreSQL database.
diff --git a/www/angie-module-postgres/pkg-plist b/www/angie-module-postgres/pkg-plist
new file mode 100644
index 000000000000..470174501922
--- /dev/null
+++ b/www/angie-module-postgres/pkg-plist
@@ -0,0 +1,3 @@
+%%DOCSDIR%%/README.md
+%%MODDIR%%/ngx_postgres_module.so
+%%DEBUG%%%%MODDIR%%/ngx_postgres_module-debug.so