summaryrefslogtreecommitdiffstats
path: root/linhes/zabbix/fix-build-with-libxml2.patch
diff options
context:
space:
mode:
Diffstat (limited to 'linhes/zabbix/fix-build-with-libxml2.patch')
-rw-r--r--linhes/zabbix/fix-build-with-libxml2.patch230
1 files changed, 230 insertions, 0 deletions
diff --git a/linhes/zabbix/fix-build-with-libxml2.patch b/linhes/zabbix/fix-build-with-libxml2.patch
new file mode 100644
index 0000000..c4716f0
--- /dev/null
+++ b/linhes/zabbix/fix-build-with-libxml2.patch
@@ -0,0 +1,230 @@
+diff --git a/ChangeLog.d/bugfix/ZBX-23738 b/ChangeLog.d/bugfix/ZBX-23738
+new file mode 100644
+index 0000000..f7c7dd5
+--- /dev/null
++++ b/ChangeLog.d/bugfix/ZBX-23738
+@@ -0,0 +1 @@
++.......PS. [ZBX-23738] fixed Zabbix backend sources for libxml2 2.12.0 version changes (akozlovs)
+diff --git a/m4/libxml2.m4 b/m4/libxml2.m4
+index b0a3c77..282d3b6 100644
+--- a/m4/libxml2.m4
++++ b/m4/libxml2.m4
+@@ -30,10 +30,13 @@ AS_HELP_STRING([--with-libxml2@<:@=ARG@:>@],
+ [
+ if test "$withval" = "no"; then
+ want_libxml2="no"
++ _libxml2_with="no"
+ elif test "$withval" = "yes"; then
+ want_libxml2="yes"
++ _libxml2_with="yes"
+ else
+ want_libxml2="yes"
++ _libxml2_with=$withval
+ fi
+ ],
+ [want_libxml2="no"]
+@@ -49,27 +52,43 @@ AS_HELP_STRING([--with-libxml2@<:@=ARG@:>@],
+ dnl
+
+ if test "$want_libxml2" = "yes"; then
+- AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+- m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG()], [:])
++ if test "$_libxml2_with" != "yes"; then
++ XML2_INCDIR=$_libxml2_with/include
++ XML2_LIBDIR=$_libxml2_with/lib
++ LIBXML2_CFLAGS="-I$XML2_INCDIR"
++ LIBXML2_LDFLAGS="-L$XML2_LIBDIR"
++ _full_libxml2_libs=$LIBXML2_LDFLAGS
++ configured_libxml2="yes"
++ else
++ AC_REQUIRE([PKG_PROG_PKG_CONFIG])
++ m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG()], [:])
++
++ if test -x "$PKG_CONFIG"; then
+
+- if test -x "$PKG_CONFIG"; then
++ LIBXML2_CFLAGS="`$PKG_CONFIG --cflags libxml-2.0`"
+
+- LIBXML2_CFLAGS="`$PKG_CONFIG --cflags libxml-2.0`"
++ _full_libxml2_libs="`$PKG_CONFIG --libs libxml-2.0`"
++
++ for i in $_full_libxml2_libs; do
++ case $i in
++ -lxml2)
++ ;;
++ -L*)
++ LIBXML2_LDFLAGS="${LIBXML2_LDFLAGS} $i"
++ ;;
++ -R*)
++ LIBXML2_LDFLAGS="${LIBXML2_LDFLAGS} -Wl,$i"
++ ;;
++ esac
++ done
+
+- _full_libxml2_libs="`$PKG_CONFIG --libs libxml-2.0`"
++ configured_libxml2="yes"
++ else
++ configured_libxml2="no"
++ fi
++ fi
+
+- for i in $_full_libxml2_libs; do
+- case $i in
+- -lxml2)
+- ;;
+- -L*)
+- LIBXML2_LDFLAGS="${LIBXML2_LDFLAGS} $i"
+- ;;
+- -R*)
+- LIBXML2_LDFLAGS="${LIBXML2_LDFLAGS} -Wl,$i"
+- ;;
+- esac
+- done
++ if test "$configured_libxml2" = "yes"; then
+
+ if test "x$enable_static" = "xyes"; then
+ for i in $_full_libxml2_libs; do
+@@ -88,6 +107,20 @@ AS_HELP_STRING([--with-libxml2@<:@=ARG@:>@],
+ done
+ fi
+
++ if test "$_libxml2_with" != "yes"; then
++ if test -f $_libxml2_with/include/libxml2/libxml/xmlversion.h; then
++ LIBXML2_VERSION=`cat $_libxml2_with/include/libxml2/libxml/xmlversion.h \
++ | grep '#define.*LIBXML_DOTTED_VERSION.*' \
++ | sed -e 's/#define LIBXML_DOTTED_VERSION *//' \
++ | sed -e 's/ *\/\*.*\*\///' \
++ | sed -e 's/\"//g'`
++ else
++ AC_MSG_ERROR([Not found libxml2 library])
++ fi
++ else
++ LIBXML2_VERSION=`$PKG_CONFIG --version libxml-2.0`
++ fi
++
+ _save_libxml2_libs="${LIBS}"
+ _save_libxml2_ldflags="${LDFLAGS}"
+ _save_libxml2_cflags="${CFLAGS}"
+@@ -96,7 +129,7 @@ AS_HELP_STRING([--with-libxml2@<:@=ARG@:>@],
+ CFLAGS="${CFLAGS} ${LIBXML2_CFLAGS}"
+
+ AC_CHECK_LIB(xml2, xmlReadMemory, [
+- LIBXML2_LIBS="-lxml2 ${LIBXML2_LIBS}"
++ LIBXML2_LIBS="${LIBXML2_LIBS} -lxml2"
+ ],[
+ AC_MSG_ERROR([Not found libxml2 library])
+ ])
+@@ -108,8 +141,6 @@ AS_HELP_STRING([--with-libxml2@<:@=ARG@:>@],
+ unset _save_libxml2_ldflags
+ unset _save_libxml2_cflags
+
+- LIBXML2_VERSION=`$PKG_CONFIG --version libxml-2.0`
+-
+ AC_DEFINE([HAVE_LIBXML2], [1], [Define to 1 if libxml2 libraries are available])
+
+ found_libxml2="yes"
+diff --git a/src/libs/zbxpreproc/item_preproc.c b/src/libs/zbxpreproc/item_preproc.c
+index 88f94c6..8921b2d 100644
+--- a/src/libs/zbxpreproc/item_preproc.c
++++ b/src/libs/zbxpreproc/item_preproc.c
+@@ -27,6 +27,7 @@
+ #include "zbxxml.h"
+ #ifdef HAVE_LIBXML2
+ # include <libxml/xpath.h>
++# include <libxml/parser.h>
+ #endif
+
+ #include "zbxnum.h"
+@@ -896,7 +897,7 @@ int item_preproc_get_error_from_xml(const zbx_variant_t *value, const char *para
+ xmlDoc *doc = NULL;
+ xmlXPathContext *xpathCtx = NULL;
+ xmlXPathObject *xpathObj = NULL;
+- xmlErrorPtr pErr;
++ const xmlError *pErr;
+ xmlBufferPtr xmlBufferLocal;
+
+ zbx_variant_copy(&value_str, value);
+diff --git a/src/libs/zbxpreproc/pp_manager.c b/src/libs/zbxpreproc/pp_manager.c
+index 9959a9f..a39f95d 100644
+--- a/src/libs/zbxpreproc/pp_manager.c
++++ b/src/libs/zbxpreproc/pp_manager.c
+@@ -34,6 +34,7 @@
+
+ #ifdef HAVE_LIBXML2
+ # include <libxml/xpath.h>
++# include <libxml/parser.h>
+ #endif
+
+ #define PP_STARTUP_TIMEOUT 10
+diff --git a/src/libs/zbxxml/xml.c b/src/libs/zbxxml/xml.c
+index 00eadce..7763be8 100644
+--- a/src/libs/zbxxml/xml.c
++++ b/src/libs/zbxxml/xml.c
+@@ -27,6 +27,7 @@
+
+ #ifdef HAVE_LIBXML2
+ # include <libxml/xpath.h>
++# include <libxml/parser.h>
+ #endif
+
+ typedef struct _zbx_xml_node_t zbx_xml_node_t;
+@@ -282,7 +283,7 @@ int zbx_query_xpath(zbx_variant_t *value, const char *params, char **errmsg)
+ xmlXPathContext *xpathCtx;
+ xmlXPathObject *xpathObj;
+ xmlNodeSetPtr nodeset;
+- xmlErrorPtr pErr;
++ const xmlError *pErr;
+ xmlBufferPtr xmlBufferLocal;
+
+ if (NULL == (doc = xmlReadMemory(value->data.str, strlen(value->data.str), "noname.xml", NULL, 0)))
+@@ -638,7 +639,7 @@ static void vector_to_json(zbx_vector_xml_node_ptr_t *nodes, struct zbx_json *js
+ ******************************************************************************/
+ int zbx_open_xml(char *data, int options, int maxerrlen, void **xml_doc, void **root_node, char **errmsg)
+ {
+- xmlErrorPtr pErr;
++ const xmlError *pErr;
+
+ if (NULL == (*xml_doc = xmlReadMemory(data, strlen(data), "noname.xml", NULL, options)))
+ {
+@@ -694,7 +695,7 @@ int zbx_open_xml(char *data, int options, int maxerrlen, void **xml_doc, void **
+ ******************************************************************************/
+ int zbx_check_xml_memory(char *mem, int maxerrlen, char **errmsg)
+ {
+- xmlErrorPtr pErr;
++ const xmlError *pErr;
+
+ if (NULL == mem)
+ {
+@@ -949,7 +950,7 @@ int zbx_json_to_xml(char *json_data, char **xstr, char **errmsg)
+ int size, ret = FAIL;
+ struct zbx_json_parse jp;
+ xmlDoc *doc = NULL;
+- xmlErrorPtr pErr;
++ const xmlError *pErr;
+ xmlChar *xmem;
+
+ if (NULL == (doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION)))
+@@ -1005,7 +1006,11 @@ zbx_libxml_error_t;
+ * err - [IN] the libxml2 error message *
+ * *
+ ******************************************************************************/
++#if 21200 > LIBXML_VERSION /* version 2.12.0 */
+ static void libxml_handle_error_xpath_check(void *user_data, xmlErrorPtr err)
++#else
++static void libxml_handle_error_xpath_check(void *user_data, const xmlError *err)
++#endif
+ {
+ zbx_libxml_error_t *err_ctx;
+
+@@ -1155,7 +1160,11 @@ out:
+ * err - [IN] the libxml2 error message *
+ * *
+ ******************************************************************************/
++#if 21200 > LIBXML_VERSION /* version 2.12.0 */
+ static void libxml_handle_error_try_read_value(void *user_data, xmlErrorPtr err)
++#else
++static void libxml_handle_error_try_read_value(void *user_data, const xmlError *err)
++#endif
+ {
+ ZBX_UNUSED(user_data);
+ ZBX_UNUSED(err);