13. Xz
xz compresses and decompresses the .xz format, and its library, liblzma, does the same for any program that links it. Inside the chroot, kpkg compresses every package it builds with xz and unpacks every package it installs through it, and many of the ports’ sources are .tar.xz archives, so xz has to exist in the root before the first port is built. This page shows the commands of script/phases/10_bootstrap/050_xz.sh and explains them.
Source: the archive of the xz port
Installs into: build/fs/usr
Approximate build time: 0.2 SBU
Installation of xz
XZ_SRC=$(extract_port_source xz)
cd "$XZ_SRC"
mkdir -p build && cd build
../configure \
--host=$KDOS_TARGET \
--prefix=/usr \
--disable-static \
--disable-nls
make
make DESTDIR=$SYSROOT install
# No libtool archive outlives this step: it is installed outside any
# package, so nothing later removes it.
rm -f $SYSROOT/usr/lib/liblzma.la
script/phases/10_bootstrap/050_xz.sh, lines 24–41
The meaning of the configure options
--host=$KDOS_TARGET-
Compile with the cross toolchain. No
--buildis given, so configure runs its own test of whether it is cross-compiling. The test program runs in the container and configure concludes that it is not (see Part III); xz’s configure tests then run in the container. The programs are still compiled and linked by the cross toolchain againstbuild/fs. --prefix=/usr-
Install under
/usr. --disable-static- Build the shared liblzma only. Nothing in the bootstrap links it statically.
--disable-nls- Build no message catalogues, and install none of the translated manual pages, which xz’s makefile installs only with native-language support. The xz port builds both, and kpkg prunes them from its package (see Size and language policy), so a copy installed here would be adopted by no package and outlive every install.
The rm deletes liblzma.la, the libtool archive the install writes. No package will own it, and libtool would copy the build-time paths it records into every library later linked through it (see Part III).
Contents of xz
Installed programs: xz, xzdec, lzmadec, lzmainfo, and the links and scripts that give it its other names: unxz, xzcat, lzma, unlzma, lzcat, xzcmp, xzdiff, xzegrep, xzfgrep, xzgrep, xzless, xzmore and their lz counterparts.
Installed library: liblzma.so.
The xz port’s page describes each program.
Built again later
The xz port, in 30_foundation, rebuilds it natively, and kpkg adopts the files this step installed. It differs in three switches:
- It compiles at
-O3instead of-O2, by substituting the level inCFLAGSandCXXFLAGSbefore configure runs. - It passes
--enable-nlswhere this step passes--disable-nls, and--enable-sandbox=landlock, which names the Landlock sandbox outright rather than leaving the choice to configure’s detection. - It leaves out
--disable-static, so the package carriesliblzma.aas well.