Daan De Meyer [Wed, 6 Dec 2023 08:52:59 +0000 (09:52 +0100)]
mkosi-initrd: Apply cryptsetup creds to all instances of systemd-cryptsetup@.service
This follows the suggestion made in https://github.com/systemd/systemd/pull/30309
to apply "cryptsetup.*" credentials to all instances of
systemd-cryptsetup@.service instead of only to
systemd-cryptsetup@root.service.
Daan De Meyer [Mon, 4 Dec 2023 07:12:51 +0000 (08:12 +0100)]
mkosi-initrd: Port tests from old repository
This commit ports some of the tests from
https://github.com/systemd/mkosi-initrd/blob/main/.github/workflows/build-fedora.sh
over.
The LUKS test is modified to generate the LUKS root partition using
repart instead of doing it manually. For the LVM tests we're forced
to do it manually as systemd-repart doesn't support setting up LVM
(and probably never will).
We also add an initrd size test so we notice when initrds grow due
to distribution packaging changes.
Daan De Meyer [Tue, 5 Dec 2023 09:28:31 +0000 (10:28 +0100)]
Fix nspawn settings
When --machine= is used, nspawn looks for a settings file named after
the machine so we have to make sure to copy to the right location.
While we're at it, let's also stop considering the nspawn settings
an output artifact, since this means we have to build the image to
apply new settings. Instead, let's copy the settings when running
the image and remove the copied file again afterwards. This means
that new settings are applied immediately instead of only after a
rebuild.
Daan De Meyer [Mon, 4 Dec 2023 12:14:43 +0000 (13:14 +0100)]
Temporarily default to debian unstable for builtin image
Booting off virtiofs only works properly from systemd v255 onwards
when virtiofs and virtio_pci are not builtin to the kernel so let's
default to unstable for now which has systemd v255.
Daan De Meyer [Mon, 4 Dec 2023 07:10:29 +0000 (08:10 +0100)]
mkosi-initrd: Enable cryptsetup.* credentials for systemd-gpt-auto-generator
systemd-cryptsetup will read credentials in the "cryptsetup" namespace but
none of the generated service units import credentials from that namespace
yet. Let's add a dropin to have systemd-cryptsetup@root.service (generated
by systemd-gpt-auto-generator) load these credentials by default so that we
can use them in integration tests.
Upstream PR in systemd related to this: https://github.com/systemd/systemd/pull/30309
Daan De Meyer [Sun, 3 Dec 2023 11:17:33 +0000 (12:17 +0100)]
mkosi-initrd: Default to cleaning package manager metadata
Various package managers are pulled in as dependencies of core
system software (dpkg by dash on Debian, rpm by kmod via
suse-module-tools on opensuse) so let's default to always cleaning
package manager metadata even if the package manager is installed.
We still allow disabling it as having the package manager metadata
available is useful when debugging dependencies and why specific
packages are installed in the initrd.
Daan De Meyer [Sat, 2 Dec 2023 09:04:55 +0000 (10:04 +0100)]
Configure rpm _install_langs if locale is configured
If the _install_langs macro is defined, rpm will only install locale
data corresponding to the locales in _install_langs. If Locale= is
set and macros.lang doesn't exist already, let's configure it ourselves
with _install_langs to save on disk space.
Daan De Meyer [Sat, 2 Dec 2023 08:34:05 +0000 (09:34 +0100)]
Allow configuring rpm in package manager trees
Up until now, we've been unconditionally using the rpm configuration
from the host system. Unfortunately we can't entirely get rid of this
as rpm doesn't operate with an empty configuration and the configuration
is tightly coupled to the rpm version.
However, let's at least make sure we don't use any rpm configuration from
/etc and let's allow users to add extra rpm configuration themselves using
package manager trees.
By using $RPM_CONFIGDIR, we can configure where rpm looks for its main
configuration. We allow users to configure various rpm configuration in their
package manager trees and then copy over any missing files from the host
afterwards.
Because the /etc config directories are hardcoded in rpm, we have to resort
to mounting an empty directory on top of /etc/rpm if it exists.
Daan De Meyer [Sat, 2 Dec 2023 08:31:21 +0000 (09:31 +0100)]
Add clobber argument for copy_tree()
Let's allow specifying that copy_tree() should not overwrite
existing files. Because of a messy backwards incompatible change
in coreutils v9.2, we're forced to use a different option depending
on the cp version.
Daan De Meyer [Fri, 1 Dec 2023 15:24:04 +0000 (16:24 +0100)]
mkosi-initrd: Only include core + host's loaded modules and firmware
The initramfs produced by mkosi-initrd's kernel-install plugin is only
intended to be used on the host system that's building it. Let's take
advantage of that and only include the currently loaded modules and
firmware in the initramfs to cut down the size.
For safety reasons we always include some core modules regardless of
whether they're loaded on the host or not.
Daan De Meyer [Fri, 1 Dec 2023 15:18:25 +0000 (16:18 +0100)]
Add KernelModulesIncludeHost= and KernelModulesInitrdIncludeHost=
These look at /proc/modules and add all modules in there to the list
of modules to keep. Useful when building images intended to be used on
the host system only.
This commit also optimizes filter_kernel_modules() which was previously
O(n)^2.
Daan De Meyer [Fri, 1 Dec 2023 10:22:21 +0000 (11:22 +0100)]
Move integration tests into python
Instead of vendor locking ourselves to Github Actions, let's move
the integration tests into python so we can run them locally and
on other CI systems.
We opt to use unittest style test cases so that we can have a
configurable base class that can be used for various integration
tests. Unfortunately, I haven't found a nice and type safe way to
make pytest fixtures configurable so we opt for unittest instead.
Note that while we use the subTest() feature of unittest, pytest
still considers test_boot() a single test because it doesn't support
this particular feature of unittest. Ideally we switch our test runner
to something else in the future which does support the subTest() feature.
We always run steps that can run unprivileged without privileges even
if we're running as root so that tests can be run locally with root
privileges without ending up with a bunch of files owned by root
afterwards.
Daan De Meyer [Wed, 29 Nov 2023 20:39:42 +0000 (21:39 +0100)]
Fix ImageId= docs
- We don't patch it into partition labels anymore
- We already patch os-release ourselves so let's not use it as an
example of what to do with $IMAGE_ID for users.
Joerg Behrmann [Tue, 21 Nov 2023 09:47:41 +0000 (10:47 +0100)]
util: make name and home of INVOKING_USER methods that cache their results
At test time, e.g. during reproducible builds, usernames are not guaranteed to
be resolvable, because NSS is deliberately broken. Hence, only try to resolve
either only if needed and cache the result, so it stays the same across
invocations.
This unfortunately can no longer be achieved by combining @classmethod with
@property, since the combination, which had only been allowed since Python 3.9,
was deprecated again in Python 3.11.
Use the main tool name in error when tool is not found
We would say that we cannnot find /usr/lib/systemd/ukify, which
is somewhat confusing, since we're looking for ukify in $PATH
first, and only for /usr/lib/systemd/ukify as a fallback.
This also avoids a second which call on the results of a which call.
Daan De Meyer [Tue, 28 Nov 2023 10:39:04 +0000 (11:39 +0100)]
Add microcode support
Let's make sure we add early CPIO initrds containing microcode when
building bootable images. To make early loading of microcode work, an
uncompressed initrd has to be prepended to the list of initrds containing
the microcode at a canonical location.
Daan De Meyer [Tue, 28 Nov 2023 09:38:01 +0000 (10:38 +0100)]
Do not trigger bwrap's max arg limit when running modinfo
We might potentially pass a lot of modules at once to modinfo which
could trigger bwrap's max argument limit so make sure to chunk things
up to avoid hitting the limit.
autologin: use a helper method to reduce boilerplate
I kept the generated option strings exactly the same. In some cases we
put the baud before the device name or placeholder, and in other cases in
the opposite order, but maybe there's some reason for this.
The unit file is changed to use just 'aggety' instead of the full path,
and the leading whitespace is dropped. Both things should have no effect,
but make the resulting file nicer to read.
Luca Boccassi [Sat, 18 Nov 2023 18:15:44 +0000 (18:15 +0000)]
ci: enable jammy-proposed-updates to get new libsolv
rawhide and tumbleweed now compress repodata with zstd which cannot be
handled by libsolv in jammy. Enable jammy-proposed to get new version
with the fix.
Joerg Behrmann [Thu, 16 Nov 2023 10:22:20 +0000 (11:22 +0100)]
Rename Compression.zst to Compression.zstd
But also leave a fallback Compression.zst with value "zstd" as a fallback in
case anybody used that. To test this we also change the construction of
Compression instances in test_config.py to use __get_item__ instead of __new__,
since that actually supports construction via the value and is also the one
actually used in config.py
Joerg Behrmann [Wed, 15 Nov 2023 11:23:36 +0000 (12:23 +0100)]
Post-release NEWS updates
This moves a few things further up to make them more prominent, like the
renaming of presets and the addition of profiles and also adds a the new esp
output format and a note about resolv.conf now needing WithNetwork=true to be
mapped during script runtime.
This is always a bit subjective, but I find a NEWS file much easier to read if
it's thematically organized. I think support for a new distro is important, so
put that first, then new verbs and options, then new configuration features,
and then all the other smaller changes.