pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

jabberd14: add options for databases



Module Name:	pkgsrc-wip
Committed By:	Frédéric Fauberteau <frederic%fauberteau.org@localhost>
Pushed By:	frederic
Date:		Sun Nov 3 10:27:00 2019 +0100
Changeset:	1bb0852f0f68ced8bd57020233ec6dc64f4c0d00

Modified Files:
	jabberd14/Makefile
	jabberd14/distinfo
	jabberd14/patches/patch-configure.ac
Added Files:
	jabberd14/options.mk
	jabberd14/patches/patch-jabberd_lib_xmlnode.cc
	jabberd14/patches/patch-jabberd_lib_xmlnode.hh
	jabberd14/patches/patch-xdb__sql_xdb__sql.cc

Log Message:
jabberd14: add options for databases

pkgsrc changes:
---------------
  * Add options.mk to exclusively choose a database engine between MySQL
    and PostgreSQL.
  * Add necessary patches to appease g++ and compile with PostgreSQL
    support.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=1bb0852f0f68ced8bd57020233ec6dc64f4c0d00

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 jabberd14/Makefile                             |  2 +
 jabberd14/distinfo                             |  5 +-
 jabberd14/options.mk                           | 27 ++++++++
 jabberd14/patches/patch-configure.ac           |  9 +++
 jabberd14/patches/patch-jabberd_lib_xmlnode.cc | 41 ++++++++++++
 jabberd14/patches/patch-jabberd_lib_xmlnode.hh | 37 +++++++++++
 jabberd14/patches/patch-xdb__sql_xdb__sql.cc   | 92 ++++++++++++++++++++++++++
 7 files changed, 212 insertions(+), 1 deletion(-)

diffs:
diff --git a/jabberd14/Makefile b/jabberd14/Makefile
index 1c892b5781..fc5d7e9b69 100644
--- a/jabberd14/Makefile
+++ b/jabberd14/Makefile
@@ -38,6 +38,8 @@ USE_LIBTOOL=		yes
 USE_TOOLS+=		aclocal autoconf automake gettext gmake pkg-config
 USE_LANGUAGES=		c c++11
 
+.include "options.mk"
+
 BUILD_DEFS+=		JABBERD_PIDDIR JABBERD_SPOOLDIR
 
 PKG_GROUPS=		${JABBERD_GROUP}
diff --git a/jabberd14/distinfo b/jabberd14/distinfo
index 6c4e7ceec8..d17957d4e5 100644
--- a/jabberd14/distinfo
+++ b/jabberd14/distinfo
@@ -5,5 +5,8 @@ RMD160 (jabberd-1.6.1.1.80-b2b871eaf3f6455d7d37113ce23d6bc59c8da70f.tar.gz) = 77
 SHA512 (jabberd-1.6.1.1.80-b2b871eaf3f6455d7d37113ce23d6bc59c8da70f.tar.gz) = b62ff5046b6e50491685775fb09d421ec561ad3c64536e80aa29631e9adcdcef23ee9a576ed7621786a3a89abc00bd20b0799041168aca40c7ac9d351969f5d3
 Size (jabberd-1.6.1.1.80-b2b871eaf3f6455d7d37113ce23d6bc59c8da70f.tar.gz) = 655198 bytes
 SHA1 (patch-Makefile.am) = 928cdb5aa77e80f5b698f08b623484d93d3500ab
-SHA1 (patch-configure.ac) = 0542bf8cebce67fe35d76232110dafc0ff398bbd
+SHA1 (patch-configure.ac) = 2b33279ad40c2f8857324e48c1d5784fc6cc0bd3
+SHA1 (patch-jabberd_lib_xmlnode.cc) = 64dbacdb09753e74a05a3873401051339f616133
+SHA1 (patch-jabberd_lib_xmlnode.hh) = 58a3dc7dafca01e494aa99b28445d6c0157c35ca
 SHA1 (patch-jsm_sessions.cc) = 051bfddb6bbec1684fd89e0c0c0fbc48fa89a568
