365. The package store
This page is for anyone who rebuilds KDOS often and turns on the package store to save compile time.
The package store, build/pkgstore, holds every package a build made, filed under a key that names its recipe, its build environment and the exact bytes of its dependencies. A later build whose key matches installs the stored package instead of compiling the port again. The store is off by default.
script/phases/70_image/015_pkgstore.sh keeps the store under a size limit. When the store is on, this step deletes the entries used least recently until the store fits under KDOS_PKG_STORE_MAX.
The step
set -e
source script/phases/70_image/phase.env
if [ -z "${KPKG_STORE:-}" ]; then
echo "[PKGSTORE] The package store is off (KDOS_PKG_STORE=${KDOS_PKG_STORE:-0})."
exit 0
fi
kpkg store gc "$KPKG_STORE" "${KDOS_PKG_STORE_MAX:-60G}"
script/phases/70_image/015_pkgstore.sh, lines 19–27
KDOS_PKG_STORE on the make build command line chooses the mode:
| Value | Effect |
|---|---|
0, unset, or any other value |
The store is off. script/chroot/exec.sh sets KPKG_STORE empty, and this step prints that the store is off and exits. |
1 |
The store is on. exec.sh sets KPKG_STORE to /kdos/build/pkgstore. |
check |
Check mode: the store is on, but every port is built anyway and the result is compared with the stored package. |
kpkg store gc decides what to delete:
- It orders the entries by the modification time of each entry’s
METAfile. kpkg touches that file whenever it reuses the entry or a build makes the same package again. - It deletes the oldest entries first, until the store’s total size is at most the limit.
- An entry directory with no
METAis a store write that never finished, and is deleted whatever the size.
The limit is KDOS_PKG_STORE_MAX, 60G unless the command line says otherwise. It is a whole number of bytes with an optional K, M, G or T suffix, each a power of 1024:
make build KDOS_PKG_STORE=1 KDOS_PKG_STORE_MAX=30G
Why it runs here
By this step every port the build names has been installed, either built or reused from the store, so every entry this build touched is newer than every entry it did not. Evicting at this point removes what the current tree has no use for, such as the packages of recipes that have since changed, and keeps the whole of what the next build of the same tree would ask for, as long as that fits under the limit. A limit smaller than one build’s packages evicts some of this build’s own entries, and the next build compiles those ports again.
Skipping the step only lets the store grow: every changed recipe adds an entry and nothing removes one. make clean removes the whole store; make cleanbuild keeps it, with the snapshots and the compiler cache.
What it leaves
Nothing on the image. The store is under build/ on your machine and is never copied into the root.
See also
- The package store: the key, check mode and eviction
- The package store: where the store sits in a build
- Caches and the package store: the directory on your machine