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

378. The image ledger

This page explains the account the build keeps of what the image spends its bytes on. Read it when the ISO is too large, or when you want to know why a particular package is on the medium.

A release ISO is one release asset of at most 1,900 MiB, and 110_iso.sh fails a base image larger than that. A build that stops there has to say what the image spends its bytes on, and why each of those packages is on it at all.

script/phases/70_image/088_ledger.sh writes that account, the image ledger: every package the finished tree holds, its size, and the dependency path from a ports/base seed that put it there. This page shows the step, the format of the ledger, and how to ask the same question of one port by hand.

Runs in: the stage, build/image-root, under KDOS_IMAGE=base; build/fs under KDOS_IMAGE=full
Reads: ports/base, ports/buildonly and the recipes, from /kdos; the root’s package database and every file its manifests name
Writes: build/image-ledger, outside the root

The step

set -e
source script/phases/70_image/phase.env

LEDGER=/kdos/build/image-ledger

python3 /kdos/script/lib/imageset.py --tree /kdos --root / --ledger --out $LEDGER
echo "[ledger] the twenty largest packages on the image ($LEDGER):"
head -n 21 $LEDGER
tail -n 1 $LEDGER

script/phases/70_image/088_ledger.sh, lines 31–39

The step runs after 087_gates.sh, so it measures the tree the trim, the sweeps, the indexes and the gates left, which is the tree 110_iso.sh squashes. It writes the ledger whole on every run, through a temporary file renamed over the old one, and prints its first twenty rows and its total into the step’s log.

The ledger

script/lib/imageset.py --ledger reads every package in the root’s database and every file its manifest names, and prints one row per package, largest first. The ledger of a base image begins and ends like this:

# bytes          MiB  package                         why
   284173981     271.0  firefox-esr                     firefox-esr
   249649753     238.1  llvm                            firefox-esr > llvm
   237850183     226.8  qt6-qtwebengine                 skanpage > qt6-qtwebengine
   207178225     197.6  linux                           linux
   ...
total 4571458713 bytes, 4359.7 MiB, in 906 packages

The bytes are the files’ sizes, each inode counted once: a file two packages share by hard link is counted for the first of them in name order, so the total is the bytes of package files the image compresses. Files no package owns, the fs/ tree and the caches the steps generate, are not in it; 087_gates.sh reports those.

The last column is the shortest dependency path from a seed to the package, the same edges the image stage closed over: each recipe’s first depends = line, not followed into a port ports/buildonly lists unless ports/base names it. A package that is itself a seed has a path of one name. A row whose path is - is a package outside the base, which only a KDOS_IMAGE=full image carries.

The path is a reason, not the only one: a port two seeds reach is listed under the shorter path. To take a port off the medium, every path to it has to go, and --why after an edit shows the next one.

One port by hand

--why answers the question for one port, with no package database, so it runs on your machine:

python3 script/lib/imageset.py --why kio-extras
plasma-workspace > kio-extras

It exits 1 and prints <port>: not in the base for a port no path reaches.

--ledger --root build/fs prints a ledger of the whole build tree, where every package outside the base has -. build/fs belongs to root, so a file whose mode keeps you out is skipped; run it as root for an exact total.

See also