mkosi: Adapt configuration to take into account configuration rework

In https://github.com/systemd/mkosi/pull/2847, the '@' specifier is
removed, CLI arguments take priority over configuration files again
and the "main" image is defined at the top level instead of in
mkosi.images/. Additionally, not every setting from the top level
configuration is inherited by the images in mkosi.images/ anymore,
only settings which make sense to be inherited are inherited.

This commit gets rid of all the usages of '@', moves the "main" image
configuration from mkosi.images/system to the top level and gets rid
of various hacks we had in place to deal with quirks of the old
configuration parsing logic.

We also remove usages of Images= and --append as these options are
removed by the mentioned PR.
This commit is contained in:
Daan De Meyer 2024-07-08 12:59:52 +02:00
parent bffd3c52ad
commit 20345a86b7
84 changed files with 144 additions and 211 deletions

View File

@ -92,7 +92,7 @@ jobs:
steps: steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- uses: systemd/mkosi@9f280901d5ba81ce63072e0892649c27d41dd169 - uses: systemd/mkosi@e5706bd0761107bda96763191950c4198e0ccb27
# Freeing up disk space with rm -rf can take multiple minutes. Since we don't need the extra free space # Freeing up disk space with rm -rf can take multiple minutes. Since we don't need the extra free space
# immediately, we remove the files in the background. However, we first move them to a different location # immediately, we remove the files in the background. However, we first move them to a different location

View File

@ -52,7 +52,7 @@ image all the time when iterating on a patch, add the following to
```conf ```conf
[Host] [Host]
@RuntimeBuildSources=yes RuntimeBuildSources=yes
``` ```
After enabling this setting, the source and build directories will be mounted to After enabling this setting, the source and build directories will be mounted to

View File

@ -1,17 +1,28 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
[Config] [Config]
@Images=system
MinimumVersion=23~devel MinimumVersion=23~devel
InitrdInclude=mkosi.initrd/
[Output] [Output]
@OutputDirectory=build/mkosi.output RepartDirectories=mkosi.repart
@BuildDirectory=build/mkosi.builddir OutputDirectory=build/mkosi.output
@CacheDirectory=build/mkosi.cache BuildDirectory=build/mkosi.builddir
CacheDirectory=build/mkosi.cache
[Content] [Content]
@SELinuxRelabel=no SELinuxRelabel=no
BuildSourcesEphemeral=yes BuildSourcesEphemeral=yes
Autologin=yes
PostInstallationScripts=mkosi.sanitizers.chroot
ExtraTrees=
mkosi.crt:/usr/lib/verity.d/mkosi.crt # sysext verification key
mkosi.leak-sanitizer-suppressions:/usr/lib/systemd/leak-sanitizer-suppressions
mkosi.coredump-journal-storage.conf:/usr/lib/systemd/coredump.conf.d/10-coredump-journal-storage.conf
Environment=
SYSTEMD_REPART_OVERRIDE_FSTYPE_ROOT=%F
# Adding more kernel command line arguments is likely to hit the kernel command line limit (512 bytes) in # Adding more kernel command line arguments is likely to hit the kernel command line limit (512 bytes) in
# various scenarios. Consider adding support for a credential instead if possible and using that. # various scenarios. Consider adding support for a credential instead if possible and using that.
@ -43,13 +54,85 @@ KernelCommandLine=systemd.crash_shell
KernelModulesInitrdExclude=.* KernelModulesInitrdExclude=.*
KernelModulesInitrdInclude=default KernelModulesInitrdInclude=default
ExtraTrees=
%O/minimal-0.root-%a.raw:/usr/share/minimal_0.raw
%O/minimal-0.root-%a-verity.raw:/usr/share/minimal_0.verity
%O/minimal-0.root-%a-verity-sig.raw:/usr/share/minimal_0.verity.sig
%O/minimal-1.root-%a.raw:/usr/share/minimal_1.raw
%O/minimal-1.root-%a-verity.raw:/usr/share/minimal_1.verity
%O/minimal-1.root-%a-verity-sig.raw:/usr/share/minimal_1.verity.sig
%O/minimal-base:/usr/share/TEST-13-NSPAWN-container-template
%O/exitrd:/exitrd
InitrdPackages=
btrfs-progs
findutils
grep
sed
Packages=
acl
attr
bash-completion
bpftrace
btrfs-progs
clang
coreutils
curl
diffutils
dnsmasq
dosfstools
e2fsprogs
findutils
gdb
grep
gzip
jq
kbd
kexec-tools
kmod
knot
less
lld
llvm
lvm2
man
mdadm
mtools
nano
nftables
nvme-cli
opensc
openssl
p11-kit
pciutils
python3
qrencode
radvd
rsync
sed
socat
strace
systemd
tar
tmux
tree
udev
util-linux
valgrind
which
wireguard-tools
xfsprogs
zsh
zstd
[Host] [Host]
Credentials=journal.storage=persistent Credentials=journal.storage=persistent
@Incremental=yes Incremental=yes
@RuntimeBuildSources=yes RuntimeBuildSources=yes
@RuntimeScratch=no RuntimeScratch=no
@QemuSmp=2 QemuSmp=2
@QemuSwtpm=yes QemuSwtpm=yes
@QemuVsock=yes QemuVsock=yes
@QemuKvm=yes QemuKvm=yes
ToolsTreePackages=virtiofsd ToolsTreePackages=virtiofsd

