add files

This commit is contained in:
Mahno 2025-02-04 18:41:49 +08:00
commit ddf879a3de
10 changed files with 3992 additions and 0 deletions

3
_multibuild Normal file
View File

@ -0,0 +1,3 @@
<multibuild>
<flavor>python</flavor>
</multibuild>

6
baselibs.conf Normal file
View File

@ -0,0 +1,6 @@
libxml2-2
obsoletes "libxml2-<targettype> < <version>"
provides "libxml2-<targettype> = <version>"
libxml2-devel
requires -libxml2-<targettype>
requires "libxml2-2-<targettype> = <version>"

BIN
libxml2-2.13.5.tar.xz Normal file

Binary file not shown.

View File

@ -0,0 +1,108 @@
---
xpath.c | 40 +++++++++++++++++++++++++++++-----------
1 file changed, 29 insertions(+), 11 deletions(-)
Index: libxml2-2.13.5/xpath.c
===================================================================
--- libxml2-2.13.5.orig/xpath.c
+++ libxml2-2.13.5/xpath.c
@@ -25,6 +25,7 @@
#include <limits.h>
#include <string.h>
#include <stddef.h>
+#include <stdlib.h>
#include <math.h>
#include <float.h>
#include <ctype.h>
@@ -104,14 +105,32 @@
#define XPATH_MAX_STACK_DEPTH 1000000
/*
- * XPATH_MAX_NODESET_LENGTH:
+ * XPATH_DEFAULT_MAX_NODESET_LENGTH:
* when evaluating an XPath expression nodesets are created and we
- * arbitrary limit the maximum length of those node set. 10000000 is
- * an insanely large value which should never be reached under normal
- * circumstances, one would first need to construct an in memory tree
+ * arbitrary limit the maximum length of those node set. Default value is
+ * 10000000, an insanely large value which should never be reached under
+ * normal circumstances, one would first need to construct an in memory tree
* with more than 10 millions nodes.
+ *
+ * Adjustable via LIBXML_MAX_NODESET_LENGTH env variable.
+ * Absolute maximum is INT_MAX.
*/
-#define XPATH_MAX_NODESET_LENGTH 10000000
+#define XPATH_DEFAULT_MAX_NODESET_LENGTH 10000000
+
+int
+get_max_nodeset_len() {
+ const char *max_nodeset_len_str = getenv("LIBXML_MAX_NODESET_LENGTH");
+ int max_nodeset_len = XPATH_DEFAULT_MAX_NODESET_LENGTH;
+
+ if (max_nodeset_len_str != NULL) {
+ max_nodeset_len = strtol(max_nodeset_len_str, NULL, 10);
+
+ if (max_nodeset_len <= 0 || max_nodeset_len > INT_MAX)
+ max_nodeset_len = XPATH_DEFAULT_MAX_NODESET_LENGTH;
+ }
+
+ return max_nodeset_len;
+}
/*
* XPATH_MAX_RECRUSION_DEPTH:
@@ -2881,7 +2900,7 @@ xmlXPathNodeSetAddNs(xmlNodeSetPtr cur,
} else if (cur->nodeNr == cur->nodeMax) {
xmlNodePtr *temp;
- if (cur->nodeMax >= XPATH_MAX_NODESET_LENGTH)
+ if (cur->nodeMax >= get_max_nodeset_len())
return(-1);
temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax * 2 *
sizeof(xmlNodePtr));
@@ -2933,7 +2952,7 @@ xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xm
} else if (cur->nodeNr == cur->nodeMax) {
xmlNodePtr *temp;
- if (cur->nodeMax >= XPATH_MAX_NODESET_LENGTH)
+ if (cur->nodeMax >= get_max_nodeset_len())
return(-1);
temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax * 2 *
sizeof(xmlNodePtr));
@@ -2983,7 +3002,7 @@ xmlXPathNodeSetAddUnique(xmlNodeSetPtr c
} else if (cur->nodeNr == cur->nodeMax) {
xmlNodePtr *temp;
- if (cur->nodeMax >= XPATH_MAX_NODESET_LENGTH)
+ if (cur->nodeMax >= get_max_nodeset_len())
return(-1);
temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax * 2 *
sizeof(xmlNodePtr));
@@ -3071,7 +3090,7 @@ xmlXPathNodeSetMerge(xmlNodeSetPtr val1,
} else if (val1->nodeNr == val1->nodeMax) {
xmlNodePtr *temp;
- if (val1->nodeMax >= XPATH_MAX_NODESET_LENGTH)
+ if (val1->nodeMax >= get_max_nodeset_len())
goto error;
temp = (xmlNodePtr *) xmlRealloc(val1->nodeTab, val1->nodeMax * 2 *
sizeof(xmlNodePtr));
@@ -3157,7 +3176,7 @@ xmlXPathNodeSetMergeAndClear(xmlNodeSetP
} else if (set1->nodeNr >= set1->nodeMax) {
xmlNodePtr *temp;
- if (set1->nodeMax >= XPATH_MAX_NODESET_LENGTH)
+ if (set1->nodeMax >= get_max_nodeset_len())
goto error;
temp = (xmlNodePtr *) xmlRealloc(
set1->nodeTab, set1->nodeMax * 2 * sizeof(xmlNodePtr));
@@ -3212,7 +3231,7 @@ xmlXPathNodeSetMergeAndClearNoDupls(xmlN
} else if (set1->nodeNr >= set1->nodeMax) {
xmlNodePtr *temp;
- if (set1->nodeMax >= XPATH_MAX_NODESET_LENGTH)
+ if (set1->nodeMax >= get_max_nodeset_len())
goto error;
temp = (xmlNodePtr *) xmlRealloc(
set1->nodeTab, set1->nodeMax * 2 * sizeof(xmlNodePtr));

View File

@ -0,0 +1,28 @@
From 07b1c4c8a736a31ac4b8ae13ea25d50793dfea83 Mon Sep 17 00:00:00 2001
From: Mike Gorse <mgorse@alum.wpi.edu>
Date: Fri, 25 Jan 2019 12:55:52 -0600
Subject: [PATCH] python: return None if PY_IMPORT_STRING returns NULL
PY_IMPORT_STRING might return NULL on python 3 if, ie, a string can't be
encoded. We should check for this and return None, rather than returning
NULL. Fixes a NULL pointer dereference when reporting an error with an
invalid string.
---
python/types.c | 4 ++++
1 file changed, 4 insertions(+)
Index: libxml2-2.10.3/python/types.c
===================================================================
--- libxml2-2.10.3.orig/python/types.c
+++ libxml2-2.10.3/python/types.c
@@ -274,6 +274,10 @@ libxml_charPtrConstWrap(const char *str)
return (Py_None);
}
ret = PY_IMPORT_STRING(str);
+ if (ret == NULL) {
+ Py_INCREF(Py_None);
+ return (Py_None);
+ }
return (ret);
}

View File

@ -0,0 +1,38 @@
---
python/libxml.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
Index: libxml2-2.12.0/python/libxml.c
===================================================================
--- libxml2-2.12.0.orig/python/libxml.c
+++ libxml2-2.12.0/python/libxml.c
@@ -1505,6 +1505,7 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
PyObject *message;
PyObject *result;
char str[1000];
+ unsigned char *ptr = (unsigned char *)str;
if (libxml_xmlPythonErrorFuncHandler == NULL) {
va_start(ap, msg);
@@ -1516,12 +1517,20 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
str[999] = 0;
va_end(ap);
+#if PY_MAJOR_VERSION >= 3
+ /* Ensure the error string doesn't start at UTF8 continuation. */
+ while (*ptr && (*ptr & 0xc0) == 0x80)
+ ptr++;
+#endif
+
list = PyTuple_New(2);
PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt);
Py_XINCREF(libxml_xmlPythonErrorFuncCtxt);
- message = libxml_charPtrConstWrap(str);
+ message = libxml_charPtrConstWrap(ptr);
PyTuple_SetItem(list, 1, message);
result = PyObject_CallObject(libxml_xmlPythonErrorFuncHandler, list);
+ /* Forget any errors caused in the error handler. */
+ PyErr_Clear();
Py_XDECREF(list);
Py_XDECREF(result);
}

