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

50.7. brotli-1.2.0

Brotli compression library

Version 1.2.0, release 1
Shelf archiver — Compression libraries and archive tools
Phase 30_foundation (Build Foundation), 115 of 127 in build order
Licence MIT
Homepage https://github.com/google/brotli
Build time 2.6 SBU
Installed size 2.0 MiB in 32 files
Recipe ports/core/archiver/brotli/kpkgbuild

About

Brotli is Google’s general-purpose compression format, the br content encoding of HTTP and the compression inside WOFF2 web fonts. The port installs the three shared libraries (libbrotlicommon, libbrotlidec, libbrotlienc), the brotli command, and the Python module brotli.

The libraries are what curl decodes br responses with and what freetype2 reads WOFF2 fonts through, and qt6-qtbase, webkitgtk, chromium and nodejs depend on them too. The Python module is there for Python programs that ask for it: fonttools, calibre and yt-dlp all name brotli in their depends.

Sources

Dependencies

Depends on: cmake, ninja, python3, python3-setuptools.

Required by (22): android-tools, blender, calibre, chromium, curl, exiv2, fonttools, freetype2, ghostscript, gnutls, libheif, libjxl, libsoup3, lynx, mupdf, nodejs, qt6-qtbase, webkitgtk, webkitgtk6, wireshark, woff2, yt-dlp.

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 brotli'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/archiver/brotli.

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/brotli
echo '816c96e8e8f193b40151dad7e8ff37b1221d019dbcb9c35cd3fadbfe6477dfec  brotli-1.2.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/brotli
SRC=$SRC_ROOT/brotli-1.2.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf brotli-1.2.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 five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

cmake -S . -B build -G Ninja \
	-D CMAKE_BUILD_TYPE=Release \
	-D CMAKE_INSTALL_PREFIX=/usr \
	-D CMAKE_INSTALL_LIBDIR=lib \
	-D BUILD_SHARED_LIBS=True

cmake --build build
DESTDIR=$PKG cmake --install build

/usr/bin/python3 setup.py build
/usr/bin/python3 setup.py install --prefix=/usr --root=$PKG --optimize=1

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/brotli, 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 brotli-1.2.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/brotli, and runs the triggers its paths call for.

Contents

Installed programs: brotli.

Installed libraries: libbrotlicommon.so, libbrotlidec.so, libbrotlienc.so.

Installed directories: /usr/include/brotli, /usr/lib/python3.14/site-packages/Brotli-1.2.0-py3.14.egg-info, /usr/share/licenses/brotli.

Short descriptions

brotli brotli, brcat, unbrotli - compress or decompress files
libbrotlicommon.pc Brotli common dictionary library
libbrotlidec.pc Brotli decoder library
libbrotlienc.pc Brotli encoder library

Notes

build.sh builds the source twice. CMake builds and installs the C libraries and the brotli command; setup.py then builds the Python extension _brotli from the same tree. With USE_SYSTEM_BROTLI unset, as here, setup.py compiles the C sources into the extension itself rather than linking the libraries just installed, so _brotli.cpython-*.so needs nothing but the C library. Setting USE_SYSTEM_BROTLI=1 would make it link them instead, and would need the pkgconfig Python module, which this build does not depend on.