48.1. expat-2.9.0
A stream oriented C library for parsing XML
| Version | 2.9.0, 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), 26 of 127 in build order |
| Licence | MIT |
| Homepage | https://libexpat.github.io |
| Build time | 0.3 SBU |
| Installed size | 780.0 KiB in 17 files |
| Recipe | ports/core/formats/expat/kpkgbuild |
About
Expat is a stream-oriented XML parser in C: it calls back into the program for each element and piece of text as it reads, and builds no tree. wayland-scanner reads the protocol XML of every Wayland interface with it, so the compositor, the panel and every Wayland client are built through it; dbus reads its bus configuration with it, fontconfig its fonts.conf, and mesa its driver configuration. Python’s pyexpat, the parser under xml.etree, is linked against it, and so are cmake, git, polkit, libarchive and Prosody’s lua54-luaexpat. xmlwf, installed with it, checks that a file is well-formed XML.
Sources
expat-2.9.0.tar.gz(827.5 KiB)
sha25616afbb9cefead2aa278105cf27d9f597bde7fbf3dbb85015857ca7ca6a4e89ba
upstream: https://github.com/libexpat/libexpat/releases/download/R_2_9_0/expat-2.9.0.tar.gz
archive copy: sources-2/formats--expat-2.9.0.tar.gz
Dependencies
Depends on: autoconf, automake, libtool.
Required by (46): afflib, astropy, audacity, avahi, brltty, cmake, coin, dasher, dbus, digikam, exempi, exiv2, fcitx5, fontconfig, freexl, gdal, gdb, git, graphviz, libarchive, libdom, libreoffice, libstrophe, libvips, lua54-luaexpat, mesa, mesa-opencl, mpd, nco, neon, opencolorio, orcaslicer, organicmaps, perl-xml-parser, poco, polkit, prusaslicer, python3, qgis, rawtherapee, tenacity, udunits, viking, vtk, wayland, wxwidgets.
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 expat'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/formats/expat.
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/expat
echo '16afbb9cefead2aa278105cf27d9f597bde7fbf3dbb85015857ca7ca6a4e89ba expat-2.9.0.tar.gz' | 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/expat
SRC=$SRC_ROOT/expat-2.9.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf expat-2.9.0.tar.gz -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 recipe’s helpers _tag and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
./buildconf.sh
./configure \
--prefix=/usr \
--with-getrandom \
--with-getentropy \
--without-arc4random \
--without-arc4random-buf \
--without-docbook \
--without-examples \
--without-tests
make
make DESTDIR=$PKG install
The switches, and why each is set:
./buildconf.sh— Runs upstream’s autotools bootstrap, which regeneratesconfigureand everyMakefile.inwith the tree’s autoconf, automake and libtool, the three ports independs.--with-getrandom— Takes the hash salt fromgetrandom(), which musl has. Expat salts its internal hash tables with random bytes, which upstream documents as a defence against denial of service by a document built to predict the hash function. A--with-form makes configure stop when the function is missing, rather than quietly pick another source.--with-getentropy— Allowsgetentropy()as well, which musl also has; the same rule holds.--without-arc4random— Skips the check forarc4random(), which musl does not provide.--without-arc4random-buf— Skips the check forarc4random_buf(), for the same reason.--without-docbook— Installs thexmlwf.1the release tarball ships instead of rendering it again fromdoc/xmlwf.xml. Left to check, configure renders the page with the first ofdocbook2x-man,db2x_docbook2man,docbook2mananddocbook-to-manit finds, so the page would depend on what happens to be in the build root (see An optional tool found in the tree).--without-examples— Does not build the example programs, which upstream never installs.--without-tests— Does not build the test suite, which the recipe does not run.
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/expat, 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 expat-2.9.0-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/expat, and runs the triggers its paths call for.
Contents
Installed programs: xmlwf.
Installed libraries: libexpat.a, libexpat.so.
Installed directories: /usr/lib/cmake/expat-2.9.0, /usr/share/doc/expat, /usr/share/licenses/expat.
Short descriptions
xmlwf |
Determines if an XML document is well-formed |
expat.pc |
expat XML parser |
Notes
Expat is built early in the 30_foundation phase: python3 and cmake, both in that phase, depend on it, so the build order puts it ahead of them.