+SHA1 (patch-xdb__sql_xdb__sql.cc) = 5807e42a55803d27f8c39c3a3c613d2b91854bfc
diff --git a/jabberd14/options.mk b/jabberd14/options.mk
new file mode 100644
index 0000000000..34038d68cc
--- /dev/null
+++ b/jabberd14/options.mk
@@ -0,0 +1,27 @@
+# $NetBSD: $
+
+PKG_OPTIONS_VAR=		PKG_OPTIONS.jabberd
+PKG_OPTIONS_OPTIONAL_GROUPS=	database
+PKG_OPTIONS_GROUP.database=	mysql pgsql
+
+.include "../../mk/bsd.options.mk"
+
+###
+### MySQL support
+###
+.if !empty(PKG_OPTIONS:Mmysql)
+CONFIGURE_ARGS+=		--with-mysql=${BUILDLINK_INCDIRS.mysql}
+. include "../../mk/mysql.buildlink3.mk"
+.else
+CONFIGURE_ARGS+=		--with-mysql=no
+.endif
+
+###
+### PostgresSQL support
+###
+.if !empty(PKG_OPTIONS:Mpgsql)
+CONFIGURE_ARGS+=		--with-postgresql=${BUILDLINK_INCDIRS.pgsql}
+.  include "../../mk/pgsql.buildlink3.mk"
+.else
+CONFIGURE_ARGS+=		--with-postgresql=no
+.endif
diff --git a/jabberd14/patches/patch-configure.ac b/jabberd14/patches/patch-configure.ac
index 35e059366d..0c2a0d03fc 100644
--- a/jabberd14/patches/patch-configure.ac
+++ b/jabberd14/patches/patch-configure.ac
@@ -13,3 +13,12 @@ $NetBSD$
  
  dnl Check for programs
  AC_PROG_CC
