48.3. libxml2-2.15.4
Contains libraries and utilities used for parsing XML files
| Version | 2.15.4, release 1 |
| Shelf | formats — Data-format and serialisation libraries (XML, JSON, YAML, TOML, INI, RDF, protobuf, thrift), plus data query and convert tools |
| Phase | 30_foundation (Build Foundation), 102 of 127 in build order |
| Licence | MIT |
| Homepage | https://github.com/GNOME/libxml2 |
| Build time | 0.7 SBU |
| Installed size | 3.7 MiB in 67 files |
| Recipe | ports/core/formats/libxml2/kpkgbuild |
About
libxml2 is GNOME’s XML library: a parser with DTD and schema validation, XPath, XInclude, XML catalogues and an HTML parser, with xmllint and xmlcatalog as its command-line tools. Many of the desktop’s applications read XML through it. libxslt, and with it every manual page rendered from DocBook, is built on it.
Its catalogue support is what lets the documentation builds run with no network. libxml2 reads /etc/xml/catalog, written by docbook-xsl, and resolves every DocBook DTD and stylesheet address through it to a local file.
libxml2 has no HTTP client, so a program that hands it an http:// address gets an error rather than a download; see SpatiaLite cannot load a WFS layer from a URL.
Sources
libxml2-2.15.4.tar.xz(3.0 MiB)
sha25698087fd181d9070724f3fbc65c7377db03038eb92bd882374daff44940138821
upstream: https://download.gnome.org/sources/libxml2/2.15/libxml2-2.15.4.tar.xz
archive copy: sources-2/formats--libxml2-2.15.4.tar.xz
Dependencies
Depends on: icu, xz, zlib, readline, python3, doxygen.
Required by (121): abiword, aisleriot, akonadi, appstream, ardour, aria2, artikulate, at-spi2-core, audacious-plugins, brasero, calibre, cantor, chemical-mime-data, clamav, clang, clang21, darktable, dcmtk, digikam, docbook-xml, docbook-xsl, ebook-tools, ffmpeg, font-manager, fontforge, foomatic-db-engine, fuse-emulator, gdal, gimp-help, glabels, gnucash, gnumeric, goffice, graphicsmagick, gst-plugins-bad, gst-plugins-good, gtksourceview4, gtksourceview5, gvfs, hamlib, handbrake, hurl, hwloc, ifcopenshell, imagemagick, inkscape, ispc, itstool, kdoctools, kfilemetadata, khelpcenter, kio, kitinerary, kodi, ktouch, lasem, libaccounts-glib, libavif, libbluray, libetonyek, libgphoto2, libgpod, libgsf, libiio, liblangtag, liblxi, libmusicbrainz5, libnbd, libodfgen, libosinfo, libqalculate, libreoffice, librsvg, libspatialite, libvirt, libvirt-glib, libvisio, libxkbcommon, libxslt, lld, lld21, lldb, llvm, llvm21, mlt, netcdf-c, netpbm, newsboat, nfs-utils, openbabel, openconnect, openscad, osinfo-db-tools, parley, pdal, phodav, podofo, postgresql, python3-lxml, python3-pyside6, qgis, raptor2, recoll, rhythmbox, sane-airscan, sane-backends, sc-im, shared-mime-info, thermald, totem-pl-parser, tuxpaint, umbrello, universal-ctags, virt-manager, vlc, vtk, wayland, webkitgtk, webkitgtk6, wireshark, wv.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/30_foundation/phase.env && kpkg install libxml2'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/formats/libxml2.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/formats/libxml2
echo '98087fd181d9070724f3fbc65c7377db03038eb92bd882374daff44940138821 libxml2-2.15.4.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/libxml2
SRC=$SRC_ROOT/libxml2-2.15.4
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libxml2-2.15.4.tar.xz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
export PYTHON=/usr/bin/python3
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--with-icu \
--with-history \
--with-zlib \
--with-python
make
make DESTDIR=$PKG install
install -Dm644 doc/xml2-config.1 dist-doc/xmllint.1 dist-doc/xmlcatalog.1 \
-t "$PKG/usr/share/man/man1"
The switches, and why each is set:
PYTHON=/usr/bin/python3— Names the interpreter configure’sAM_PATH_PYTHONchecks and builds the Python bindings for, instead of the first one it finds onPATH.--sysconfdir=/etc— For libxml2 this is also where its default catalogue lives: the library readsfile://+ sysconfdir +/xml/catalogwheneverXML_CATALOG_FILESis unset, which makes it/etc/xml/catalog.--with-icu— Builds ICU in as a further converter for character encodings. For an encoding its own built-in converters do not handle, libxml2 asks iconv, which here is musl’s, and then ICU for any encoding iconv does not know.--with-history— Buildsxmllint --shellwith readline and its history, so the interactive shell has line editing and remembers commands. It turns on--with-readlineas well.--with-zlib— Lets libxml2 read gzip-compressed XML when a program asks for it with theXML_PARSE_UNZIPoption, andxmllintread compressed files. Upstream leaves zlib off by default.--with-python— Builds the Python bindings, thelibxml2module, which upstream leaves off by default. itstool, which merges translations into XML documentation for many GNOME-style builds, is a Python program that imports it. The bindings are generated from the API description doxygen writes, which is why doxygen is independs.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/libxml2, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf libxml2-2.15.4-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/libxml2, and runs the triggers its paths call for.
Contents
Installed programs: xml2-config, xmlcatalog, xmllint.
Installed libraries: libxml2.so.
Installed directories: /usr/include/libxml2, /usr/lib/cmake/libxml2, /usr/share/licenses/libxml2.
Short descriptions
xml2-config |
script to get information about the installed version of libxml2 |
xmlcatalog |
Command line tool to parse and manipulate XML or SGML catalog files. |
xmllint |
command line XML tool |
libxml-2.0.pc |
libXML library version2. |
Notes
The three manual pages are installed by hand. Upstream installs them only with --with-docs, the switch that also renders xmllint.1 and xmlcatalog.1 again from their DocBook sources, which needs xsltproc and the DocBook stylesheets. Those are libxslt and docbook-xsl, and both depend on libxml2, so the pages are taken as the release tarball ships them: doc/xml2-config.1, dist-doc/xmllint.1 and dist-doc/xmlcatalog.1.
gettext builds its own copy of libxml2’s parser rather than linking this one, because libxml2’s dependency on doxygen reaches back to gettext through bison.