Daan De Meyer [Sat, 16 Dec 2023 19:31:01 +0000 (20:31 +0100)]
ci: Drop rocky, alma and rhel-ubi
The next commit is going to add a second dimension to the test
matrix which will dramatically introduce the number of CI jobs.
Let's keep things manageable by dropping rhel-ubi, alma and rocky
which should be covered by the centos job already.
Daan De Meyer [Mon, 18 Dec 2023 13:32:31 +0000 (14:32 +0100)]
mkosi-initrd: Drop explicit CompressOutput=yes
This allows the compression passed by mkosi or the default compression
to be used instead. Note that the default is to compress the initrd, so
this doesn't change anything.
Daan De Meyer [Sat, 16 Dec 2023 23:01:56 +0000 (00:01 +0100)]
opensuse: Use curl to fetch repomd.xml
urllib.request.urlopen() means we're responsible for catching all
the exceptions and showing a proper error message to the user.
Instead, let's just shell out to curl to fetch the file which can
translate any errors into user friendly error messages for us.
Daan De Meyer [Sat, 16 Dec 2023 21:58:21 +0000 (22:58 +0100)]
Split out rpm.py and hook up rpm logic with zypper as well
We have a bunch of rpm related logic that's required when using
dnf and zypper so let's split out rpm.py and hook up everything in
both dnf and zypper.
Daan De Meyer [Sat, 16 Dec 2023 21:35:53 +0000 (22:35 +0100)]
Mount over various other directories as well if needed
On Opensuse the openssl certificates are stored in
/var/lib/ca-certificates so let's make sure we mount this directory
from the tools tree into the host as well.
The pacman keyring is stored in /etc/pacman.d/gnupg so we mount over
/etc/pacman.d as well if needed.
Daan De Meyer [Fri, 15 Dec 2023 09:55:23 +0000 (10:55 +0100)]
Use mkosi.key/mkosi.crt for SSH authentication
Instead of using the user's SSH certificate and key, let's use the
X509 certificate and private key generated by 'mkosi genkey' instead.
This saves us from having to rely on ssh-agent to get the public key
or doing otherwise complicated logic to try and find the public and
private key. We also avoid always needing a separate public/private
key just for SSH by automatically converting the X509 certificate to
a SSH public key.
Daan De Meyer [Fri, 15 Dec 2023 13:23:22 +0000 (14:23 +0100)]
Support multiple [Match] sections
Instead of considering all match sections part of the same match,
let's consider each [Match] section on its own. This allows doing
multiple independent triggers, such as:
Daan De Meyer [Fri, 15 Dec 2023 13:20:49 +0000 (14:20 +0100)]
Build initrd if Bootable=auto
If building a bootable image is not explicitly disabled and we
don't split out an initrd from a UKI because the dependencies are
not installed or we're on the wrong architecture, let's still build
an initrd so that booting with qemu direct kernel boot still works.
Daan De Meyer [Thu, 14 Dec 2023 15:30:02 +0000 (16:30 +0100)]
Fix install_tree()
Let's make sure that all the skeleton, extra and package manager
trees we get have absolute targets. That allows us to stop using
with_prefix() when installing these trees, which means we pass
target=None instead of target="/" which makes install_tree do the
right thing.
Daan De Meyer [Thu, 14 Dec 2023 14:54:27 +0000 (15:54 +0100)]
Stop using the tools tree for the ssh verb
This allows us to run ssh out of the user namespace which means we
can get rid of the passwd hack to make ssh work. ssh is widespread
enough that we can require users to install it on the host machine
instead of using the tools tree.
Daan De Meyer [Wed, 13 Dec 2023 09:14:25 +0000 (10:14 +0100)]
kernel-install: Use host's package manager configuration and repos
Let's make sure we use the host's package manager configuration and
repositories in the kernel-install plugin. The initrd we produce
should be as compatible with the host as we can make it and making
sure we use the same packages that the host uses is a good step in
achieving that.
Daan De Meyer [Tue, 12 Dec 2023 11:26:45 +0000 (12:26 +0100)]
mkosi-initrd: Rewrite kernel-install plugin in python and support UKIs
There's really no point for the kernel-install plugin to be in bash,
so let's rewrite it in python. While we're at it, let's also support
running as a UKI generator.
Malte Poll [Mon, 11 Dec 2023 10:40:18 +0000 (11:40 +0100)]
make_cpio: sort files used as cpio input
Pathlib's glob functions return files in the order used by the filesystem.
This may differ between implementations and configuration (file system, locale).
For better reproducibility, the file list should be sorted.
Daan De Meyer [Tue, 12 Dec 2023 11:22:44 +0000 (12:22 +0100)]
Save kernel image and stub when building UKI/ESP images
When building a UKI image, it's not unreasonable for users to not
want to ship the large vmlinuz kernel image file inside their UKI
initrd. However, because we process remove_files() before we build
the UKI, the kernel image might already have been removed by the
time we build the UKI. To avoid this problem, let's save the UKI
(and the stub while we're at it) in the workspace directory before
we process file removals.
Let's also only process cmdline files from the rootfs when we're
building a bootable image and ignore them if we're building a UKI.
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.