+@@ -348,7 +348,7 @@ if test "$postgresql" != "no"; then
+         LDFLAGS="${LDFLAGS} -L$postgresql/lib"
+         CPPFLAGS="${CPPFLAGS} -I$postgresql/include"
+     fi
+-    AC_CHECK_HEADER(postgresql/libpq-fe.h,
++    AC_CHECK_HEADER(libpq-fe.h,
+                     AC_CHECK_LIB(pq, PQconnectdb,
+                                  [postgresql=yes LIBS="${LIBS} -lpq"], postgresql=no),
+                                  postgresql=no)
diff --git a/jabberd14/patches/patch-jabberd_lib_xmlnode.cc b/jabberd14/patches/patch-jabberd_lib_xmlnode.cc
new file mode 100644
index 0000000000..fe18769566
--- /dev/null
+++ b/jabberd14/patches/patch-jabberd_lib_xmlnode.cc
@@ -0,0 +1,41 @@
+$NetBSD$
+
+* Move struct xmlnode_t from xmlnode.cc to xmlnode.hh to appease g++.
+
+--- jabberd/lib/xmlnode.cc.orig	2019-09-29 18:37:09.000000000 +0000
++++ jabberd/lib/xmlnode.cc
+@@ -44,34 +44,6 @@
+ #include <sstream>
+ #include <stdexcept>
+ 
+-//----[ internal types ]-------------------------------------------------------
+-
+-struct xmlnode_t {
+-    char *name;          /**< local name of the xmlnode */
+-    char *prefix;        /**< namespace prefix for this xmlnode */
+-    char *ns_iri;        /**< namespace IRI for this xmlnode */
+-    unsigned short type; /**< type of the xmlnode, one of ::NTYPE_TAG,
+-                            ::NTYPE_ATTRIB, ::NTYPE_CDATA, or ::NTYPE_UNDEF */
+-    char *data;  /**< data of the xmlnode, for attributes this is the value, for
+-                    text nodes this is the text */
+-    int data_sz; /**< length of the data in the xmlnode */
+-                 /*     int                 complete; */
+-    pool p; /**< memory pool used by this xmlnode (the same as for all other
+-               xmlnode in a tree) */
+-    struct xmlnode_t
+-        *parent; /**< parent node for this node, or NULL for the root element */
+-    struct xmlnode_t *firstchild; /**< first child element of this node, or NULL
+-                                     for no child elements */
+-    struct xmlnode_t *lastchild;  /**< last child element of this node, or NULL
+-                                     for no child elements */
+-    struct xmlnode_t *prev;       /**< previous sibling */
+-    struct xmlnode_t *next;       /**< next sibling */
+-    struct xmlnode_t *firstattrib; /**< first attribute node of this node */
+-    struct xmlnode_t *lastattrib;  /**< last attribute node of this node */
+-};
+-
+-//-----------------------------------------------------------------------------
+-
+ #ifdef POOL_DEBUG
+ std::map<pool, std::list<xmlnode>> existing_xmlnodes;
+ #endif
diff --git a/jabberd14/patches/patch-jabberd_lib_xmlnode.hh b/jabberd14/patches/patch-jabberd_lib_xmlnode.hh
new file mode 100644
index 0000000000..4278199728
--- /dev/null
+++ b/jabberd14/patches/patch-jabberd_lib_xmlnode.hh
@@ -0,0 +1,37 @@
+$NetBSD$
+
+* Move struct xmlnode_t from xmlnode.cc to xmlnode.hh to appease g++.
+
+--- jabberd/lib/xmlnode.hh.orig	2019-09-29 18:37:09.000000000 +0000
++++ jabberd/lib/xmlnode.hh
+@@ -48,7 +48,29 @@
+     ' ' /**< character used to separate NS IRI from local name in expat        \
+            callbacks */
+ 
+-typedef struct xmlnode_t _xmlnode, *xmlnode;
++typedef struct xmlnode_t {
++    char *name;          /**< local name of the xmlnode */
++    char *prefix;        /**< namespace prefix for this xmlnode */
++    char *ns_iri;        /**< namespace IRI for this xmlnode */
++    unsigned short type; /**< type of the xmlnode, one of ::NTYPE_TAG,
++                            ::NTYPE_ATTRIB, ::NTYPE_CDATA, or ::NTYPE_UNDEF */
++    char *data;  /**< data of the xmlnode, for attributes this is the value, for
++                    text nodes this is the text */
++    int data_sz; /**< length of the data in the xmlnode */
++                 /*     int                 complete; */
++    pool p; /**< memory pool used by this xmlnode (the same as for all other
++               xmlnode in a tree) */
++    struct xmlnode_t
++        *parent; /**< parent node for this node, or NULL for the root element */
++    struct xmlnode_t *firstchild; /**< first child element of this node, or NULL
++                                     for no child elements */
++    struct xmlnode_t *lastchild;  /**< last child element of this node, or NULL
++                                     for no child elements */
++    struct xmlnode_t *prev;       /**< previous sibling */
++    struct xmlnode_t *next;       /**< next sibling */
++    struct xmlnode_t *firstattrib; /**< first attribute node of this node */
++    struct xmlnode_t *lastattrib;  /**< last attribute node of this node */
++} _xmlnode, *xmlnode;
+ 
+ namespace xmppd {
+ 
diff --git a/jabberd14/patches/patch-xdb__sql_xdb__sql.cc b/jabberd14/patches/patch-xdb__sql_xdb__sql.cc
new file mode 100644
index 0000000000..fac1cad555
--- /dev/null
+++ b/jabberd14/patches/patch-xdb__sql_xdb__sql.cc
@@ -0,0 +1,92 @@
+$NetBSD$
+
+* Include missing header for xmlnode_str.
+* Header files of pkgsrc PostgreSQL are not in postgresql/ directory.
+* Reorder xdbsql_struct.
+* Change function signature.
+* Add missing enumeration values in switch.
+* Add parentheses for test condition used as boolean value.
+
+--- xdb_sql/xdb_sql.cc.orig	2019-09-29 18:37:09.000000000 +0000
++++ xdb_sql/xdb_sql.cc
+@@ -24,6 +24,7 @@
+ 
+ #include <jabberd.h>
+ 
++#include <expat.hh>
+ #include <namespaces.hh>
+ 
+ #include <list>
+@@ -40,7 +41,7 @@
+ #endif
+ 
+ #ifdef HAVE_POSTGRESQL
+-#include <postgresql/libpq-fe.h>
++#include <libpq-fe.h>
+ #endif
+ 
+ /**
+@@ -91,12 +92,6 @@ typedef struct xdbsql_struct {
+     std::map<std::string, _xdbsql_ns_def>
+         namespace_defs; /**< definitions of queries for the different namespaces
+                          */
+-    char *onconnect; /**< SQL query that should be executed after we connected
+-                        to the database server */
+-    xht namespace_prefixes;     /**< prefixes for the namespaces (key = prefix,
+-                                   value = ns_iri) */
+-    xht std_namespace_prefixes; /**< prefixes used by the component itself for
+-                                   the namespaces */
+ #ifdef HAVE_MYSQL
+     int use_mysql;        /**< if we want to use the mysql driver */
+     MYSQL *mysql;         /**< our database handle */
+@@ -114,6 +109,12 @@ typedef struct xdbsql_struct {
+     PGconn *postgresql;        /**< our postgresql connection handle */
+     char *postgresql_conninfo; /**< settings used to connect to postgresql */
+ #endif
++    char *onconnect; /**< SQL query that should be executed after we connected
++                        to the database server */
++    xht namespace_prefixes;     /**< prefixes for the namespaces (key = prefix,
++                                   value = ns_iri) */
++    xht std_namespace_prefixes; /**< prefixes used by the component itself for
++                                   the namespaces */
+ } * xdbsql, _xdbsql;
+ 
+ /* forward declaration */
+@@ -414,7 +415,7 @@ static int xdb_sql_execute_mysql(instanc
+  * @return 0 on success, non zero on failure
+  */
+ #ifdef HAVE_POSTGRESQL
+-static int xdb_sql_execute_postgresql(instance i, xdbsql xq, char *query,
++static int xdb_sql_execute_postgresql(instance i, xdbsql xq, char const *query,
+                                       xmlnode xmltemplate, xmlnode result) {
+     PGresult *res = NULL;
+     ExecStatusType status = static_cast<ExecStatusType>(0);
+@@ -452,6 +453,7 @@ static int xdb_sql_execute_postgresql(in
+         case PGRES_EMPTY_QUERY:
+         case PGRES_BAD_RESPONSE:
+         case PGRES_FATAL_ERROR:
++        case PGRES_NONFATAL_ERROR:
+             log_warn(i->id, "%s: %s", PQresStatus(status),
+                      PQresultErrorMessage(res));
+             PQclear(res);
+@@ -459,6 +461,9 @@ static int xdb_sql_execute_postgresql(in
+         case PGRES_COMMAND_OK:
+         case PGRES_COPY_OUT:
+         case PGRES_COPY_IN:
++        case PGRES_COPY_BOTH:
++        case PGRES_SINGLE_TUPLE:
++        case PGRES_TUPLES_OK:
+             PQclear(res);
+             return 0;
+     }
+@@ -473,8 +478,8 @@ static int xdb_sql_execute_postgresql(in
+         new_instance = xmlnode_dup_pool(result->p, xmltemplate);
+ 
+         /* find variables in the template and replace them with values */
+-        while (variable = xdb_sql_find_node_recursive(new_instance, "value",
+-                                                      NS_JABBERD_XDBSQL)) {
++        while ((variable = xdb_sql_find_node_recursive(new_instance, "value",
++                                                      NS_JABBERD_XDBSQL))) {
+             xmlnode parent = xmlnode_get_parent(variable);
+             int value =
+                 j_atoi(xmlnode_get_attrib_ns(variable, "value", NULL), 0);


Home | Main Index | Thread Index | Old Index