]> git.ipfire.org Git - thirdparty/mkosi.git/commit
Put build history into the output directory
authorMartin Pitt <martin@amutable.com>
Sat, 13 Jun 2026 06:31:08 +0000 (08:31 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 22 Jun 2026 08:21:36 +0000 (10:21 +0200)
commitda49fe976c7398524202cfedf93c8ff332d4eaf2
treec7554e7fe9034c10dd0205c8cae786c921979907
parent1c392f1918cb790e041f22e76c498835bc88c264
Put build history into the output directory

Running e.g. `test_initrd` and `test_initrd_luks` in parallel fails one of
them with "Image 'main' has not been built yet". The integration tests build
into a per-test `--output-directory`, but `vm()`/`boot()` did not pass it, so
those verbs recovered the build configuration from the *shared* global history
in `<configdir>/.mkosi-private/history/latest.json`. With concurrent builds
that file holds whatever the last build wrote, so a verb reads back another
build's config (e.g. the wrong `Format=`).

Tie the build history to the output directory: when an output directory is
given on the CLI, store and read the history under it instead of in the config
directory. Each build's history is then isolated, and a verb pointed at a
given `--output-directory` reads back exactly that build's configuration. In
the tests, pass `--output-directory` to `vm()` and `boot()` as well.

As a consequence, `mkosi vm` (and the other verbs that consume a previous
build) now require `-O`/`--output-directory` when the build used one. This is
a behaviour change, but unbreaks having more than one output dir.

Note: If a config file sets `OutputDirectory=`, the history continues to
be in the config dir, as before. The computation of the history
directory (necessarily) happens before parsing the config
files/includes. This *only* applies to the CLI option.

Rejected alternatives:
 * This cannot be worked around with `--history=no` in the tests': that
   only disables *writing* history, not *reading* it, so vm/boot still
   pick up a stale (in our setup, empty) `latest.json` and fall back to
   the wrong config.
 * A dedicated `--history-dir` option would just be redundant with
   `--output-dir`.
mkosi/config.py
tests/__init__.py