Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

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

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:

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.