1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

mkosi: Streamline running the integration tests without building systemd

Let's document in detail how to build the integration test image and run
the integration tests without building systemd. To streamline the process,
we stop automatically using binaries from build/ when invoking mkosi directly
and don't automatically use a tools tree anymore if systemd on the host is too
old. Instead, we document these options in HACKING.md and change the mkosi meson
target to automatically use the current build directory as an extra binary search
path for mkosi.
This commit is contained in:
Daan De Meyer 2024-07-11 16:09:47 +02:00
parent bb8f6ac445
commit d279ec4a50
5 changed files with 49 additions and 16 deletions

View File

@ -44,6 +44,24 @@ or:
$ mkosi qemu
```
By default, the tools from your host system are used to build the image. To have
`mkosi` use the systemd tools from the `build/` directory, add the following to
`mkosi.local.conf`:
```conf
[Host]
ExtraSearchPaths=build/
```
And if you want `mkosi` to build a tools image and use the tools from there
instead of looking for tools on the host, add the following to
`mkosi.local.conf`:
```conf
[Host]
ToolsTree=default
```
Every time you rerun the `mkosi` command a fresh image is built, incorporating
all current changes you made to the project tree. To avoid having to build a new
image all the time when iterating on a patch, add the following to

View File

@ -2673,6 +2673,7 @@ if mkosi.found()
'--output-dir', meson.current_build_dir() / 'mkosi.output',
'--cache-dir', meson.current_build_dir() / 'mkosi.cache',
'--build-dir', meson.current_build_dir() / 'mkosi.builddir',
'--extra-search-path', meson.current_build_dir(),
'--force',
'build',
],

View File

@ -1,7 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
PathExists=build/
[Host]
ExtraSearchPaths=build/

View File

@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
PathExists=!build/
SystemdVersion=<254
[Host]
@ToolsTree=default

View File

@ -14,12 +14,41 @@ We also need to make sure the required meson options are enabled:
$ meson setup --reconfigure build -Dremote=enabled
```
Next, we can build the integration test image:
To make sure `mkosi` doesn't try to build systemd from source during the image build
process, you can add the following to `mkosi.local.conf`:
```
[Content]
Environment=NO_BUILD=1
```
You might also want to use the `PackageDirectories=` or `Repositories=` option to provide
mkosi with a directory or repository containing the systemd packages that should be installed
instead. If the repository containing the systemd packages is not a builtin repository known
by mkosi, you can use the `PackageManagerTrees=` option to write an extra repository definition
to /etc which is used when building the image instead.
Next, we can build the integration test image with meson:
```shell
$ meson compile -C build mkosi
```
By default, the `mkosi` meson target which builds the integration test image depends on
other meson targets to build various systemd tools that are used to build the image to make
sure they are up-to-date. If you instead want the already installed systemd tools on the
host to be used, you can run `mkosi` manually to build the image. To build the integration test
image without meson, run the following:
```shell
$ mkosi -f
```
Note that by default we assume that `build/` is used as the meson build directory that will be used to run
the integration tests. If you want to use another directory as the meson build directory, you will have to
configure the mkosi build directory (`BuildDirectory=`), cache directory (`CacheDirectory=`) and output
directory (`OutputDirectory=`) to point to the other directory using `mkosi.local.conf`.
After the image has been built, the integration tests can be run with:
```shell