View File

@ -1,11 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
Distribution=centos
[Distribution]
@Release=9
Repositories=epel
epel-next
hyperscale-packages-main
hyperscale-packages-experimental

View File

@ -3,6 +3,13 @@
[Match] [Match]
Distribution=centos Distribution=centos
[Distribution]
Release=9
Repositories=epel
epel-next
hyperscale-packages-main
hyperscale-packages-experimental
[Content] [Content]
Environment= Environment=
Environment= Environment=

View File

@ -4,6 +4,9 @@
Distribution=|debian Distribution=|debian
Distribution=|ubuntu Distribution=|ubuntu
[Distribution]
PackageManagerTrees=mkosi-pinning.pref:/etc/apt/preferences.d/mkosi-pinning.pref
[Content] [Content]
Environment= Environment=
GIT_URL=https://salsa.debian.org/systemd-team/systemd.git GIT_URL=https://salsa.debian.org/systemd-team/systemd.git
@ -11,9 +14,6 @@ Environment=
GIT_BRANCH=debian/master GIT_BRANCH=debian/master
GIT_COMMIT=abf24e775c67cf054f474526dd5d9d952a00228b GIT_COMMIT=abf24e775c67cf054f474526dd5d9d952a00228b
[Distribution]
PackageManagerTrees=mkosi-pinning.pref:/etc/apt/preferences.d/mkosi-pinning.pref
VolatilePackages= VolatilePackages=
libnss-myhostname libnss-myhostname
libnss-mymachines libnss-mymachines

View File

@ -1,7 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
Distribution=debian
[Distribution]
@Release=testing

View File

@ -3,6 +3,9 @@
[Match] [Match]
Distribution=debian Distribution=debian
[Distribution]
Release=testing
[Content] [Content]
Packages= Packages=
linux-perf linux-perf

View File

@ -1,7 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
Distribution=fedora
[Distribution]
@Release=rawhide

View File

@ -3,6 +3,9 @@
[Match] [Match]
Distribution=fedora Distribution=fedora
[Distribution]
Release=rawhide
[Content] [Content]
Environment= Environment=
GIT_URL=https://src.fedoraproject.org/rpms/systemd.git GIT_URL=https://src.fedoraproject.org/rpms/systemd.git

View File

@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
Distribution=opensuse
[Distribution]
@Release=tumbleweed
PackageManagerTrees=mkosi.conf.d/macros.db_backend:/etc/rpm/macros.db_backend

View File

