%define major 2 # The naming scheme in non-Mandriva-based distros %if 0%{!?mklibname:1} %define mklibname(ds) lib%{1}%{?2:%{2}}%{-s:-static}%{-d:-devel} %endif %if 0%{!?mkrel:1} %define mkrel(c) %{1}%{?dist} %endif %define libname %mklibname xml 2 %{major} %define develname %mklibname xml 2 -d %if 0%{?cmake_build:1} %define buildsystem cmake %else %define buildsystem autotools %endif %if "%{_target_cpu}" == "%{_host_cpu}" %bcond_without python %endif Summary: Library providing XML and HTML support Name: libxml2 # WARNING: Please rebuild perl-XML-LibXML when you upload a new version else # you'll break a ton of perl packages' testsuite!!!!! Version: 2.13.5 Release: %mkrel 1 License: MIT Group: System/Libraries URL: http://www.xmlsoft.org/ Source0: https://download.gnome.org/sources/%{name}/2.11/%{name}-%{version}.tar.xz # Patch from openSUSE. # See: https://bugzilla.gnome.org/show_bug.cgi?id=789714 Patch1: libxml2-2.12.0-python3-unicode-errors.patch #Patch2: d0c3f01e110d54415611c5fa0040cdf4a56053f9.patch #Patch3: 235b15a590eecf97b09e87bdb7e4f8333e9de129.patch #Patch4: d39f78069dff496ec865c73aa44d7110e429bce9.patch BuildRequires: gcc %if "%{buildsystem}" == "cmake" BuildRequires: cmake %else BuildRequires: gtk-doc %if "%{buildsystem}" == "autotools" BuildRequires: autoconf BuildRequires: automake BuildRequires: libtool %endif %endif %if %{with python} BuildRequires: pkgconfig(python3) %endif BuildRequires: pkgconfig(zlib) BuildRequires: pkgconfig(liblzma) BuildRequires: (pkgconfig(readline) or readline-devel) %description This library allows you to manipulate XML files. It includes support for reading, modifying and writing XML and HTML files. There is DTDs support: this includes parsing and validation even with complex DtDs, either at parse time or later once the document has been modified. The output can be a simple SAX stream or and in-memory DOM-like representations. In this case one can use the built-in XPath and XPointer implementation to select subnodes or ranges. A flexible Input/Output mechanism is available, with existing HTTP and FTP modules and combined to a URI library. %if "%{libname}" != "%{name}" %package -n %{libname} Summary: Shared libraries providing XML and HTML support Group: System/Libraries Provides: %{name} = %{version}-%{release} %description -n %{libname} This library allows you to manipulate XML files. It includes support for reading, modifying and writing XML and HTML files. There is DTDs support: this includes parsing and validation even with complex DtDs, either at parse time or later once the document has been modified. %endif %package utils Summary: Utilities to manipulate XML files Group: System/Libraries Provides: xmllint = %{version}-%{release} Provides: xmlcatalog = %{version}-%{release} %description utils This packages contains utils to manipulate XML files. %if %{with python} %package python3 Summary: Python bindings for the libxml2 library Group: Development/Python Requires: python3 >= %{python3_version} Provides: python3-%{name} = %{version}-%{release} %{?python_provide:%python_provide python3-%{name}} %description python3 The libxml2-python3 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 you to manipulate XML files. It includes support for reading, modifying and writing XML and HTML files. There is DTDs support: this includes parsing and validation even with complex DtDs, either at parse time or later once the document has been modified. %endif %package -n %{develname} Summary: Libraries, includes, etc. to develop XML and HTML applications Group: Development/C Requires: %{libname} = %{version}-%{release} Provides: %{name}-devel = %{version}-%{release} %description -n %{develname} Libraries, include files, etc you can use to develop XML applications. This library allows you to manipulate XML files. It includes support for reading, modifying and writing XML and HTML files. There is DTDs support: this includes parsing and validation even with complex DtDs, either at parse time or later once the document has been modified. %prep %setup -q %autopatch -p1 # Prep py3 docs mkdir py3doc cp doc/*.py py3doc sed -i 's|#!/usr/bin/python |#!%{__python3} |' py3doc/*.py # Remove files generated by python/generator.py to force regenerating them # rm python/{libxml2-py.c,libxml2-py.h,libxml2-export.c} %build %if "%{buildsystem}" == "autotools" autoreconf -vfi %if %{with python} %configure %else %configure --without-python %endif %make_build %else %if "%{buildsystem}" == "cmake" %if %{with python} %cmake -DLIBXML2_WITH_PYTHON=ON \ %else %cmake -DLIBXML2_WITH_PYTHON=OFF \ %endif -DCMAKE_C_COMPILER=$(command -v gcc) %cmake_build %endif %endif %install %if "%{buildsystem}" == "cmake" %cmake_install %else %make_install %endif #only do it here if check aren't done if [ %{_with check} -eq 0 ]; then # clean before packaging documentation (test -d doc/examples && cd doc/examples && make clean && rm -rf .deps Makefile || true) gzip -9 doc/libxml2-api.xml fi # multiarch policy %if "%{_target_cpu}" == "{%_host_cpu}" && "%{_target_os}" == "%{_host_os}" %multiarch_binaries %{buildroot}%{_bindir}/xml2-config %endif # remove unpackaged files rm -rf %{buildroot}%{_prefix}/doc \ %{buildroot}%{_datadir}/doc #we don't want these find %{buildroot} -name "*.la" -delete %check # all tests must pass # use TARBALLURL_2="" TARBALLURL="" TESTDIRS="" to disable xstc test which are using remote tarball #make TARBALLURL_2="" TARBALLURL="" TESTDIRS="" check #need to do that after check otherwise it will fail # clean before packaging documentation (test -d doc/examples && cd doc/examples && make clean && rm -rf .deps Makefile || true) gzip -9 doc/libxml2-api.xml %if "%{buildsystem}" == "cmake" && %{with python} mkdir -p %{buildroot}/%{python3_sitearch} %{buildroot}/%{python3_sitelib} mv %{buildroot}/%{_prefix}/python/*.so* %{buildroot}/%{python3_sitearch} mv %{buildroot}/%{_prefix}/python/*.py %{buildroot}/%{python3_sitelib} find %{buildroot} -name '*.debug' -type f -exec rm -rf '{}' \; || true %endif %if "%{libname}" == "%{name}" %files %else %files -n %{libname} %endif %{_libdir}/lib*.so.%{major}{,.*} %files utils %doc README.md %license Copyright %{_bindir}/xmlcatalog %{_bindir}/xmllint %{_mandir}/man1/xmlcatalog* %{_mandir}/man1/xmllint* %if %{with python} %files python3 %doc README.md %license Copyright %doc py3doc/*.py %if "%{buildsystem}" != "cmake" %doc python/libxml2class.txt %endif %doc python/tests/*.py %{python3_sitearch}/* %{python3_sitelib}/* %endif %files -n %{develname} %doc NEWS README.md %license Copyright %doc doc/libxml2-api.xml.gz %if "%{buildsystem}" != "cmake" %doc %{_datadir}/gtk-doc/html/* %endif %{_bindir}/xml2-config %if "%{_target_cpu}" == "{%_host_cpu}" && "%{_target_os}" == "%{_host_os}" %multiarch %{multiarch_bindir}/xml2-config %endif %{_libdir}/*.so %{_libdir}/pkgconfig/* %if "%{buildsystem}" == "cmake" %{_libdir}/cmake/libxml2-%{version}/ %else %{_libdir}/cmake/libxml2/libxml2-config.cmake %endif %{_mandir}/man1/xml2-config* %{_includedir}/* %{_datadir}/aclocal/*