tree-wide: Remove numbered prefixes from config files
With the following changes, there's no more need for numbered prefixes
for ordering:
- Assume EPEL is available for CentOS Stream 9/10
- Stop enabling epel-next repository for CentOS Stream 9
- Remove orphan_file hack for ubuntu jammy since we do it internally now
So we make these changes and remove the numbered prefixes throughout the
tree.
Remove mirror from default package cache directory cache key again
We added this initially to deal with pacman not having the mirror
in its cache key of repository metadata. The downside of this approach
is that we cannot cache packages across different mirrors. As an
aternative, let's simply not cache repository metadata for pacman in
the package cache directory.
While we're at it, remove the hack we did for zypper to ensure it had
the mirror in its cache key and also don't store its repository metadata
in the package cache directory. The reasoning here is while we can make
sure our own generated repository ids have the hashed mirror in them, we
cannot do so for any repositories added by users, which might end up causing
conflicts.
dnf: Share package cache between repositories with different baseurl=
Currently, the dnf5 package is not shared between repositories with the
same id but different baseurl=. For building images this is not ideal,
we do not want to have to redownload all packages when switching the
baseurl= or similar for a repository, so let's fix this by having
package_subdirs() return a tuple of source and destination path, and
in dnf's implementation of it, use the same package cache directory
for all repositories with the same id, regardless of the baseurl= used.
Note that this only applies to the package cache directory, the repository
metadata is still cached in the cache directory that is keyed by the baseurl=
or equivalent setting.
DaanDeMeyer [Fri, 22 Aug 2025 13:58:18 +0000 (15:58 +0200)]
Stop passing --workspace-dir= in mkosi-initrd and mkosi-addon
The default value when running as root is /var/tmp now so there's no
need to specify --workspace-dir= explicitly anymore. This allows the
workspace directory to be changed in the configuration file in
/etc/mkosi-initrd and /etc/mkosi-addon.
https://github.com/systemd/mkosi/issues/3852 is better fixed
by not configuring --workspace-dir at all within mkosi-initrd.
This allows it to be changed via the config file as the CLI argument
won't override it anymore and the default value used when running as
root is /var/tmp anyway.
DaanDeMeyer [Thu, 21 Aug 2025 11:47:03 +0000 (13:47 +0200)]
fedora: Rework rawhide GPG key logic
- Drop secondary key logic as looking at https://github.com/rpm-software-management/distribution-gpg-keys/tree/main/keys/fedora,
this hasn't been used for a long time.
- If repository key fetching is enabled, always look up the key remotely
as e.g. on CentOS 9 or so the rawhide symlink might be horribly outdated.
- If not using repository key fetching, Use all local keys newer than the
rawhide key as well to maximize the chances of including the current rawhide
key.
- Resolve symlinks within the sandbox in find_rpm_gpgkey() as we might not be
able to resolve the symlinks outside of the sandbox.
Luca Boccassi [Mon, 18 Aug 2025 13:04:59 +0000 (14:04 +0100)]
mkosi-tools: virtiofsd is only available on a subset of architectures on debian/ubuntu
Package virtiofsd is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'virtiofsd' has no installation candidate
‣ "/work/prepare final" returned non-zero exit code 123.
Afaict, this should work quite similar to the previous dpkg-scanpackages but
also doesn't use perl and is part of apt. Certain distros don't have reprepro
packaged, e.g. nixpkgs. It's also a simpler to work with and smaller compared
to reprepro.
DaanDeMeyer [Mon, 11 Aug 2025 13:26:50 +0000 (15:26 +0200)]
mkosi-tools: Drop systemd-boot-efi package
There's no need to install systemd-boot, systemd-stub, ... in the
tools tree as these are picked up from inside the image so let's stop
installing systemd-boot-efi in the tools tree.
Luca Boccassi [Sat, 9 Aug 2025 14:05:48 +0000 (15:05 +0100)]
mkosi-tools: move systemd-boot package to conf file matching older releases
Since debian 13/ubuntu 25.04 the tools needed at build time
(bootctl) are in the systemd-boot-tools package, so there's
no need to pull in the systemd-boot package in the tools image,
since it is an integration point that sets up the local ESP and
so on
Alberto Planas [Wed, 6 Aug 2025 10:58:55 +0000 (12:58 +0200)]
Drop microsecond resolution for datetime.now()
The RPM INSTALLTIME attribute is an integer represetantion of the
installation time of the package, and datetime.now is a date
representation of a float timestamp. This can produce some rounding
errors is powerful build servers.
For example, if the variable `_init_timestamp` has a value XXXXX.1 but
in the same sub-second the package gets installed, the registered
installation time will be the integer representation (XXXXX), making the
comparison done for exclusion of the package to be `True`.
This patch will remove the microsecond granularity of the datetime,
converting the timestamp on its integer representation, instead of the
default float one. The comparison is still done in the datetime data
type.
mkosi-initrd/vm: ensure TPM2 core modules are installed in the initrd
On arm64 the tpm_tis modules are not built-in, so /dev/tpmrm0 does
not show up in the initrd and it times out, and unlocking using
the tpm doesn't work.
Ensure the modules are included in the initrd if they are not
built in.
FirmwareVariables: allow generating during image build
The build immediately fails if FirmwareVariables=%O/somefile is used, as
the config parser won't be able to find it, so it is not possible to
generate it during the image build itself (e.g: mkosi.postoutput)
in order to add generated keys to MOK. Set required=False.
Deniz Adrian [Wed, 23 Jul 2025 20:04:53 +0000 (22:04 +0200)]
ensure builds with cache over device boundaries
when running mkosi with the default cache dir/XDG_CACHE_HOME on a
different device than the mkosi working directory, mkosi falls back to
trying to copy the cache using `copy_tree` from tree.py.
the cache contains symlinks which are pointing to files on the host:
e.g. `mkosi.cache/debian...cache/usr/bin/mt -> /etc/alternatives/mt`
`os.listxattr()` defaults to `follow_symlinks=True`, which leads to
`FileNotFoundError`s if the files don't exist on the host, which stops
the build.
this patch ignores symlinks, but feels like a workaround, as our
assumption would be that such absolute links should not be traversed
outside the chroot in the first place.
Change UnifiedKernelImages to enum and accept signed/unsigned
With custom firmware we enroll our keys in db, so local UKIs can be
built and there's no need to fail the build. Many distributions
ship signed bootloaders, but they still don't ship UKIs.
Add an enum and a parser (to keep backward compat), and if set to
unsigned build locally instead of failing when the bootloader is
signed.
hpet is an emulated clocksource that is generally discouraged in favor
of kvm-clock or tsc for virtual machines. While mkosi's virtual machines
already use kvm-clock, leaving hpet enabled causes qemu on the host to
consume a non-trivial amount of cpu, so let's disable the hpet feature since
we're not making use of it anyway.
EDK2 nowadays does provide secureboot for arm. Not only that, TPM2 support is
only enabled in builds that enable secure boot, probably because it's all
part of the TCG modules.
Default to uefi_secure_boot on arm too, like x86.
Also do not pass qemu x86-only configuration options that break booting
arm.
nfs-utils-2.8.4 will provide its own nfsroot-generator [1] to allow mounting the
real rootfs via NFSv4, so this initrd profile will enable this feature.
mkosi-tools: make sure p11-kit dir exists when configuring module
Fixes this failure, since I guess the dir may not exist:
‣ Running prepare script /tmp/tmphh1uwz2a/resources/mkosi-tools/mkosi.prepare…
/work/prepare: line 4: /buildroot/usr/share/p11-kit/modules/opensc.module: No such file or directory
Do not try to install packages that are listed in RemovePackages=
This allows using RemovePackages= in mkosi.local.conf to prevent
certain packages listed in the regular configuration from being
installed in the first place.
We also add RemovePackages= to the cache manifest because it now
affects the cached images.
opensuse: pull in grep/gzip/xz explicitly to avoid busybox in main image
Problem: 1: the installed busybox-xz-1.37.0-34.1.noarch conflicts with 'xz' provided by the to be installed xz-5.8.1-1.1.aarch64
Solution 1: deinstallation of busybox-xz-1.37.0-34.1.noarch
Solution 2: do not install xz-5.8.1-1.1.aarch64
It's both shorter, and doesn't give the wrong impression that this
is about security sandboxing, so let's rename the sandbox name to
just box. Keep the old name as well of course for compat.
Currently, if /work does not exist, we go into the exception handler which
doesn't do anything if the errno is ENOENT, even though we still need to
remove the parent directory.
If we're running inside mkosi sandbox, we don't parse the default
tools tree configuration, which this test depends on, so skip it
when running in the sandbox.
DaanDeMeyer [Mon, 30 Jun 2025 21:38:01 +0000 (23:38 +0200)]
mkosi-tools: Make sure opensc module is registered with p11-kit
Otherwise openssl will fail to load keys off a yubikey when using
pkcs11-provider. For more discussion and why this isn't the default
everywhere, see https://gitlab.archlinux.org/archlinux/packaging/packages/opensc/-/issues/2.
Daan De Meyer [Wed, 25 Jun 2025 10:47:56 +0000 (12:47 +0200)]
sandbox: Work around extra file descriptor opened by importing ctypes since python 3.14
Since python 3.14, importing ctypes opens an extra file descriptor which is used to allocate libffi
closures which are in turn used by ctypes to pass python functions as C callback function pointers. We
don't use this functionality, yet the file descriptor is still opened and messes with the file descriptor
packing logic since the file descriptor to libffi will be passed as a packed file descriptor to the
executable we're invoking. To avoid that from happening, we close libffi's file descriptor after importing
ctypes.
See https://github.com/python/cpython/issues/135893.
Luca Boccassi [Sat, 21 Jun 2025 16:54:48 +0000 (17:54 +0100)]
mkosi-obs: support splitting out and compressing partitions
Need to recompress the verity-sig partition after creating it,
and deleting the non-compressed split out partitions that are
already present as compressed but that sd-repart re-creates
when doing the signature attach operation.
Luca Boccassi [Sat, 21 Jun 2025 16:53:39 +0000 (17:53 +0100)]
compress: do not attempt to compress skipped partitions
When doing offline verity signing, split partitions and compression are
enabled, we attempt to compress a non-existing partition (verity-sig)
which will be created only later.
Do not attempt to compress partitions that are marked to be skipped by
repart.