@ -6,6 +6,10 @@ Distribution=opensuse
[Config] [Config]
InitrdInclude=initrd/ InitrdInclude=initrd/
[Distribution]
Release=tumbleweed
PackageManagerTrees=macros.db_backend:/etc/rpm/macros.db_backend
[Content] [Content]
Environment= Environment=
GIT_URL=https://src.opensuse.org/rpm/systemd GIT_URL=https://src.opensuse.org/rpm/systemd

View File

@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
Distribution=ubuntu
[Distribution]
@Release=noble
Repositories=universe

View File

@ -3,6 +3,10 @@
[Match] [Match]
Distribution=ubuntu Distribution=ubuntu
[Distribution]
Release=noble
Repositories=universe
[Content] [Content]
Packages= Packages=
linux-image-generic linux-image-generic

View File

@ -0,0 +1,9 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# If we're only rerunning the build script, remove all subimage dependencies to speed up builds.
[Match]
Format=none
[Config]
Dependencies=

View File

@ -8,8 +8,8 @@ RepartDirectories=
RepartDirectories=mkosi.repart RepartDirectories=mkosi.repart
[Validation] [Validation]
@SecureBoot=yes SecureBoot=yes
@SignExpectedPcr=yes SignExpectedPcr=yes
[Host] [Host]
@RuntimeSize=8G RuntimeSize=8G

View File

@ -1,22 +1,14 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
[Config]
ConfigureScripts=
[Output] [Output]
Format=directory Format=directory
[Content] [Content]
Bootable=no Bootable=no
@Locale=C.UTF-8 Locale=C.UTF-8
WithDocs=no WithDocs=no
CleanPackageMetadata=yes CleanPackageMetadata=yes
MakeInitrd=yes MakeInitrd=yes
BuildSources=
Packages=
BuildPackages=
VolatilePackages=
Packages= Packages=
bash bash

View File

@ -2,7 +2,6 @@
[Config] [Config]
Dependencies=minimal-base Dependencies=minimal-base
ConfigureScripts=
[Distribution] [Distribution]
CacheOnly=always CacheOnly=always
@ -15,11 +14,3 @@ SplitArtifacts=yes
BaseTrees=%O/minimal-base BaseTrees=%O/minimal-base
Environment=SYSTEMD_REPART_OVERRIDE_FSTYPE=squashfs Environment=SYSTEMD_REPART_OVERRIDE_FSTYPE=squashfs
Bootable=no Bootable=no
BuildSources=
Packages=
BuildPackages=
VolatilePackages=
[Host]
Incremental=no

View File

@ -2,7 +2,6 @@
[Config] [Config]
Dependencies=minimal-base Dependencies=minimal-base
ConfigureScripts=
[Distribution] [Distribution]
CacheOnly=always CacheOnly=always
@ -15,11 +14,3 @@ SplitArtifacts=yes
BaseTrees=%O/minimal-base BaseTrees=%O/minimal-base
Environment=SYSTEMD_REPART_OVERRIDE_FSTYPE=squashfs Environment=SYSTEMD_REPART_OVERRIDE_FSTYPE=squashfs
Bootable=no Bootable=no
BuildSources=
Packages=
BuildPackages=
VolatilePackages=
[Host]
Incremental=no

View File

@ -1,22 +1,14 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
[Config]
ConfigureScripts=
[Output] [Output]
Format=directory Format=directory
[Content] [Content]
Bootable=no Bootable=no
@Locale=C.UTF-8 Locale=C.UTF-8
WithDocs=no WithDocs=no
CleanPackageMetadata=yes CleanPackageMetadata=yes
BuildSources=
Packages=
BuildPackages=
VolatilePackages=
Packages= Packages=
bash bash
coreutils coreutils

View File

@ -1,7 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Content]
PostInstallationScripts=../mkosi.sanitizers.chroot
ExtraTrees=
../leak-sanitizer-suppressions:/usr/lib/systemd/leak-sanitizer-suppressions
../coredump-journal-storage.conf:/usr/lib/systemd/coredump.conf.d/10-coredump-journal-storage.conf

View File

