Daan De Meyer [Mon, 11 Dec 2023 17:51:28 +0000 (18:51 +0100)]
tests: Test "none" output format as well
Let's build an image with "none" as well. There won't be any output,
but we can at least test that nothing breaks when specifying "none"
as the output format.
Also apply the "integration" marker to the entire file while we're
at it.
Daan De Meyer [Mon, 11 Dec 2023 09:17:19 +0000 (10:17 +0100)]
Add RepartOffline= option
Instead of auto-detecting all cases where --offline=no has to be
used with systemd-repart, let's allow configuring it via an option
so that if we discover any new cases, users can easily disable
offline mode themselves.
Daan De Meyer [Sun, 10 Dec 2023 21:09:55 +0000 (22:09 +0100)]
qemu: Remove --posix-acl and add --no-announce-submounts to virtiofsd
--posix-acl causes an error from virtiofsd saying the client doesn't
support this feature. We also get a warning about announcing submounts
not being supported so let's make sure we disable both features to
avoid these warnings/errors.
Daan De Meyer [Sun, 10 Dec 2023 18:39:05 +0000 (19:39 +0100)]
Use grub's search.file module instead of hardcoding partition numbers
We can tell grub to search for the first partition containing a
/grub/grub.cfg file. This still isn't ideal, but it's better than
hardcoding partition numbers.
Daan De Meyer [Sun, 10 Dec 2023 16:06:51 +0000 (17:06 +0100)]
Install kernels to /boot
If users want to use XBOOTLDR partitions, then we have to put the
kernels in a separate location from the ESP stuff. Currently we put
everything in /efi when building the image, which means that users
don't have a way to specify that the kernels should be put in an
XBOOTLDR partition.
Let's fix this by installing kernels to /boot so that users can
populate an XBOOTLDR partition by simply using CopyFiles=/boot:/
in a repart xbootldr partition definition.
Daan De Meyer [Sun, 10 Dec 2023 13:24:04 +0000 (14:24 +0100)]
Use kernel-install entry token if available
Let's try and look for the kernel-install entry token if
kernel-install v255 or newer is available. This makes us more
compatible with package manager upgrades as we'll use the same
directory that kernel-install will look for when invoked by a
package manager.
Daan De Meyer [Sun, 10 Dec 2023 11:48:15 +0000 (12:48 +0100)]
Add QemuFirmwareVariables=
This allows configuring the path to the qemu firmware variables to
use. This allows users to configure their own variables using
https://pypi.org/project/virt-firmware/ before passing it to mkosi.
This also fixes a bug where we didn't pass the variables file to
qemu if the firmware doesn't support secure boot.
Daan De Meyer [Sun, 10 Dec 2023 12:17:45 +0000 (13:17 +0100)]
Allow specifying minimum mkosi version
Currently, users often get a confusing message about some property
not existing when they try to use an older version of mkosi to build
a configuration that requires a newer version. Let's improve on this
by allowing configurations to declare the minimum version required to
build the configuration.
Daan De Meyer [Sun, 10 Dec 2023 10:31:23 +0000 (11:31 +0100)]
arch: Unconditionally assume initramfs package is installed
This doesn't prevent installing individual initramfs generators so
let's always set it and require users to specify mkinitcpio or dracut
if they really need one of these.
Daan De Meyer [Sat, 9 Dec 2023 11:51:46 +0000 (12:51 +0100)]
Relax qemu check in uncaught_exception_handler()
qemu binaries can have many different names (qemu, qemu-kvm,
qemu-system-xxx, ...) so let's not log a stacktrace for any binary
that starts with "qemu".
Daan De Meyer [Fri, 8 Dec 2023 15:53:51 +0000 (16:53 +0100)]
tests: Make more robust on distros with recent systemd
Let's make use of the fact that we can communicate the exit status
from VMs on recent versions of systemd. Even when it fails to run
qemu will often exit with exit status 0 so let's make our successful
exit status 123 and check for that instead of 0.
Let's also rework how we have systemd log. Instead of using
default_standard_output, let's have journald forward all logs to the
console. While we're at, let's also add some general useful debugging
kernel command line arguments that we also use in the systemd repository.
Daan De Meyer [Sat, 9 Dec 2023 11:59:16 +0000 (12:59 +0100)]
Revert "mkosi: include binutils in the packages for building"
Now that we pass the kernel version explicitly to ukify, we
don't need to have binutils installed anymore as ukify only uses
readelf to autodetect the kernel version if it wasn't supplied
explicitly by the user.
Daan De Meyer [Fri, 8 Dec 2023 12:52:01 +0000 (13:52 +0100)]
Use mkosi-initrd to build the default initrd
Instead of maintaining a separate default initrd, let's use
mkosi-initrd for the default initrd. This provides users with a more
batteries included initrd by default and saves us from having to
maintain two separate initrd definitions.
Daan De Meyer [Thu, 7 Dec 2023 22:11:19 +0000 (23:11 +0100)]
Add support for installing shim
Unfortunately shim is a necessary evil that we have to support. We
add a new option that allows choosing either a signed version, an
unsigned version or none at all (the default).
We also stop redirecting /boot/efi to /efi so that /efi is our pristine
directory for populating the ESP whereas /boot is unclaimed wasteland
free for package managers to write all kinds of stuff to.
Josef Bacik [Fri, 8 Dec 2023 22:28:21 +0000 (22:28 +0000)]
mkosi: include binutils in the packages for building
On aarch64 the dependencies are different than x86 and we don't end up
with binutils getting picked up, which means readelf isn't available for
systemd-ukify when using mkosi-kernel on aarch64. Explicitly add
bintuils to the list of packages, this allows mkosi-kernel to work
properly on an aarch64 machine.
Joerg Behrmann [Thu, 7 Dec 2023 18:09:34 +0000 (19:09 +0100)]
Move off of the deprecated importlib.resources API
Python 3.9 brought a new importlib.resources API and deprecated the old
one. This introduces a small shim to use the part of the APi that guarantees a
Path object, thus making our usage of this just pathlike.
Daan De Meyer [Thu, 7 Dec 2023 11:48:53 +0000 (12:48 +0100)]
Improve exception handling for subprocess.run()
Instead of having subprocess.run() kill child processes on exceptions
with SIGKILL, let's have it use SIGTERM instead. Because this is not
configurable, we have to override signal.SIGKILL with signal.SIGTERM
before we call subprocess.run().
Daan De Meyer [Thu, 7 Dec 2023 10:21:30 +0000 (11:21 +0100)]
Run image builds in a fork again
This solves two problems:
- When not using a tools tree, we can run qemu outside of the user
namespace which means that we don't need to pass fds to /dev/kvm and
/dev/vhost-vsock to keep things working unprivileged
- The vmspawn verb we're about to introduce will not be able to run
properly inside a user namespace, so we need to make sure we're not
inside a user namespace after the image build.
Compared to our original implementation of this way back with exception
propagation, this time we opt to do things differently by doing all
exception handling and logging inside the fork to avoid having to
propagate exceptions. This makes the overall implementation a lot
simpler.
We can also run the other verbs outside of the user namespace as long
as we're not using a tools tree. Because we want to keep support for
using a tools tree with all verbs, we keep support for running them
inside a user namespace as well. Because we already use INVOKING_USER
everywhere, this actually turns out to require very little changes. We
only need to make sure when starting virtiofsd that we unshare the user
namespace ourselves if we're not uid mapping.
Daan De Meyer [Wed, 6 Dec 2023 14:04:54 +0000 (15:04 +0100)]
Add sysext, confext and portable support
Wwe also write the extension-release file in case of sysexts and
confexts and make sure we skip a bunch of our automatic features
when building extension images or enabling the Overlay= option
as in these cases many of our automatic features are undesireable.
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.