summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Rostovtsev <tetromino@gentoo.org>2015-04-19 16:09:17 +0000
committerAlexandre Rostovtsev <tetromino@gentoo.org>2015-04-19 16:09:17 +0000
commit95843da8697b037c113cea1c1c54f66f94a371e2 (patch)
treea670eeb9bcf5793772ef374ab958340722b5eb61 /dev-libs/libxml2
parentppc64 stable wrt 524308 (diff)
downloadgentoo-2-95843da8697b037c113cea1c1c54f66f94a371e2.tar.gz
gentoo-2-95843da8697b037c113cea1c1c54f66f94a371e2.tar.bz2
gentoo-2-95843da8697b037c113cea1c1c54f66f94a371e2.zip
Add important patches from upstream, including a fix for a DoS vulnerability (CVE-2015-1819, bug #546720, thanks to Agostino Sarubbo).
(Portage version: 2.2.18/cvs/Linux x86_64, signed Manifest commit with key 0x18E5B6F2D8D5EC8D)
Diffstat (limited to 'dev-libs/libxml2')
-rw-r--r--dev-libs/libxml2/ChangeLog12
-rw-r--r--dev-libs/libxml2/files/libxml2-2.9.2-constant-memory.patch176
-rw-r--r--dev-libs/libxml2/files/libxml2-2.9.2-missing-entities.patch31
-rw-r--r--dev-libs/libxml2/files/libxml2-2.9.2-threads-declarations.patch48
-rw-r--r--dev-libs/libxml2/files/libxml2-2.9.2-timsort.patch128
-rw-r--r--dev-libs/libxml2/libxml2-2.9.2-r1.ebuild212
6 files changed, 606 insertions, 1 deletions
diff --git a/dev-libs/libxml2/ChangeLog b/dev-libs/libxml2/ChangeLog
index d7f3b1e65058..188d9764a480 100644
--- a/dev-libs/libxml2/ChangeLog
+++ b/dev-libs/libxml2/ChangeLog
@@ -1,6 +1,16 @@
# ChangeLog for dev-libs/libxml2
# Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/dev-libs/libxml2/ChangeLog,v 1.443 2015/04/08 17:51:56 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/dev-libs/libxml2/ChangeLog,v 1.444 2015/04/19 16:09:17 tetromino Exp $
+
+*libxml2-2.9.2-r1 (19 Apr 2015)
+
+ 19 Apr 2015; Alexandre Rostovtsev <tetromino@gentoo.org>
+ +libxml2-2.9.2-r1.ebuild, +files/libxml2-2.9.2-constant-memory.patch,
+ +files/libxml2-2.9.2-missing-entities.patch,
+ +files/libxml2-2.9.2-threads-declarations.patch,
+ +files/libxml2-2.9.2-timsort.patch:
+ Add important patches from upstream, including a fix for a DoS vulnerability
+ (CVE-2015-1819, bug #546720, thanks to Agostino Sarubbo).
08 Apr 2015; Michał Górny <mgorny@gentoo.org> libxml2-2.9.2.ebuild:
Drop old Python implementations
diff --git a/dev-libs/libxml2/files/libxml2-2.9.2-constant-memory.patch b/dev-libs/libxml2/files/libxml2-2.9.2-constant-memory.patch
new file mode 100644
index 000000000000..dc944b6353ea
--- /dev/null
+++ b/dev-libs/libxml2/files/libxml2-2.9.2-constant-memory.patch
@@ -0,0 +1,176 @@
+From 213f1fe0d76d30eaed6e5853057defc43e6df2c9 Mon Sep 17 00:00:00 2001
+From: Daniel Veillard <veillard@redhat.com>
+Date: Tue, 14 Apr 2015 17:41:48 +0800
+Subject: [PATCH] CVE-2015-1819 Enforce the reader to run in constant memory
+
+One of the operation on the reader could resolve entities
+leading to the classic expansion issue. Make sure the
+buffer used for xmlreader operation is bounded.
+Introduce a new allocation type for the buffers for this effect.
+---
+ buf.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
+ include/libxml/tree.h | 3 ++-
+ xmlreader.c | 20 +++++++++++++++++++-
+ 3 files changed, 63 insertions(+), 3 deletions(-)
+
+diff --git a/buf.c b/buf.c
+index 6efc7b6..07922ff 100644
+--- a/buf.c
++++ b/buf.c
+@@ -27,6 +27,7 @@
+ #include <libxml/tree.h>
+ #include <libxml/globals.h>
+ #include <libxml/tree.h>
++#include <libxml/parserInternals.h> /* for XML_MAX_TEXT_LENGTH */
+ #include "buf.h"
+
+ #define WITH_BUFFER_COMPAT
+@@ -299,7 +300,8 @@ xmlBufSetAllocationScheme(xmlBufPtr buf,
+ if ((scheme == XML_BUFFER_ALLOC_DOUBLEIT) ||
+ (scheme == XML_BUFFER_ALLOC_EXACT) ||
+ (scheme == XML_BUFFER_ALLOC_HYBRID) ||
+- (scheme == XML_BUFFER_ALLOC_IMMUTABLE)) {
++ (scheme == XML_BUFFER_ALLOC_IMMUTABLE) ||
++ (scheme == XML_BUFFER_ALLOC_BOUNDED)) {
+ buf->alloc = scheme;
+ if (buf->buffer)
+ buf->buffer->alloc = scheme;
+@@ -458,6 +460,18 @@ xmlBufGrowInternal(xmlBufPtr buf, size_t len) {
+ size = buf->use + len + 100;
+ #endif
+
++ if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
++ /*
++ * Used to provide parsing limits
++ */
++ if ((buf->use + len >= XML_MAX_TEXT_LENGTH) ||
++ (buf->size >= XML_MAX_TEXT_LENGTH)) {
++ xmlBufMemoryError(buf, "buffer error: text too long\n");
++ return(0);
++ }
++ if (size >= XML_MAX_TEXT_LENGTH)
++ size = XML_MAX_TEXT_LENGTH;
++ }
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
+ size_t start_buf = buf->content - buf->contentIO;
+
+@@ -739,6 +753,15 @@ xmlBufResize(xmlBufPtr buf, size_t size)
+ CHECK_COMPAT(buf)
+
+ if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0);
++ if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
++ /*
++ * Used to provide parsing limits
++ */
++ if (size >= XML_MAX_TEXT_LENGTH) {
++ xmlBufMemoryError(buf, "buffer error: text too long\n");
++ return(0);
++ }
++ }
+
+ /* Don't resize if we don't have to */
+ if (size < buf->size)
+@@ -867,6 +890,15 @@ xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len) {
+
+ needSize = buf->use + len + 2;
+ if (needSize > buf->size){
++ if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
++ /*
++ * Used to provide parsing limits
++ */
++ if (needSize >= XML_MAX_TEXT_LENGTH) {
++ xmlBufMemoryError(buf, "buffer error: text too long\n");
++ return(-1);
++ }
++ }
+ if (!xmlBufResize(buf, needSize)){
+ xmlBufMemoryError(buf, "growing buffer");
+ return XML_ERR_NO_MEMORY;
+@@ -938,6 +970,15 @@ xmlBufAddHead(xmlBufPtr buf, const xmlChar *str, int len) {
+ }
+ needSize = buf->use + len + 2;
+ if (needSize > buf->size){
++ if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
++ /*
++ * Used to provide parsing limits
++ */
++ if (needSize >= XML_MAX_TEXT_LENGTH) {
++ xmlBufMemoryError(buf, "buffer error: text too long\n");
++ return(-1);
++ }
++ }
+ if (!xmlBufResize(buf, needSize)){
+ xmlBufMemoryError(buf, "growing buffer");
+ return XML_ERR_NO_MEMORY;
+diff --git a/include/libxml/tree.h b/include/libxml/tree.h
+index 2f90717..4a9b3bc 100644
+--- a/include/libxml/tree.h
++++ b/include/libxml/tree.h
+@@ -76,7 +76,8 @@ typedef enum {
+ XML_BUFFER_ALLOC_EXACT, /* grow only to the minimal size */
+ XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer */
+ XML_BUFFER_ALLOC_IO, /* special allocation scheme used for I/O */
+- XML_BUFFER_ALLOC_HYBRID /* exact up to a threshold, and doubleit thereafter */
++ XML_BUFFER_ALLOC_HYBRID, /* exact up to a threshold, and doubleit thereafter */
++ XML_BUFFER_ALLOC_BOUNDED /* limit the upper size of the buffer */
+ } xmlBufferAllocationScheme;
+
+ /**
+diff --git a/xmlreader.c b/xmlreader.c
+index f19e123..471e7e2 100644
+--- a/xmlreader.c
++++ b/xmlreader.c
+@@ -2091,6 +2091,9 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
+ "xmlNewTextReader : malloc failed\n");
+ return(NULL);
+ }
++ /* no operation on a reader should require a huge buffer */
++ xmlBufSetAllocationScheme(ret->buffer,
++ XML_BUFFER_ALLOC_BOUNDED);
+ ret->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
+ if (ret->sax == NULL) {
+ xmlBufFree(ret->buffer);
+@@ -3616,6 +3619,7 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) {
+ return(((xmlNsPtr) node)->href);
+ case XML_ATTRIBUTE_NODE:{
+ xmlAttrPtr attr = (xmlAttrPtr) node;
++ const xmlChar *ret;
+
+ if ((attr->children != NULL) &&
+ (attr->children->type == XML_TEXT_NODE) &&
+@@ -3629,10 +3633,21 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) {
+ "xmlTextReaderSetup : malloc failed\n");
+ return (NULL);
+ }
++ xmlBufSetAllocationScheme(reader->buffer,
++ XML_BUFFER_ALLOC_BOUNDED);
+ } else
+ xmlBufEmpty(reader->buffer);
+ xmlBufGetNodeContent(reader->buffer, node);
+- return(xmlBufContent(reader->buffer));
++ ret = xmlBufContent(reader->buffer);
++ if (ret == NULL) {
++ /* error on the buffer best to reallocate */
++ xmlBufFree(reader->buffer);
++ reader->buffer = xmlBufCreateSize(100);
++ xmlBufSetAllocationScheme(reader->buffer,
++ XML_BUFFER_ALLOC_BOUNDED);
++ ret = BAD_CAST "";
++ }
++ return(ret);
+ }
+ break;
+ }
+@@ -5131,6 +5146,9 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
+ "xmlTextReaderSetup : malloc failed\n");
+ return (-1);
+ }
++ /* no operation on a reader should require a huge buffer */
++ xmlBufSetAllocationScheme(reader->buffer,
++ XML_BUFFER_ALLOC_BOUNDED);
+ if (reader->sax == NULL)
+ reader->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
+ if (reader->sax == NULL) {
+--
+2.3.5
+
diff --git a/dev-libs/libxml2/files/libxml2-2.9.2-missing-entities.patch b/dev-libs/libxml2/files/libxml2-2.9.2-missing-entities.patch
new file mode 100644
index 000000000000..7a10e206ad82
--- /dev/null
+++ b/dev-libs/libxml2/files/libxml2-2.9.2-missing-entities.patch
@@ -0,0 +1,31 @@
+From 72a46a519ce7326d9a00f0b6a7f2a8e958cd1675 Mon Sep 17 00:00:00 2001
+From: Daniel Veillard <veillard@redhat.com>
+Date: Thu, 23 Oct 2014 11:35:36 +0800
+Subject: [PATCH] Fix missing entities after CVE-2014-3660 fix
+
+For https://bugzilla.gnome.org/show_bug.cgi?id=738805
+
+The fix for CVE-2014-3660 introduced a regression in some case
+where entity substitution is required and the entity is used
+first in anotther entity referenced from an attribute value
+---
+ parser.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/parser.c b/parser.c
+index 67c9dfd..a8d1b67 100644
+--- a/parser.c
++++ b/parser.c
+@@ -7235,7 +7235,8 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
+ * far more secure as the parser will only process data coming from
+ * the document entity by default.
+ */
+- if ((ent->checked == 0) &&
++ if (((ent->checked == 0) ||
++ ((ent->children == NULL) && (ctxt->options & XML_PARSE_NOENT))) &&
+ ((ent->etype != XML_EXTERNAL_GENERAL_PARSED_ENTITY) ||
+ (ctxt->options & (XML_PARSE_NOENT | XML_PARSE_DTDVALID)))) {
+ unsigned long oldnbent = ctxt->nbentities;
+--
+2.3.5
+
diff --git a/dev-libs/libxml2/files/libxml2-2.9.2-threads-declarations.patch b/dev-libs/libxml2/files/libxml2-2.9.2-threads-declarations.patch
new file mode 100644
index 000000000000..1236f622d6a4
--- /dev/null
+++ b/dev-libs/libxml2/files/libxml2-2.9.2-threads-declarations.patch
@@ -0,0 +1,48 @@
+From fff8a6b87e05200a0ad0af6f86c2e859c7de9172 Mon Sep 17 00:00:00 2001
+From: Michael Heimpold <mhei@heimpold.de>
+Date: Mon, 22 Dec 2014 11:12:12 +0800
+Subject: [PATCH] threads: use forward declarations only for glibc
+
+Fixes bug #704908
+
+The declarations of pthread functions, used to generate weak references
+to them, fail to suppress macros. Thus, if any pthread function has
+been provided as a macro, compiling threads.c will fail.
+This breaks on musl libc, which defines pthread_equal as a macro (in
+addition to providing the function, as required).
+
+Prevent the declarations for e.g. musl libc by refining the condition.
+
+The idea for this solution was borrowed from the alpine linux guys, see
+http://git.alpinelinux.org/cgit/aports/tree/main/libxml2/libxml2-pthread.patch
+
+Signed-off-by: Michael Heimpold <mhei@heimpold.de>
+---
+ threads.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/threads.c b/threads.c
+index 8921204..78006a2 100644
+--- a/threads.c
++++ b/threads.c
+@@ -47,7 +47,7 @@
+ #ifdef HAVE_PTHREAD_H
+
+ static int libxml_is_threaded = -1;
+-#ifdef __GNUC__
++#if defined(__GNUC__) && defined(__GLIBC__)
+ #ifdef linux
+ #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3)
+ extern int pthread_once (pthread_once_t *__once_control,
+@@ -89,7 +89,7 @@ extern int pthread_cond_signal ()
+ __attribute((weak));
+ #endif
+ #endif /* linux */
+-#endif /* __GNUC__ */
++#endif /* defined(__GNUC__) && defined(__GLIBC__) */
+ #endif /* HAVE_PTHREAD_H */
+
+ /*
+--
+2.3.5
+
diff --git a/dev-libs/libxml2/files/libxml2-2.9.2-timsort.patch b/dev-libs/libxml2/files/libxml2-2.9.2-timsort.patch
new file mode 100644
index 000000000000..c179d47ef2db
--- /dev/null
+++ b/dev-libs/libxml2/files/libxml2-2.9.2-timsort.patch
@@ -0,0 +1,128 @@
+From 9b987f8c98763ee569bde90b5268b43474ca106c Mon Sep 17 00:00:00 2001
+From: Christopher Swenson <chris@caswenson.com>
+Date: Fri, 27 Feb 2015 14:55:49 +0800
+Subject: [PATCH] Fix timsort invariant loop re: Envisage article
+
+See http://envisage-project.eu/proving-android-java-and-python-sorting-algorithm-is-broken-and-how-to-fix-it/
+
+We use a "runLen" array of size 128, so it should be nearly impossible
+to have our implementation overflow.
+
+But in any case, the fix is relatively simple -- checking two extra
+conditions in the invariant calculation.
+
+I also took this opportunity to remove some redundancy in the
+left/right merge logic in the invariant loop.
+---
+ timsort.h | 74 +++++++++++++++++++++++++++++++++------------------------------
+ 1 file changed, 39 insertions(+), 35 deletions(-)
+
+diff --git a/timsort.h b/timsort.h
+index efa3aab..795f272 100644
+--- a/timsort.h
++++ b/timsort.h
+@@ -392,62 +392,66 @@ static void TIM_SORT_MERGE(SORT_TYPE *dst, const TIM_SORT_RUN_T *stack, const in
+
+ static int TIM_SORT_COLLAPSE(SORT_TYPE *dst, TIM_SORT_RUN_T *stack, int stack_curr, TEMP_STORAGE_T *store, const size_t size)
+ {
+- while (1)
+- {
+- int64_t A, B, C;
++ while (1) {
++ int64_t A, B, C, D;
++ int ABC, BCD, BD, CD;
++
+ /* if the stack only has one thing on it, we are done with the collapse */
+- if (stack_curr <= 1) break;
++ if (stack_curr <= 1) {
++ break;
++ }
++
+ /* if this is the last merge, just do it */
+- if ((stack_curr == 2) &&
+- (stack[0].length + stack[1].length == (int64_t) size))
+- {
++ if ((stack_curr == 2) && (stack[0].length + stack[1].length == size)) {
+ TIM_SORT_MERGE(dst, stack, stack_curr, store);
+ stack[0].length += stack[1].length;
+ stack_curr--;
+ break;
+ }
+ /* check if the invariant is off for a stack of 2 elements */
+- else if ((stack_curr == 2) && (stack[0].length <= stack[1].length))
+- {
++ else if ((stack_curr == 2) && (stack[0].length <= stack[1].length)) {
+ TIM_SORT_MERGE(dst, stack, stack_curr, store);
+ stack[0].length += stack[1].length;
+ stack_curr--;
+ break;
+- }
+- else if (stack_curr == 2)
++ } else if (stack_curr == 2) {
+ break;
++ }
+
+- A = stack[stack_curr - 3].length;
+- B = stack[stack_curr - 2].length;
+- C = stack[stack_curr - 1].length;
++ B = stack[stack_curr - 3].length;
++ C = stack[stack_curr - 2].length;
++ D = stack[stack_curr - 1].length;
+
+- /* check first invariant */
+- if (A <= B + C)
+- {
+- if (A < C)
+- {
+- TIM_SORT_MERGE(dst, stack, stack_curr - 1, store);
+- stack[stack_curr - 3].length += stack[stack_curr - 2].length;
+- stack[stack_curr - 2] = stack[stack_curr - 1];
+- stack_curr--;
+- }
+- else
+- {
+- TIM_SORT_MERGE(dst, stack, stack_curr, store);
+- stack[stack_curr - 2].length += stack[stack_curr - 1].length;
+- stack_curr--;
+- }
++ if (stack_curr >= 4) {
++ A = stack[stack_curr - 4].length;
++ ABC = (A <= B + C);
++ } else {
++ ABC = 0;
+ }
+- /* check second invariant */
+- else if (B <= C)
+- {
++
++ BCD = (B <= C + D) || ABC;
++ CD = (C <= D);
++ BD = (B < D);
++
++ /* Both invariants are good */
++ if (!BCD && !CD) {
++ break;
++ }
++
++ /* left merge */
++ if (BCD && !CD) {
++ TIM_SORT_MERGE(dst, stack, stack_curr - 1, store);
++ stack[stack_curr - 3].length += stack[stack_curr - 2].length;
++ stack[stack_curr - 2] = stack[stack_curr - 1];
++ stack_curr--;
++ } else {
++ /* right merge */
+ TIM_SORT_MERGE(dst, stack, stack_curr, store);
+ stack[stack_curr - 2].length += stack[stack_curr - 1].length;
+ stack_curr--;
+ }
+- else
+- break;
+ }
++
+ return stack_curr;
+ }
+
+--
+2.3.5
+
diff --git a/dev-libs/libxml2/libxml2-2.9.2-r1.ebuild b/dev-libs/libxml2/libxml2-2.9.2-r1.ebuild
new file mode 100644
index 000000000000..9c6add2a4dc2
--- /dev/null
+++ b/dev-libs/libxml2/libxml2-2.9.2-r1.ebuild
@@ -0,0 +1,212 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-libs/libxml2/libxml2-2.9.2-r1.ebuild,v 1.1 2015/04/19 16:09:17 tetromino Exp $
+
+EAPI="5"
+PYTHON_COMPAT=( python{2_7,3_3,3_4} )
+PYTHON_REQ_USE="xml"
+
+inherit libtool flag-o-matic eutils python-r1 autotools prefix multilib-minimal
+
+DESCRIPTION="Version 2 of the library to manipulate XML files"
+HOMEPAGE="http://www.xmlsoft.org/"
+
+LICENSE="MIT"
+SLOT="2"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~arm-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris ~x86-winnt"
+IUSE="debug examples icu ipv6 lzma python readline static-libs test"
+
+XSTS_HOME="http://www.w3.org/XML/2004/xml-schema-test-suite"
+XSTS_NAME_1="xmlschema2002-01-16"
+XSTS_NAME_2="xmlschema2004-01-14"
+XSTS_TARBALL_1="xsts-2002-01-16.tar.gz"
+XSTS_TARBALL_2="xsts-2004-01-14.tar.gz"
+XMLCONF_TARBALL="xmlts20080827.tar.gz"
+
+SRC_URI="ftp://xmlsoft.org/${PN}/${PN}-${PV/_rc/-rc}.tar.gz
+ test? (
+ ${XSTS_HOME}/${XSTS_NAME_1}/${XSTS_TARBALL_1}
+ ${XSTS_HOME}/${XSTS_NAME_2}/${XSTS_TARBALL_2}
+ http://www.w3.org/XML/Test/${XMLCONF_TARBALL} )"
+
+COMMON_DEPEND="
+ >=sys-libs/zlib-1.2.8-r1:=[${MULTILIB_USEDEP}]
+ icu? ( >=dev-libs/icu-51.2-r1:=[${MULTILIB_USEDEP}] )
+ lzma? ( >=app-arch/xz-utils-5.0.5-r1:=[${MULTILIB_USEDEP}] )
+ python? ( ${PYTHON_DEPS} )
+ readline? ( sys-libs/readline:= )
+"
+RDEPEND="${COMMON_DEPEND}
+ abi_x86_32? ( !<=app-emulation/emul-linux-x86-baselibs-20131008-r6
+ !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)] )
+"
+DEPEND="${COMMON_DEPEND}
+ dev-util/gtk-doc-am
+ virtual/pkgconfig
+ hppa? ( >=sys-devel/binutils-2.15.92.0.2 )
+"
+
+S="${WORKDIR}/${PN}-${PV%_rc*}"
+
+MULTILIB_CHOST_TOOLS=(
+ /usr/bin/xml2-config
+)
+
+src_unpack() {
+ # ${A} isn't used to avoid unpacking of test tarballs into $WORKDIR,
+ # as they are needed as tarballs in ${S}/xstc instead and not unpacked
+ unpack ${P/_rc/-rc}.tar.gz
+ cd "${S}"
+
+ if use test; then
+ cp "${DISTDIR}/${XSTS_TARBALL_1}" \
+ "${DISTDIR}/${XSTS_TARBALL_2}" \
+ "${S}"/xstc/ \
+ || die "Failed to install test tarballs"
+ unpack ${XMLCONF_TARBALL}
+ fi
+}
+
+src_prepare() {
+ DOCS=( AUTHORS ChangeLog NEWS README* TODO* )
+
+ # Patches needed for prefix support
+ epatch "${FILESDIR}"/${PN}-2.7.1-catalog_path.patch
+ epatch "${FILESDIR}"/${PN}-2.8.0_rc1-winnt.patch
+
+ eprefixify catalog.c xmlcatalog.c runtest.c xmllint.c
+
+# epunt_cxx # if we don't eautoreconf
+
+ # Important patches from master
+ epatch \
+ "${FILESDIR}/${PN}-2.9.2-revert-missing-initialization.patch" \
+ "${FILESDIR}/${PN}-2.9.2-missing-entities.patch" \
+ "${FILESDIR}/${PN}-2.9.2-threads-declarations.patch" \
+ "${FILESDIR}/${PN}-2.9.2-timsort.patch" \
+ "${FILESDIR}/${PN}-2.9.2-constant-memory.patch"
+
+ # Please do not remove, as else we get references to PORTAGE_TMPDIR
+ # in /usr/lib/python?.?/site-packages/libxml2mod.la among things.
+ # We now need to run eautoreconf at the end to prevent maintainer mode.
+# elibtoolize
+
+ # Use pkgconfig to find icu to properly support multilib, upstream bug #738751
+ epatch "${FILESDIR}/${PN}-2.9.2-icu-pkgconfig.patch"
+
+ eautoreconf
+}
+
+multilib_src_configure() {
+ # filter seemingly problematic CFLAGS (#26320)
+ filter-flags -fprefetch-loop-arrays -funroll-loops
+
+ # USE zlib support breaks gnome2
+ # (libgnomeprint for instance fails to compile with
+ # fresh install, and existing) - <azarah@gentoo.org> (22 Dec 2002).
+
+ # The meaning of the 'debug' USE flag does not apply to the --with-debug
+ # switch (enabling the libxml2 debug module). See bug #100898.
+
+ # --with-mem-debug causes unusual segmentation faults (bug #105120).
+
+ libxml2_configure() {
+ ECONF_SOURCE="${S}" econf \
+ --with-html-subdir=${PF}/html \
+ --docdir="${EPREFIX}/usr/share/doc/${PF}" \
+ $(use_with debug run-debug) \
+ $(use_with icu) \
+ $(use_with lzma) \
+ $(use_enable ipv6) \
+ $(use_enable static-libs static) \
+ $(multilib_native_use_with readline) \
+ $(multilib_native_use_with readline history) \
+ "$@"
+ }
+
+ libxml2_py_configure() {
+ mkdir -p "${BUILD_DIR}" || die # ensure python build dirs exist
+ run_in_build_dir libxml2_configure "--with-python=${PYTHON}" # odd build system
+ }
+
+ libxml2_configure --without-python # build python bindings separately
+
+ if multilib_is_native_abi && use python; then
+ python_foreach_impl libxml2_py_configure
+ fi
+}
+
+multilib_src_compile() {
+ default
+ if multilib_is_native_abi && use python; then
+ local native_builddir=${BUILD_DIR}
+ python_foreach_impl libxml2_py_emake top_builddir="${native_builddir}" all
+ fi
+}
+
+multilib_src_test() {
+ default
+ multilib_is_native_abi && use python && python_foreach_impl libxml2_py_emake test
+}
+
+multilib_src_install() {
+ emake DESTDIR="${D}" \
+ EXAMPLES_DIR="${EPREFIX}"/usr/share/doc/${PF}/examples install
+
+ if multilib_is_native_abi && use python; then
+ python_foreach_impl libxml2_py_emake DESTDIR="${D}" install
+ python_foreach_impl python_optimize
+ fi
+}
+
+multilib_src_install_all() {
+ # on windows, xmllint is installed by interix libxml2 in parent prefix.
+ # this is the version to use. the native winnt version does not support
+ # symlinks, which makes repoman fail if the portage tree is linked in
+ # from another location (which is my default). -- mduft
+ if [[ ${CHOST} == *-winnt* ]]; then
+ rm -rf "${ED}"/usr/bin/xmllint
+ rm -rf "${ED}"/usr/bin/xmlcatalog
+ fi
+
+ rm -rf "${ED}"/usr/share/doc/${P}
+ einstalldocs
+
+ if ! use python; then
+ rm -rf "${ED}"/usr/share/doc/${PF}/python
+ rm -rf "${ED}"/usr/share/doc/${PN}-python-${PV}
+ fi
+
+ if ! use examples; then
+ rm -rf "${ED}/usr/share/doc/${PF}/examples"
+ rm -rf "${ED}/usr/share/doc/${PF}/python/examples"
+ fi
+
+ prune_libtool_files --modules
+}
+
+pkg_postinst() {
+ # We don't want to do the xmlcatalog during stage1, as xmlcatalog will not
+ # be in / and stage1 builds to ROOT=/tmp/stage1root. This fixes bug #208887.
+ if [[ "${ROOT}" != "/" ]]; then
+ elog "Skipping XML catalog creation for stage building (bug #208887)."
+ else
+ # need an XML catalog, so no-one writes to a non-existent one
+ CATALOG="${EROOT}etc/xml/catalog"
+
+ # we dont want to clobber an existing catalog though,
+ # only ensure that one is there
+ # <obz@gentoo.org>
+ if [[ ! -e ${CATALOG} ]]; then
+ [[ -d "${EROOT}etc/xml" ]] || mkdir -p "${EROOT}etc/xml"
+ "${EPREFIX}"/usr/bin/xmlcatalog --create > "${CATALOG}"
+ einfo "Created XML catalog in ${CATALOG}"
+ fi
+ fi
+}
+
+libxml2_py_emake() {
+ pushd "${BUILD_DIR}/python" > /dev/null || die
+ emake "$@"
+ popd > /dev/null
+}