50.2. xz-5.8.4
XZ compression utilities
| Version | 5.8.4, release 1 |
| Shelf | archiver — Compression libraries and archive tools |
| Phase | 30_foundation (Build Foundation), 3 of 127 in build order |
| Licence | 0BSD AND GPL-2.0-or-later |
| Homepage | https://tukaani.org/xz/ |
| Build time | 0.3 SBU |
| Installed size | 1.5 MiB in 89 files |
| Recipe | ports/core/archiver/xz/kpkgbuild |
About
XZ Utils is the .xz and .lzma format: the library liblzma and the xz, unxz, xzcat and lzma commands, with the xzgrep, xzdiff and xzless scripts. On KDOS it is the package format itself. kpkg rolls every package as a .tar.xz, piping the archive through xz -T0 on all cores, and unpacks every .tar.xz source with it (see What kpkg does around build.sh). liblzma is linked by file, libarchive, elfutils, zstd, gdb and many more.
Until 30_foundation the root’s xz is the one Part III built, outside any package; this port, the second of the archiver shelf, replaces it and adopts its files.
Sources
xz-5.8.4.tar.gz(2.7 MiB)
sha2560014c7886930454fe8bd4228665b51af55eeae560ea135c9c4cd33f55b2591d9
upstream: https://github.com/tukaani-project/xz/releases/download/v5.8.4/xz-5.8.4.tar.gz
archive copy: sources-1/archiver--xz-5.8.4.tar.gz
Dependencies
Depends on: nothing a recipe names.
Required by (53): akonadi, bcc, boost, botan, caligula, elfutils, erofs-utils, ffmpeg, file, freeciv, fwupd, gdal, gdb, gettext, gimp, gnome-disk-utility, gnuastro, goldendict-ng, graphicsmagick, handbrake, htslib, imagemagick, imhex, karchive, kbd, kmod, libarchive, libreoffice, libtiff, libunwind-nongnu, libxml2, libxmlb, libzim, libzip, lldb, minizip-ng, nbdkit, opencpn, openttd, pdal, perf, python3, qemu, R, ripgrep-all, rizin, rust, schismtracker, squashfs-tools, viking, vtk, wxwidgets, zstd.
Differs from the bootstrap build. Xz builds this source too, in script/phases/10_bootstrap/050_xz.sh, before kpkg exists.
Only in the bootstrap build: --disable-nls, --disable-static, --host=$KDOS_TARGET.
Only in this build: --enable-nls, --enable-sandbox=landlock.
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 xz'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/archiver/xz.
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/archiver/xz
echo '0014c7886930454fe8bd4228665b51af55eeae560ea135c9c4cd33f55b2591d9 xz-5.8.4.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/xz
SRC=$SRC_ROOT/xz-5.8.4
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf xz-5.8.4.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 five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
export CFLAGS="${CFLAGS/-O2/-O3}" CXXFLAGS="${CXXFLAGS/-O2/-O3}"
./configure --prefix=/usr \
--enable-nls \
--enable-sandbox=landlock
make
make DESTDIR=$PKG install
The switches, and why each is set:
${CFLAGS/-O2/-O3}— raise the exportedCFLAGSandCXXFLAGSfrom-O2to-O3before configure reads them.-O3is raised per port, never across the tree (see One release flag set, raised per port).--enable-nls— build translated messages, which is configure’s default. The catalogues the install writes are removed again by kpkg’s language rule, so the package carries none (see Size and language policy).--enable-sandbox=landlock— use Landlock, the Linux sandbox a program can impose on itself, to restrict whatxzmay do once it has parsed its arguments. Writing only to standard output, it gives up creating or removing files; with exactly one input file, it gives up opening anything else once that file is open. Left atauto, configure would pick Landlock when a test program usinglinux/landlock.hand the Landlock system calls links, and silently build no sandbox when it does not; named outright, a failed test stops configure withlandlock support not found.
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/xz, 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 xz-5.8.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/xz, and runs the triggers its paths call for.
Contents
Installed programs: lzcat, lzcmp, lzdiff, lzegrep, lzfgrep, lzgrep, lzless, lzma, lzmadec, lzmainfo, lzmore, unlzma, unxz, xz, xzcat, xzcmp, xzdec, xzdiff, xzegrep, xzfgrep, xzgrep, xzless, xzmore.
Installed libraries: liblzma.a, liblzma.so.
Installed directories: /usr/include/lzma, /usr/share/doc/xz, /usr/share/licenses/xz.
Short descriptions
lzmainfo |
show information stored in the .lzma file header |
xz |
Compress or decompress .xz and .lzma files |
xzdec |
Small .xz and .lzma decompressors |
xzdiff |
compare compressed files |
xzgrep |
search possibly-compressed files for patterns |
xzless |
view xz or lzma compressed (text) files |
xzmore |
view xz or lzma compressed (text) files |
liblzma.pc |
General purpose data compression library |
Notes
Landlock cannot be combined with -fsanitize. A sanitizer build cannot compress or decompress a single file to standard output, so configure stops with an error when CC or CFLAGS contain -fsanitize=; such a build of this port needs --disable-sandbox in place of the switch above.