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

173.4. kdos-kfs-1.0.0

KDOS from Scratch, the build book, as HTML and one PDF

Version 1.0.0, release 1
Source tree src/system/kdos-kfs/
Phase 41_system (System), 963 of 1047 in build order
Licence MIT
Homepage https://github.com/kunaldawn/kdos
Build time 3.0 SBU
Installed size 119.2 MiB in 2926 files
Recipe src/system/kdos-kfs/kpkgbuild

About

kdos-kfs puts this book, KDOS from Scratch, on the machine, so it can be read offline:

It is the book make book renders into build/kfs, made by the same two scripts in the same order (see Make targets):

  1. kfsgen.py writes the Markdown source of every hand-written page and every package page, the package pages generated from the recipes and the phase lists;
  2. kfsrender.py turns it into HTML and, through typst, the PDF.

The pandoc and typst it uses are the tree’s own ports, which is why both are in depends, with python3 for the two scripts.

There is no kdos-kfs command: the port installs only documents. Nothing is fetched; the port has no source = and builds out of its own directory.

Why it is in KDOS

The comment above it in script/phases/41_system/packages.d/src-system.txt:

KDOS from Scratch under /usr/share/doc/kfs, HTML and one PDF, rendered from docs/kfs and the recipes by pandoc and typst. The full file lists in its HTML come from the package database, so they name only what is installed by the time it builds.

Sources

None: the port builds from its own directory, /kdos/src/system/kdos-kfs.

Dependencies

Depends on: pandoc, typst, python3.

Required by: no port names it.

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/41_system/phase.env && kpkg install kdos-kfs'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /kdos/src/system/kdos-kfs.

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.

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/kdos-kfs
SRC=$SRC_ROOT/kdos-kfs-1.0.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"

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 PYTHONDONTWRITEBYTECODE=1
root=$PORT_SRC/../../..
for d in ports/core script/phases docs/kfs; do
	[ -d "$root/$d" ] || { echo "kdos-kfs: $root/$d is missing: the book is rendered from a KDOS checkout" >&2; exit 1; }
done

python3 "$PORT_SRC/book/kfsgen.py" --root "$root" --out "$SRC/kfs-src" \
	--kdos-book file:///usr/share/doc/kdos/
python3 "$PORT_SRC/book/kfsrender.py" --pandoc pandoc --typst typst \
	--src "$SRC/kfs-src" --out "$SRC/kfs" --buildfs /

install -d "$PKG/usr/share/doc"
cp -R "$SRC/kfs/html" "$PKG/usr/share/doc/kfs"
install -m644 "$SRC/kfs/kfs.pdf" "$PKG/usr/share/doc/kfs/kfs.pdf"
install -Dm644 -t "$PKG/usr/share/khelpcenter/plugins" "$PORT_SRC"/khelpcenter/kfs.desktop
install -Dm644 -t "$PKG/usr/share/applications" "$PORT_SRC"/applications/kdos-library-kfs-book.desktop

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/kdos-kfs, 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 kdos-kfs-1.0.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/kdos-kfs, and runs the triggers its paths call for.

Other files in the port directory, read by build.sh: applications/, book/, docs/, khelpcenter/.

Contents

Installed directories: /usr/share/doc/kfs.

Notes

The book reaches the port through two symbolic links in its directory, docs to docs/kfs and book to script/book, the renderer. The recipe hash follows them, so an edit to a hand-written page, to the committed snapshot under docs/kfs/data or to the renderer rebuilds this port on the next 41_system run. A recipe, a kfs.md or a phase list is in no part of that hash; each is covered by docs/kfs/data/recipes.stamp, and make book-stamp rewriting the stamp is what rebuilds this port for them (see The port’s note: kfs.md).

kfsgen.py reads the whole repository, not only the two links: the recipes under ports/core and src/, script/phases, and, for the listings of Part I, the Makefile and the Dockerfile. build.sh takes the repository as $PORT_SRC/../../.., which in the chroot is /kdos, and stops with a message when ports/core, script/phases or docs/kfs is missing there. The chroot binds docs/, ports/ and the two files under /kdos for it (see Entering the chroot). The image’s /ports carries the two books and the renderer but has no ports/core or script/phases beside them, so on an installed machine the port does not build.

--kdos-book file:///usr/share/doc/kdos/ makes every link into the KDOS book open the page kdos-doc installs there, at the heading the link names, instead of the page on GitHub, so the installed book reads offline. The prefix is an absolute file: URL rather than ../kdos/ because the same Markdown becomes kfs.pdf, whose viewer resolves a relative link against the PDF’s own directory. The headings match because kdos-doc gives every installed heading GitHub’s id. A link to a recipe, a patch, a phase list or anything else of the tree stays on GitHub: the image carries no copy of them.

The package installs the menu’s Library launcher for the book, kdos-library-kfs-book.desktop, which opens it in the browser through xdg-open, and KHelpCenter’s entry for it, /usr/share/khelpcenter/plugins/kfs.desktop, at an X-DOC-Weight of -99, second after the KDOS book (see kdos-doc). The installation medium does not carry this port; it is installed by name.

KHelpCenter, where it is installed, shows the book too. It adds KDE’s handbook stylesheet to every page it shows, as a <style id="default"> appended to the page’s head after kfs.css, so its element rules would put white paper, black text and blue links under the dark palette’s code blocks. kfs.css ends with rules under html:has(> head > style#default), which match only a page carrying that element and outrank the handbook’s, so in the Help Center the book keeps its own palette in either colour scheme. Outside the Help Center they match nothing.

--buildfs / points the renderer at the build root’s own package database, from which the HTML gives every package’s full file list. The database holds only what was installed before this port was built, so a package of a later phase gets the summary from docs/kfs/data/contents.tsv instead. The PDF never carries the full lists.

PYTHONDONTWRITEBYTECODE=1 keeps Python from writing a __pycache__ beside any module the two scripts import. script/book is the checkout’s, and a checkout should hold only the files it commits; the recipe hash skips such a directory when one is written all the same.