Call rmtree() on context.root after finalize_staging()
After we've finalized the staging directory, there is no more need
for the root directory in the workspace. It used to get cleaned by
the setup_workspace() context manager but this is rather slow (can
take more than a second). By calling rmtree() explicitly, if we're
on a btrfs filesystem, we'll call btrfs subvolume delete which is
much faster than rm.
Always rerun build if Format=none and don't remove previous outputs
Let's always rerun the build if Format=none. Also, since we know
Format=none won't touch any of the outputs we know about, let's keep
the existing outputs intact. This allows using Format=none to rerun
the build script without removing the existing output (e.g. directory
or disk image).
We'll be able to make use of this in mkosi-kernel to rebuild the kernel
modules without removing the disk image produced in a previous step.
We also simplify check_outputs() to only check the main output and not
the auxiliary outputs.
Add mirror to package cache key if one is specified
On Arch Linux, pacman seems to only check if the sync db on the
mirror is newer than the one available locally, which breaks when
using e.g. the archive where the sync db is older by definition.
Let's add any specified mirror to the default package cache dir key
to make sure that a different cache is used for explicitly specified
mirrors.
If not set in Environment=, we default to the user's home directory.
Let's instead use GNUPGHOME from the user's environment if it is set
before falling back to the user's home directory.
Michael Ferrari [Mon, 1 Jul 2024 09:10:36 +0000 (11:10 +0200)]
Support decompressing tar archives
This switches `extract_tar` to read the file itself instead of from
stdin to be able to auto-detect the compression method used.
BSD tar can auto-detect and decompress from stdin, but GNU tar only
auto-detects the compression method and notifies the user, but refuses
to run when not explicitly specifying the format on the command line.
Daan De Meyer [Sat, 29 Jun 2024 09:16:47 +0000 (11:16 +0200)]
Fix mirror paths for centos/fedora family of distributions.
We assumed that fedora would always be in the fedora subdirectory
of the mirror and that centos would always be in the centos-stream
subdirectory of the mirror but this is not guaranteed to be true
(see https://pagure.io/centos-infra/issue/1430).
Let's fix this by not always appending centos-stream/ or fedora/ to
the given mirror so the user can determine whether to include this
or not.
This is a breaking change but making sure all mirrors can be used
regardless of layout seems more important in this case.
For EPEL we do make a bigger assumption on the mirror layout since
we're forced to as we don't have a mechanism to specify more than one
mirror. We also allow users to override the epel mirror via an
environment variable.
mkosi-initrd: provide a separate mkosi-initrd script
Extract the basic functionality implemented on the kernel-install plugin into a
separate script. This allows to simplify the initrd/UKI build auto-filling
arguments of the `mkosi` call, and also auto-include user/distro configuration
from `/{etc,usr/lib}/mkosi-initrd`.
NamedTuple is an outdated solution… Make a normal dataclass to
match other places. Dataclasses also have nicer string representation.
Also let's not make the class nested. This doesn't matter terribly here,
but it makes the code unusual. Rename the type to "AptRepository"
to match RpmRepository.
Dataclasses are the more modern approach, with better string representation and
less hacks. A NamedTuple is also a tuple, which is rather surprising when we
don't use that.
Daan De Meyer [Wed, 26 Jun 2024 10:04:19 +0000 (12:04 +0200)]
Deal with systemd split packages added in Debian testing
systemd-repart and systemd-cryptsetup were moved to subpackages in
Debian testing. Let's make sure we account for that in mkosi-tools
and mkosi-initrd.
Daan De Meyer [Mon, 24 Jun 2024 11:37:29 +0000 (13:37 +0200)]
Fix sdmagic check on CentOS
systemd-stub on CentOS has misaligned PE sections causing us to read
a bunch of null bytes from the sdmagic section. Let's treat this case
as not finding a stub version to fix the CI builds.
Luca Boccassi [Sun, 16 Jun 2024 22:34:02 +0000 (23:34 +0100)]
qemu/vmspawn: check for an uncompressed kernel too
On some architecture/distributions (eg: ppc64el and riscv64 on Debian/Ubuntu)
the kernel is shipped uncompressed, as vmlinux. If vmlinuz cannot be found,
try looking for vmlinux.
Daan De Meyer [Thu, 13 Jun 2024 20:46:42 +0000 (22:46 +0200)]
centos: Fix GPG key search logic
Let's only look for the release key of the release we're building for
and add support for searching for the SHA256 key which is used by centos
stream 10.
We can't use the symlinked names because those don't exist on centos.org/keys.
Daan De Meyer [Thu, 13 Jun 2024 19:38:39 +0000 (21:38 +0200)]
centos: Change local rpm GPG key location
Let's look for the one suffixed with the release number. This doesn't
change behavior for c9s as this is a symlink to the file we looked for
previously but will fix our behavior for c10s which uses a different key.
Michael Ferrari [Sun, 9 Jun 2024 10:34:38 +0000 (12:34 +0200)]
Set default output name for `mkosi-tools`
This should allow one to invoke `mkosi --directory "" --include mkosi-tools`
in the project root to create a tools tree that is automatically
detected and used in subsequent invocations.
Daan De Meyer [Fri, 7 Jun 2024 18:01:59 +0000 (20:01 +0200)]
action: Disable apparmor completely
These are ephemeral CI machines with full root access without password,
there's really no point in running apparmor in the first place so instead
of trying to work around broken apparmor policies, just disable apparmor
completely.
Daan De Meyer [Thu, 6 Jun 2024 13:35:07 +0000 (15:35 +0200)]
mkosi-initrd: Include more modules
- systemd logs an error if x_tables.ko is missing so let's include it.
- For cryptsetup, let's make sure we include all crypto modules so it
always has everything it needs
Daan De Meyer [Wed, 5 Jun 2024 07:59:34 +0000 (09:59 +0200)]
opensuse: Add glibc-gconv-modules-extra to default tools tree
This package was split off from glibc but mtools does not yet have
a required dependency on it (see
https://bugzilla.opensuse.org/show_bug.cgi?id=1225982) so for now
let's install it ourselves.
Daan De Meyer [Wed, 5 Jun 2024 07:15:50 +0000 (09:15 +0200)]
Make sure we don't fail when there is no sdmagic section in sd-stub
The sdmagic section in sd-stub was only introduced in systemd 250.
Since Ubuntu Jammy ships systemd 249, let's make sure we gracefully
handle the scenario where we can't find the sdmagic section.
Daan De Meyer [Wed, 5 Jun 2024 07:29:50 +0000 (09:29 +0200)]
dnf: Enable versionlock plugin by default
Let's allow users to make use of the versionlock plugin by enabling
it by default. To make sure it doesn't fail, we write a noop
configuration that makes the plugin do nothing at all which users
can then override using PackageManagerTrees=.
Michael Ferrari [Tue, 4 Jun 2024 11:26:00 +0000 (13:26 +0200)]
Add `UnifiedKernelImageFormat=` with specifiers
This can be used to control the name to use for the UKI during image
generation. Special `&` specifiers can be used to include kernel
specific information in the filename.
This is useful for the `systemd-sysupdate` case, as you can set this to
`%i_%v` to use a format that can be parse by its configuration. The
current format used includes both a roothash as well as the kernel
version which both can't be matched by sysupdate.