Merge pull request #33761 from DaanDeMeyer/mkosi

mkosi: Various NO_BUILD improvements
This commit is contained in:
Daan De Meyer
2024-07-18 12:46:58 +02:00
committed by GitHub
7 changed files with 51 additions and 18 deletions
+18
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
+1
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',
],
+1 -1
View File
@@ -4,7 +4,7 @@
Distribution=centos
[Distribution]
Release=9
Release=10
[Content]
Environment=
-7
View File
@@ -1,7 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
PathExists=build/
[Host]
ExtraSearchPaths=build/
-8
View File
@@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
PathExists=!build/
SystemdVersion=<254
[Host]
@ToolsTree=default
+1 -1
View File
@@ -3,7 +3,7 @@
set -e
set -o nounset
if ((${NO_SYNC:-0})); then
if ((${NO_SYNC:-0})) || ((${NO_BUILD:-0})); then
exit 0
fi
+30 -1
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