Gentoo Archives: gentoo-commits

From: Mart Raudsepp <leio@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/libxml2/, dev-libs/libxml2/files/
Date: Wed, 01 Jan 2020 16:28:40
Message-Id: 1577896099.3d060cd62d99a7b6f26b30a695701b4ccafcccea.leio@gentoo
1 commit: 3d060cd62d99a7b6f26b30a695701b4ccafcccea
2 Author: Mart Raudsepp <leio <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jan 1 16:27:19 2020 +0000
4 Commit: Mart Raudsepp <leio <AT> gentoo <DOT> org>
5 CommitDate: Wed Jan 1 16:28:19 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3d060cd6
7
8 dev-libs/libxml2: workaround py3 issues for itstool
9
10 Bug: https://bugs.gentoo.org/701020
11 Package-Manager: Portage-2.3.79, Repoman-2.3.12
12 Signed-off-by: Mart Raudsepp <leio <AT> gentoo.org>
13
14 .../files/2.9.9-python3-unicode-errors.patch | 34 +++
15 dev-libs/libxml2/libxml2-2.9.9-r3.ebuild | 227 +++++++++++++++++++++
16 2 files changed, 261 insertions(+)
17
18 diff --git a/dev-libs/libxml2/files/2.9.9-python3-unicode-errors.patch b/dev-libs/libxml2/files/2.9.9-python3-unicode-errors.patch
19 new file mode 100644
20 index 00000000000..e87dcdedf88
21 --- /dev/null
22 +++ b/dev-libs/libxml2/files/2.9.9-python3-unicode-errors.patch
23 @@ -0,0 +1,34 @@
24 +Index: libxml2-2.9.5/python/libxml.c
25 +===================================================================
26 +--- libxml2-2.9.5.orig/python/libxml.c
27 ++++ libxml2-2.9.5/python/libxml.c
28 +@@ -1620,6 +1620,7 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
29 + PyObject *message;
30 + PyObject *result;
31 + char str[1000];
32 ++ unsigned char *ptr = (unsigned char *)str;
33 +
34 + #ifdef DEBUG_ERROR
35 + printf("libxml_xmlErrorFuncHandler(%p, %s, ...) called\n", ctx, msg);
36 +@@ -1636,12 +1637,20 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
37 + str[999] = 0;
38 + va_end(ap);
39 +
40 ++#if PY_MAJOR_VERSION >= 3
41 ++ /* Ensure the error string doesn't start at UTF8 continuation. */
42 ++ while (*ptr && (*ptr & 0xc0) == 0x80)
43 ++ ptr++;
44 ++#endif
45 ++
46 + list = PyTuple_New(2);
47 + PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt);
48 + Py_XINCREF(libxml_xmlPythonErrorFuncCtxt);
49 +- message = libxml_charPtrConstWrap(str);
50 ++ message = libxml_charPtrConstWrap(ptr);
51 + PyTuple_SetItem(list, 1, message);
52 + result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list);
53 ++ /* Forget any errors caused in the error handler. */
54 ++ PyErr_Clear();
55 + Py_XDECREF(list);
56 + Py_XDECREF(result);
57 + }
58
59 diff --git a/dev-libs/libxml2/libxml2-2.9.9-r3.ebuild b/dev-libs/libxml2/libxml2-2.9.9-r3.ebuild
60 new file mode 100644
61 index 00000000000..5f7f29a15de
62 --- /dev/null
63 +++ b/dev-libs/libxml2/libxml2-2.9.9-r3.ebuild
64 @@ -0,0 +1,227 @@
65 +# Copyright 1999-2020 Gentoo Authors
66 +# Distributed under the terms of the GNU General Public License v2
67 +
68 +EAPI=6
69 +
70 +PYTHON_COMPAT=( python2_7 python3_{5,6,7,8} )
71 +PYTHON_REQ_USE="xml"
72 +
73 +inherit libtool flag-o-matic python-r1 autotools prefix multilib-minimal
74 +
75 +DESCRIPTION="XML C parser and toolkit"
76 +HOMEPAGE="http://www.xmlsoft.org/"
77 +
78 +LICENSE="MIT"
79 +SLOT="2"
80 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86 ~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
81 +IUSE="debug examples icu ipv6 lzma python readline static-libs test"
82 +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
83 +RESTRICT="!test? ( test )"
84 +
85 +XSTS_HOME="http://www.w3.org/XML/2004/xml-schema-test-suite"
86 +XSTS_NAME_1="xmlschema2002-01-16"
87 +XSTS_NAME_2="xmlschema2004-01-14"
88 +XSTS_TARBALL_1="xsts-2002-01-16.tar.gz"
89 +XSTS_TARBALL_2="xsts-2004-01-14.tar.gz"
90 +XMLCONF_TARBALL="xmlts20080827.tar.gz"
91 +
92 +SRC_URI="ftp://xmlsoft.org/${PN}/${PN}-${PV/_rc/-rc}.tar.gz
93 + https://dev.gentoo.org/~leio/distfiles/${P}-patchset.tar.xz
94 + test? (
95 + ${XSTS_HOME}/${XSTS_NAME_1}/${XSTS_TARBALL_1}
96 + ${XSTS_HOME}/${XSTS_NAME_2}/${XSTS_TARBALL_2}
97 + http://www.w3.org/XML/Test/${XMLCONF_TARBALL} )"
98 +
99 +RDEPEND="
100 + >=sys-libs/zlib-1.2.8-r1:=[${MULTILIB_USEDEP}]
101 + icu? ( >=dev-libs/icu-51.2-r1:=[${MULTILIB_USEDEP}] )
102 + lzma? ( >=app-arch/xz-utils-5.0.5-r1:=[${MULTILIB_USEDEP}] )
103 + python? ( ${PYTHON_DEPS} )
104 + readline? ( sys-libs/readline:= )
105 +"
106 +DEPEND="${RDEPEND}
107 + dev-util/gtk-doc-am
108 + virtual/pkgconfig
109 + hppa? ( >=sys-devel/binutils-2.15.92.0.2 )
110 +"
111 +
112 +S="${WORKDIR}/${PN}-${PV%_rc*}"
113 +
114 +MULTILIB_CHOST_TOOLS=(
115 + /usr/bin/xml2-config
116 +)
117 +
118 +src_unpack() {
119 + # ${A} isn't used to avoid unpacking of test tarballs into $WORKDIR,
120 + # as they are needed as tarballs in ${S}/xstc instead and not unpacked
121 + unpack ${P/_rc/-rc}.tar.gz
122 + unpack ${P}-patchset.tar.xz
123 + cd "${S}" || die
124 +
125 + if use test; then
126 + cp "${DISTDIR}/${XSTS_TARBALL_1}" \
127 + "${DISTDIR}/${XSTS_TARBALL_2}" \
128 + "${S}"/xstc/ \
129 + || die "Failed to install test tarballs"
130 + unpack ${XMLCONF_TARBALL}
131 + fi
132 +}
133 +
134 +src_prepare() {
135 + default
136 +
137 + DOCS=( AUTHORS ChangeLog NEWS README* TODO* )
138 +
139 + # Selective cherry-picks from master up to 2019-02-28 (commit 8161b463f5)
140 + eapply "${WORKDIR}"/patches
141 +
142 + # Patches needed for prefix support
143 + eapply "${FILESDIR}"/${PN}-2.7.1-catalog_path.patch
144 +
145 + eprefixify catalog.c xmlcatalog.c runtest.c xmllint.c
146 +
147 + # Fix build for Windows platform
148 + # https://bugzilla.gnome.org/show_bug.cgi?id=760456
149 + # eapply "${FILESDIR}"/${PN}-2.8.0_rc1-winnt.patch
150 +
151 + # Fix python detection, bug #567066
152 + # https://bugzilla.gnome.org/show_bug.cgi?id=760458
153 + eapply "${FILESDIR}"/${PN}-2.9.2-python-ABIFLAG.patch
154 +
155 + # Fix python tests when building out of tree #565576
156 + eapply "${FILESDIR}"/${PN}-2.9.8-out-of-tree-test.patch
157 +
158 + # Workaround python3 itstool potential problems, bug 701020
159 + eapply "${FILESDIR}"/${PV}-python3-unicode-errors.patch
160 +
161 + if [[ ${CHOST} == *-darwin* ]] ; then
162 + # Avoid final linking arguments for python modules
163 + sed -i -e '/PYTHON_LIBS/s/ldflags/libs/' configure.ac || die
164 + # gcc-apple doesn't grok -Wno-array-bounds
165 + sed -i -e 's/-Wno-array-bounds//' configure.ac || die
166 + fi
167 +
168 + # Please do not remove, as else we get references to PORTAGE_TMPDIR
169 + # in /usr/lib/python?.?/site-packages/libxml2mod.la among things.
170 + # We now need to run eautoreconf at the end to prevent maintainer mode.
171 +# elibtoolize
172 +# epunt_cxx # if we don't eautoreconf
173 +
174 + eautoreconf
175 +}
176 +
177 +multilib_src_configure() {
178 + # filter seemingly problematic CFLAGS (#26320)
179 + filter-flags -fprefetch-loop-arrays -funroll-loops
180 +
181 + # USE zlib support breaks gnome2
182 + # (libgnomeprint for instance fails to compile with
183 + # fresh install, and existing) - <azarah@g.o> (22 Dec 2002).
184 +
185 + # The meaning of the 'debug' USE flag does not apply to the --with-debug
186 + # switch (enabling the libxml2 debug module). See bug #100898.
187 +
188 + # --with-mem-debug causes unusual segmentation faults (bug #105120).
189 +
190 + libxml2_configure() {
191 + ECONF_SOURCE="${S}" econf \
192 + --with-html-subdir=${PF}/html \
193 + $(use_with debug run-debug) \
194 + $(use_with icu) \
195 + $(use_with lzma) \
196 + $(use_enable ipv6) \
197 + $(use_enable static-libs static) \
198 + $(multilib_native_use_with readline) \
199 + $(multilib_native_use_with readline history) \
200 + "$@"
201 + }
202 +
203 + libxml2_py_configure() {
204 + mkdir -p "${BUILD_DIR}" || die # ensure python build dirs exist
205 + run_in_build_dir libxml2_configure \
206 + "--with-python=${EPYTHON}" \
207 + "--with-python-install-dir=$(python_get_sitedir)"
208 + # odd build system, also see bug #582130
209 + }
210 +
211 + libxml2_configure --without-python # build python bindings separately
212 +
213 + if multilib_is_native_abi && use python; then
214 + python_foreach_impl libxml2_py_configure
215 + fi
216 +}
217 +
218 +multilib_src_compile() {
219 + default
220 + if multilib_is_native_abi && use python; then
221 + local native_builddir=${BUILD_DIR}
222 + python_foreach_impl libxml2_py_emake top_builddir="${native_builddir}" all
223 + fi
224 +}
225 +
226 +multilib_src_test() {
227 + ln -s "${S}"/xmlconf || die
228 + emake check
229 + multilib_is_native_abi && use python && python_foreach_impl libxml2_py_emake test
230 +}
231 +
232 +multilib_src_install() {
233 + emake DESTDIR="${D}" \
234 + EXAMPLES_DIR="${EPREFIX}"/usr/share/doc/${PF}/examples install
235 +
236 + if multilib_is_native_abi && use python; then
237 + python_foreach_impl libxml2_py_emake \
238 + DESTDIR="${D}" \
239 + docsdir="${EPREFIX}"/usr/share/doc/${PF}/python \
240 + exampledir="${EPREFIX}"/usr/share/doc/${PF}/python/examples \
241 + install
242 + python_foreach_impl python_optimize
243 + fi
244 +}
245 +
246 +multilib_src_install_all() {
247 + # on windows, xmllint is installed by interix libxml2 in parent prefix.
248 + # this is the version to use. the native winnt version does not support
249 + # symlinks, which makes repoman fail if the portage tree is linked in
250 + # from another location (which is my default). -- mduft
251 + if [[ ${CHOST} == *-winnt* ]]; then
252 + rm -rf "${ED}"/usr/bin/xmllint
253 + rm -rf "${ED}"/usr/bin/xmlcatalog
254 + fi
255 +
256 + rm -rf "${ED}"/usr/share/doc/${P}
257 + einstalldocs
258 +
259 + if ! use examples; then
260 + rm -rf "${ED}"/usr/share/doc/${PF}/examples
261 + rm -rf "${ED}"/usr/share/doc/${PF}/python/examples
262 + fi
263 +
264 + find "${D}" -name '*.la' -delete || die
265 +}
266 +
267 +pkg_postinst() {
268 + # We don't want to do the xmlcatalog during stage1, as xmlcatalog will not
269 + # be in / and stage1 builds to ROOT=/tmp/stage1root. This fixes bug #208887.
270 + if [[ "${ROOT}" != "/" ]]; then
271 + elog "Skipping XML catalog creation for stage building (bug #208887)."
272 + else
273 + # need an XML catalog, so no-one writes to a non-existent one
274 + CATALOG="${EROOT}etc/xml/catalog"
275 +
276 + # we dont want to clobber an existing catalog though,
277 + # only ensure that one is there
278 + # <obz@g.o>
279 + if [[ ! -e ${CATALOG} ]]; then
280 + [[ -d "${EROOT}etc/xml" ]] || mkdir -p "${EROOT}etc/xml"
281 + "${EPREFIX}"/usr/bin/xmlcatalog --create > "${CATALOG}"
282 + einfo "Created XML catalog in ${CATALOG}"
283 + fi
284 + fi
285 +}
286 +
287 +libxml2_py_emake() {
288 + pushd "${BUILD_DIR}/python" > /dev/null || die
289 + emake "$@"
290 + popd > /dev/null
291 +}