@ -1,81 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Config]
InitrdInclude=initrd/
[Output]
RepartDirectories=mkosi.repart
[Content]
Autologin=yes
ExtraTrees=
%D/mkosi.crt:/usr/lib/verity.d/mkosi.crt # sysext verification key
leak-sanitizer-suppressions:/usr/lib/systemd/leak-sanitizer-suppressions
coredump-journal-storage.conf:/usr/lib/systemd/coredump.conf.d/10-coredump-journal-storage.conf
PostInstallationScripts=mkosi.sanitizers.chroot
Environment=
SYSTEMD_REPART_OVERRIDE_FSTYPE_ROOT=%F
InitrdPackages=
btrfs-progs
findutils
grep
sed
Packages=
acl
attr
bash-completion
bpftrace
btrfs-progs
clang
coreutils
curl
diffutils
dnsmasq
dosfstools
e2fsprogs
findutils
gdb
grep
gzip
jq
kbd
kexec-tools
kmod
knot
less
lld
llvm
lvm2
man
mdadm
mtools
nano
nftables
nvme-cli
opensc
openssl
p11-kit
pciutils
python3
qrencode
radvd
rsync
sed
socat
strace
systemd
tar
tmux
tree
udev
util-linux
valgrind
which
wireguard-tools
xfsprogs
zsh
zstd

View File

@ -1,22 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
Format=!none
[Config]
Dependencies=
exitrd
minimal-base
minimal-0
minimal-1
[Content]
ExtraTrees=
%O/minimal-0.root-%a.raw:/usr/share/minimal_0.raw
%O/minimal-0.root-%a-verity.raw:/usr/share/minimal_0.verity
%O/minimal-0.root-%a-verity-sig.raw:/usr/share/minimal_0.verity.sig
%O/minimal-1.root-%a.raw:/usr/share/minimal_1.raw
%O/minimal-1.root-%a-verity.raw:/usr/share/minimal_1.verity
%O/minimal-1.root-%a-verity-sig.raw:/usr/share/minimal_1.verity.sig
%O/minimal-base:/usr/share/TEST-13-NSPAWN-container-template
%O/exitrd:/exitrd

7
mkosi.initrd/mkosi.conf Normal file
View File

@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Content]
PostInstallationScripts=../mkosi.sanitizers.chroot
ExtraTrees=
../mkosi.leak-sanitizer-suppressions:/usr/lib/systemd/leak-sanitizer-suppressions
../mkosi.coredump-journal-storage.conf:/usr/lib/systemd/coredump.conf.d/10-coredump-journal-storage.conf

View File

@ -134,7 +134,6 @@ def main():
'--runtime-network=none', '--runtime-network=none',
'--runtime-scratch=no', '--runtime-scratch=no',
*args.mkosi_args, *args.mkosi_args,
'--append',
'--qemu-firmware', args.firmware, '--qemu-firmware', args.firmware,
'--qemu-kvm', "auto" if not bool(int(os.getenv("TEST_NO_KVM", "0"))) else "no", '--qemu-kvm', "auto" if not bool(int(os.getenv("TEST_NO_KVM", "0"))) else "no",
'--kernel-command-line-extra', '--kernel-command-line-extra',
@ -184,9 +183,8 @@ def main():
text=True, text=True,
).stdout ).stdout
) )
images = {image["Image"]: image for image in j["Images"]} distribution = j["Images"][-1]["Distribution"]
distribution = images["system"]["Distribution"] release = j["Images"][-1]["Release"]
release = images["system"]["Release"]
artifact = f"ci-mkosi-{id}-{iteration}-{distribution}-{release}-failed-test-journals" artifact = f"ci-mkosi-{id}-{iteration}-{distribution}-{release}-failed-test-journals"
ops += [f"gh run download {id} --name {artifact} -D ci/{artifact}"] ops += [f"gh run download {id} --name {artifact} -D ci/{artifact}"]
journal_file = Path(f"ci/{artifact}/test/journal/{name}.journal") journal_file = Path(f"ci/{artifact}/test/journal/{name}.journal")