View File

@ -0,0 +1,363 @@
From 6208f86edd59e31a51a8d9b300d428504adb25a7 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Tue, 28 Jan 2025 20:13:58 +0100
Subject: [PATCH] xmllint: Support compressed input from stdin
Another regression related to reading from stdin.
Making a "-" filename read from stdin was deeply baked into the core
IO code but is inherently insecure. I really want to reenable this
dangerous feature as sparingly as possible.
Add a new hidden parser option to make xmllint work. This will likely
turn into a public option that must be opted in later.
Allow compressed stdin in xmlReadFile to support xmlstarlet and older
versions of xsltproc. So far, these are the only known command-line
tools that rely on "-" meaning stdin.
---
include/private/io.h | 3 +
include/private/parser.h | 4 +
parser.c | 9 ++-
parserInternals.c | 9 ++-
xmlIO.c | 160 +++++++++++++++++++++++----------------
xmllint.c | 9 ++-
6 files changed, 121 insertions(+), 73 deletions(-)
diff --git a/include/private/io.h b/include/private/io.h
index a2535ae19..d116fadaa 100644
--- a/include/private/io.h
+++ b/include/private/io.h
@@ -24,6 +24,9 @@ XML_HIDDEN xmlParserInputBufferPtr
xmlNewInputBufferMemory(const void *mem, size_t size, int flags,
xmlCharEncoding enc);
+XML_HIDDEN int
+xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int unzip);
+
#ifdef LIBXML_OUTPUT_ENABLED
XML_HIDDEN xmlOutputBufferPtr
xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder);
diff --git a/include/private/parser.h b/include/private/parser.h
index b14bebf91..4a8004207 100644
--- a/include/private/parser.h
+++ b/include/private/parser.h
@@ -90,6 +90,10 @@ xmlParserNsLookupSax(xmlParserCtxtPtr ctxt, const xmlChar *prefix);
#define XML_INPUT_BUF_STATIC (1u << 1)
#define XML_INPUT_BUF_ZERO_TERMINATED (1u << 2)
+#define XML_INPUT_UNZIP (1u << 3)
+
+/* Internal parser option */
+#define XML_PARSE_UNZIP (1 << 24)
XML_HIDDEN xmlParserInputPtr
xmlNewInputURL(xmlParserCtxtPtr ctxt, const char *url, const char *publicId,
diff --git a/parser.c b/parser.c
index 52ca35652..44467355a 100644
--- a/parser.c
+++ b/parser.c
@@ -13890,7 +13890,8 @@ xmlReadFile(const char *filename, const char *encoding, int options)
* should be removed at some point.
*/
if ((filename != NULL) && (filename[0] == '-') && (filename[1] == 0))
- input = xmlNewInputFd(ctxt, filename, STDIN_FILENO, encoding, 0);
+ input = xmlNewInputFd(ctxt, filename, STDIN_FILENO, encoding,
+ XML_INPUT_UNZIP);
else
input = xmlNewInputURL(ctxt, filename, NULL, encoding, 0);
@@ -14141,6 +14142,7 @@ xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd,
const char *URL, const char *encoding, int options)
{
xmlParserInputPtr input;
+ int inputFlags;
if (ctxt == NULL)
return(NULL);
@@ -14148,7 +14150,10 @@ xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd,
xmlCtxtReset(ctxt);
xmlCtxtUseOptions(ctxt, options);
- input = xmlNewInputFd(ctxt, URL, fd, encoding, 0);
+ inputFlags = 0;
+ if (options & XML_PARSE_UNZIP)
+ inputFlags |= XML_INPUT_UNZIP;
+ input = xmlNewInputFd(ctxt, URL, fd, encoding, inputFlags);
return(xmlCtxtParseDocument(ctxt, input));
}
diff --git a/parserInternals.c b/parserInternals.c
index 6ddd28e78..c9afe21d1 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -1715,18 +1715,23 @@ xmlNewInputString(xmlParserCtxtPtr ctxt, const char *url,
*/
xmlParserInputPtr
xmlNewInputFd(xmlParserCtxtPtr ctxt, const char *url,
- int fd, const char *encoding, int flags ATTRIBUTE_UNUSED) {
+ int fd, const char *encoding, int flags) {
xmlParserInputBufferPtr buf;
if ((ctxt == NULL) || (fd < 0))
return(NULL);
- buf = xmlParserInputBufferCreateFd(fd, XML_CHAR_ENCODING_NONE);
+ buf = xmlAllocParserInputBuffer(XML_CHAR_ENCODING_NONE);
if (buf == NULL) {
xmlCtxtErrMemory(ctxt);
return(NULL);
}
+ if (xmlInputFromFd(buf, fd, (flags & XML_INPUT_UNZIP) != 0) < 0) {
+ xmlFreeParserInputBuffer(buf);
+ return(NULL);
+ }
+
return(xmlNewInputInternal(ctxt, buf, url, encoding));
}
diff --git a/xmlIO.c b/xmlIO.c
index 746cb3e26..a758caa32 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -1158,65 +1158,36 @@ xmlIODefaultMatch(const char *filename ATTRIBUTE_UNUSED) {
return(1);
}
-/**
- * xmlInputDefaultOpen:
- * @buf: input buffer to be filled
- * @filename: filename or URI
- *
- * Returns an xmlParserErrors code.
- */
-static int
-xmlInputDefaultOpen(xmlParserInputBufferPtr buf, const char *filename) {
- int ret;
- int fd;
-
-#ifdef LIBXML_FTP_ENABLED
- if (xmlIOFTPMatch(filename)) {
- buf->context = xmlIOFTPOpen(filename);
-
- if (buf->context != NULL) {
- buf->readcallback = xmlIOFTPRead;
- buf->closecallback = xmlIOFTPClose;
- return(XML_ERR_OK);
- }
- }
-#endif /* LIBXML_FTP_ENABLED */
-
-#ifdef LIBXML_HTTP_ENABLED
- if (xmlIOHTTPMatch(filename)) {
- buf->context = xmlIOHTTPOpen(filename);
-
- if (buf->context != NULL) {
- buf->readcallback = xmlIOHTTPRead;
- buf->closecallback = xmlIOHTTPClose;
- return(XML_ERR_OK);
- }
- }
-#endif /* LIBXML_HTTP_ENABLED */
+int
+xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int unzip) {
+ int copy;
- if (!xmlFileMatch(filename))
- return(XML_IO_ENOENT);
+ (void) unzip;
#ifdef LIBXML_LZMA_ENABLED
- {
+ if (unzip) {
xzFile xzStream;
+ off_t pos;
- ret = xmlFdOpen(filename, 0, &fd);
- if (ret != XML_ERR_OK)
- return(ret);
+ pos = lseek(fd, 0, SEEK_CUR);
- xzStream = __libxml2_xzdopen(filename, fd, "rb");
+ copy = dup(fd);
+ if (copy == -1)
+ return(xmlIOErr(0, "dup()"));
+
+ xzStream = __libxml2_xzdopen("?", copy, "rb");
if (xzStream == NULL) {
- close(fd);
+ close(copy);
} else {
- /*
- * Non-regular files like pipes can't be reopened.
- * If a file isn't seekable, we pipe uncompressed
- * input through xzlib.
- */
- if ((lseek(fd, 0, SEEK_CUR) < 0) ||
- (__libxml2_xzcompressed(xzStream) > 0)) {
+ if ((__libxml2_xzcompressed(xzStream) > 0) ||
+ /* Try to rewind if not gzip compressed */
+ (pos < 0) ||
+ (lseek(fd, pos, SEEK_SET) < 0)) {
+ /*
+ * If a file isn't seekable, we pipe uncompressed
+ * input through xzlib.
+ */
buf->context = xzStream;
buf->readcallback = xmlXzfileRead;
buf->closecallback = xmlXzfileClose;
@@ -1231,25 +1202,29 @@ xmlInputDefaultOpen(xmlParserInputBufferPtr buf, const char *filename) {
#endif /* LIBXML_LZMA_ENABLED */
#ifdef LIBXML_ZLIB_ENABLED
- {
+ if (unzip) {
gzFile gzStream;
+ off_t pos;
- ret = xmlFdOpen(filename, 0, &fd);
- if (ret != XML_ERR_OK)
- return(ret);
+ pos = lseek(fd, 0, SEEK_CUR);
+
+ copy = dup(fd);
+ if (copy == -1)
+ return(xmlIOErr(0, "dup()"));
- gzStream = gzdopen(fd, "rb");
+ gzStream = gzdopen(copy, "rb");
if (gzStream == NULL) {
- close(fd);
+ close(copy);
} else {
- /*
- * Non-regular files like pipes can't be reopened.
- * If a file isn't seekable, we pipe uncompressed
- * input through zlib.
- */
- if ((lseek(fd, 0, SEEK_CUR) < 0) ||
- (gzdirect(gzStream) == 0)) {
+ if ((gzdirect(gzStream) == 0) ||
+ /* Try to rewind if not gzip compressed */
+ (pos < 0) ||
+ (lseek(fd, pos, SEEK_SET) < 0)) {
+ /*
+ * If a file isn't seekable, we pipe uncompressed
+ * input through zlib.
+ */
buf->context = gzStream;
buf->readcallback = xmlGzfileRead;
buf->closecallback = xmlGzfileClose;
@@ -1263,16 +1238,67 @@ xmlInputDefaultOpen(xmlParserInputBufferPtr buf, const char *filename) {
}
#endif /* LIBXML_ZLIB_ENABLED */
- ret = xmlFdOpen(filename, 0, &fd);
- if (ret != XML_ERR_OK)
- return(ret);
+ copy = dup(fd);
+ if (copy == -1)
+ return(xmlIOErr(0, "dup()"));
- buf->context = (void *) (ptrdiff_t) fd;
+ buf->context = (void *) (ptrdiff_t) copy;
buf->readcallback = xmlFdRead;
buf->closecallback = xmlFdClose;
+
return(XML_ERR_OK);
}
+/**
+ * xmlInputDefaultOpen:
+ * @buf: input buffer to be filled
+ * @filename: filename or URI
+ *
+ * Returns an xmlParserErrors code.
+ */
+static int
+xmlInputDefaultOpen(xmlParserInputBufferPtr buf, const char *filename) {
+ int ret;
+ int fd;
+
+#ifdef LIBXML_FTP_ENABLED
+ if (xmlIOFTPMatch(filename)) {
+ buf->context = xmlIOFTPOpen(filename);
+
+ if (buf->context != NULL) {
+ buf->readcallback = xmlIOFTPRead;
+ buf->closecallback = xmlIOFTPClose;
+ return(XML_ERR_OK);
+ }
+ }
+#endif /* LIBXML_FTP_ENABLED */
+
+#ifdef LIBXML_HTTP_ENABLED
+ if (xmlIOHTTPMatch(filename)) {
+ buf->context = xmlIOHTTPOpen(filename);
+
+ if (buf->context != NULL) {
+ buf->readcallback = xmlIOHTTPRead;
+ buf->closecallback = xmlIOHTTPClose;
+ return(XML_ERR_OK);
+ }
+ }
+#endif /* LIBXML_HTTP_ENABLED */
+
+ if (!xmlFileMatch(filename))
+ return(XML_IO_ENOENT);
+
+ ret = xmlFdOpen(filename, 0, &fd);
+ if (ret != XML_ERR_OK)
+ return(ret);
+
+ ret = xmlInputFromFd(buf, fd, /* unzip */ 1);
+
+ close(fd);
+
+ return(ret);
+}
+
#ifdef LIBXML_OUTPUT_ENABLED
/**
* xmlOutputDefaultOpen:
diff --git a/xmllint.c b/xmllint.c
index 3a7a8a002..c62734776 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -95,6 +95,9 @@
#define STDIN_FILENO 0
#endif
+/* Internal parser option */
+#define XML_PARSE_UNZIP (1 << 24)
+
typedef enum {
XMLLINT_RETURN_OK = 0, /* No error */
XMLLINT_ERR_UNCLASS = 1, /* Unclassified */
@@ -1648,7 +1651,8 @@ testSAX(const char *filename) {
xmlCtxtSetMaxAmplification(ctxt, maxAmpl);
if (strcmp(filename, "-") == 0)
- xmlCtxtReadFd(ctxt, STDIN_FILENO, "-", NULL, options);
+ xmlCtxtReadFd(ctxt, STDIN_FILENO, "-", NULL,
+ options | XML_PARSE_UNZIP);
else
xmlCtxtReadFile(ctxt, filename, NULL, options);
@@ -2333,7 +2337,8 @@ parseFile(const char *filename, xmlParserCtxtPtr rectxt) {
#endif
} else {
if (strcmp(filename, "-") == 0)
- doc = xmlCtxtReadFd(ctxt, STDIN_FILENO, "-", NULL, options);
+ doc = xmlCtxtReadFd(ctxt, STDIN_FILENO, "-", NULL,
+ options | XML_PARSE_UNZIP);
else
doc = xmlCtxtReadFile(ctxt, filename, NULL, options);
}
--
GitLab

3176
libxml2.changes Normal file

File diff suppressed because it is too large Load Diff

270
libxml2.spec Normal file
View File

@ -0,0 +1,270 @@
#
# spec file for package libxml2
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define base_name libxml2
%define libname libxml2-2
%define flavor @BUILD_FLAVOR@%nil
%if "%{flavor}" == "python"
%define dash -
%define buildpython 1
%endif
%{?sle15allpythons}
Name: libxml2%{?dash}%{flavor}
Version: 2.13.5
Release: 0
License: MIT
Summary: A Library to Manipulate XML Files
URL: https://gitlab.gnome.org/GNOME/libxml2
Source0: https://download.gnome.org/sources/%{name}/2.13/libxml2-%{version}.tar.xz
Source1: baselibs.conf
# W3C Conformance tests
Source2: https://www.w3.org/XML/Test/xmlts20080827.tar.gz
### -- Upstream patches range from 0 to 999 -- ###
# PATCH-FIX-UPSTREAM libxml2-python3-unicode-errors.patch bsc#1064286 mcepl@suse.com
# remove segfault after doc.freeDoc()
Patch0: libxml2-python3-unicode-errors.patch
# PATCH-FIX-UPSTREAM libxml2-python3-string-null-check.patch bsc#1065270 mgorse@suse.com
# https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/15
Patch1: libxml2-python3-string-null-check.patch
#
### -- openSUSE patches range from 1000 to 1999 -- ###
# PATCH-FIX-OPENSUSE
#Patch1000:
#
### -- SUSE patches starts from 2000 -- ###
## TODO -- Is libxml2-make-XPATH_MAX_NODESET_LENGTH-configurable.patch really
## SUSE-specific? If so, shouldn't it be applied only for SLE distributions?
# PATCH-FIX-SUSE bsc#1135123 Added a new configurable variable XPATH_DEFAULT_MAX_NODESET_LENGTH to avoid nodeset limit
Patch2000: libxml2-make-XPATH_MAX_NODESET_LENGTH-configurable.patch
# https://gitlab.gnome.org/nwellnhof/libxml2/-/commit/6208f86edd59e31a51a8d9b300d428504adb25a7
Patch2001: libxml2-support-compressed-input-from-stdin.patch
#
BuildRequires: fdupes
BuildRequires: pkgconfig
BuildRequires: readline-devel
BuildRequires: pkgconfig(liblzma)
BuildRequires: pkgconfig(zlib)
%if 0%{?buildpython}
BuildRequires: %{python_module devel}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: %{python_module xml}
BuildRequires: python-rpm-macros
BuildRequires: pkgconfig(libxml-2.0)
# TW: generate subpackages for every python3 flavor
%define python_subpackage_only 1
%python_subpackages
%endif
%description
The XML C library was initially developed for the GNOME project. It is
now used by many programs to load and save extensible data structures
or manipulate any kind of XML files.
%package -n %{libname}
Summary: A Library to Manipulate XML Files
%description -n %{libname}
The XML C library was initially developed for the GNOME project. It is
now used by many programs to load and save extensible data structures
or manipulate any kind of XML files.
This library implements a number of existing standards related to
markup languages, including the XML standard, name spaces in XML, XML
Base, RFC 2396, XPath, XPointer, HTML4, XInclude, SGML catalogs, and
XML catalogs. In most cases, libxml tries to implement the
specification in a rather strict way. To some extent, it provides
support for the following specifications, but does not claim to
implement them: DOM, FTP client, HTTP client, and SAX.
The library also supports RelaxNG. Support for W3C XML Schemas is in
progress.
%package tools
Summary: Tools using libxml
Provides: %{base_name} = %{version}-%{release}
# Use hardcoded version to avoid unwanted behavior in the future.
Obsoletes: %{base_name} < 2.9.13
%description tools
This package contains xmllint, a very useful tool proving libxml's power.
%package devel
Summary: Development files for libxml2, an XML manipulation library
Requires: %{base_name} = %{version}
Requires: %{base_name}-tools = %{version}
Requires: %{libname} = %{version}
Requires: glibc-devel
Requires: libxml2 = %{version}
Requires: readline-devel
Requires: xz-devel
Requires: pkgconfig(liblzma)
Requires: pkgconfig(zlib)
%description devel
The XML C library can load and save extensible data structures
or manipulate any kind of XML files.
This subpackage contains header files for developing
applications that want to make use of libxml.
%package doc
Summary: Documentation for libxml, an XML manipulation library
Requires: %{libname} = %{version}
BuildArch: noarch
%description doc
The XML C library was initially developed for the GNOME project. It is
now used by many programs to load and save extensible data structures
or manipulate any kind of XML files.
%package -n python-libxml2
Summary: Python Bindings for %{name}
Requires: %{libname} = %{version}
Requires: python-extras
Provides: %{base_name}-python = %{version}-%{release}
Provides: python-libxml2-python = %{version}-%{release}
# Use hardcoded version to avoid unwanted behavior in the future.
Obsoletes: %{base_name}-python < 2.9.13
Obsoletes: python-libxml2-python < 2.9.13
%description -n python-libxml2
This package contains a module that permits
applications written in the Python programming language to use the
interface supplied by the libxml2 library to manipulate XML files.
This library allows manipulation of XML files. It includes support for
reading, modifying, and writing XML and HTML files. There is DTD
support that includes parsing and validation even with complex DTDs,
either at parse time or later once the document has been modified.
%prep
%autosetup -p1 -n libxml2-%{version}
sed -i '1 s|/usr/bin/env python|/usr/bin/python3|' doc/apibuild.py
%build
%if ! 0%{?buildpython}
# TODO -- Document why are we using the -fno-strict-aliasing extra flag.
export CFLAGS="%{optflags} -fno-strict-aliasing"
%configure \
--disable-silent-rules \
--disable-static \
--docdir=%{_docdir}/%{base_name} \
--without-python \
--with-history \
--enable-ipv6 \
--with-sax1 \
--with-regexps \
--with-threads \
--with-reader \
--with-ftp \
--with-http \
--with-legacy
%make_build BASE_DIR="%{_docdir}" DOC_MODULE="%{base_name}"
%else
%configure --with-python=%{__python3}
pushd python
%if 0%{suse_version} > 1500
export PYTHONPATH="."
%pyproject_wheel
%else
%python_build
%endif
popd
%endif
%install
%if ! 0%{?buildpython}
%make_install BASE_DIR="%{_docdir}" DOC_MODULE="%{base_name}"
find %{buildroot} -type f -name "*.la" -delete -print
mkdir -p "%{buildroot}/%{_docdir}/%{base_name}"
cp -a NEWS README.md %{buildroot}%{_docdir}/%{base_name}/
ln -s libxml2/libxml %{buildroot}%{_includedir}/libxml
# Remove duplicated file Copyright as not found by fdupes
rm -fr %{buildroot}%{_docdir}/%{base_name}/Copyright
%fdupes %{buildroot}%{_datadir}
%else
pushd python
%if 0%{suse_version} > 1500
%pyproject_install
%else
%python_install
%endif
popd
chmod a-x python/tests/*.py
%python_expand %fdupes %{buildroot}%{$python_sitearch}
%endif
%if ! 0%{?buildpython}
%check
# qemu-arm can't keep up atm, disabling check for arm
%ifnarch %{arm}
tar xzvf %{SOURCE2} # add conformance tests where they are expected
%make_build check
rm -rf xmlconf/ # remove the conformance tests afterwards
%endif
%ldconfig_scriptlets -n %{libname}
%files -n %{libname}
%{_libdir}/lib*.so.*
%license Copyright
%doc %dir %{_docdir}/%{base_name}
%doc %{_docdir}/%{base_name}/[ANRCT]*
# the -n %%base_name tag is necessary so that python_subpackages does not interfere
%files -n %{base_name}-tools
%{_bindir}/xmllint
%{_bindir}/xmlcatalog
%{_mandir}/man1/xmllint.1%{?ext_man}
%{_mandir}/man1/xmlcatalog.1%{?ext_man}
%files -n %{base_name}-devel
%{_bindir}/xml2-config
%dir %{_datadir}/aclocal
%{_datadir}/aclocal/libxml.m4
%{_includedir}/libxml
%{_includedir}/libxml2
%{_libdir}/lib*.so
%{_libdir}/pkgconfig/*.pc
%{_libdir}/cmake
%{_mandir}/man1/xml2-config.1%{?ext_man}
%files -n %{base_name}-doc
%{_datadir}/gtk-doc/html/*
%doc %{_docdir}/%{base_name}/*.html
# owning these directories prevents gtk-doc <-> libxml2 build loop:
%dir %{_datadir}/gtk-doc
%dir %{_datadir}/gtk-doc/html
%else
%files %{python_files libxml2}
%doc python/libxml2class.txt
%doc doc/*.py
%doc python/README
%pycache_only %{python_sitearch}/__pycache__/*libxml2*
%{python_sitearch}/*libxml2*
%endif
%changelog

BIN
xmlts20080827.tar.gz Normal file

Binary file not shown.