Daan De Meyer [Thu, 24 Aug 2023 10:25:47 +0000 (12:25 +0200)]
Drop "first assignment wins" logic
From experience in the systemd repository's usage of presets, we've
learned that we want to have fixed values for certain settings for
presets that cannot be overridden by either the CLI options or by
global config. Good examples are that the Format= of a base image
should always be "directory" and the Format= of an initrd image
should always be "cpio" or that Bootable= should always be "no" for
both the base image and the initrd image and their list of packages
should not be affected by any packages specified on the CLI.
The issue is that with "first assignment wins" logic, we need to add
an explicit "override" mechanism which almost all settings in these
presets would then use to make sure they can't be changed by CLI
options. This seems rather backwards, and is a good indication that
any settings configured in config should not be overridden by settings
set on the CLI.
Even disregarding usage of presets, any existing mkosi config will almost
certainly not be written to expect arbitrary changes in the config due
to options set on the CLI.
Also, it's currently not entirely trivial to set default values for
presets from the global config, because any values set in the global
config cannot be overridden anymore by presets. By not doing "first
assignment wins" logic, this becomes trivial as the global config can
simply set a default value and it can be overridden by presets.
Of course by removing "first assignment wins" logic, we do introduce
the issue again that "first assignment wins" solves in the first place,
which is that it becomes possible to assign a value to a setting, match
on that value and then change the setting later. We acknowledge this by
documenting it in the manual. Also, in some cases, this is exactly what
you want. For example, if you want to use a Fedora rawhide tools tree to
build CentOS 8 images, you have to first match on distribution == centos
and then set Distribution=fedora afterwards for the tools tree preset, so
this actually makes perfect sense in some cases.
While this is technically a compat break, it will only be noticed by users
doing advanced stuff with mkosi, which AFAIK does not exist yet outside of
the systemd repo. In fact even the systemd repo was not broken by this change,
so we should be OK with making it, given the large benefits we get out of it.
This commit also simplifies the interfaces of the parser and matching callbacks
to not take the namespace as an argument anymore, but to simply take the existing
value as an argument instead.
Daan De Meyer [Fri, 18 Aug 2023 11:58:08 +0000 (13:58 +0200)]
Add grub EFI support
Note that we only generate the necessary menu entries for the grub
configuration to chainload into our generated UKIs, we do not yet
install grub for EFI ourselves as this is a distribution specific
mess that we still need to figure out. On Fedora, because the
shim and grub2-efi packages install directly to /boot which we
redirect to /efi, this is sufficient to boot with grub on EFI by
simply installing the shim and grub2-efi packages.
For other distributions, a post install or finalize script will be
necessary that installs grub (and optionally shim) to the correct
locations in the ESP.
Daan De Meyer [Mon, 14 Aug 2023 11:52:29 +0000 (13:52 +0200)]
Add back BIOS support using grub
Let's add back support for booting on BIOS using grub. This comes
with the following limitations:
- grub does not support UKIs on BIOS, so we set up the individual
components instead
- grub cannot search partitions by PARTUUID, so we're forced to have
it find the ESP by partition number instead.
We opt to generate grub.cfg ourselves instead of relying on grub-mkconfig.
grub-mkconfig is basically like kernel-install but for grub configuration,
it has a ton of distro specific cruft that we want to ignore, so we simply
don't use it and generate the grub configuration ourselves.
To allow for unprivileged installation of grub, we can't use grub-install
as it insists on opening the root device and probing its filesystem, which
isn't possible unprivileged. Instead, we run grub-mkimage and grub-bios-setup
ourselves, and manually copy the required files to the ESP.
We use the ESP to store the kernels, initrds and grub config. In the event
that grub adds support for UKIs on BIOS in the future, we can simply modify
the generated grub configuration to use our generated UKIs instead.
Daan De Meyer [Thu, 17 Aug 2023 18:54:36 +0000 (20:54 +0200)]
Unset TMPDIR in apivfs_cmd()
dnf seems to have issues with this as well so let's unset TMPDIR
whenever we set up APIVFS as that's a good indication something is
going to chroot and we should unset TMPDIR.
Daan De Meyer [Thu, 17 Aug 2023 12:40:23 +0000 (14:40 +0200)]
Reset terminal cursor if tput is available
When interrupting dnf5 or other programs, they sometimes mess up
the terminal cursor. So let's make sure we reset the cursor state
when we exit mkosi if tput is available.
Daan De Meyer [Thu, 17 Aug 2023 08:15:00 +0000 (10:15 +0200)]
Set --no-variables when we invoke bootctl
We already don't install variables because we're operating on a
root directory, but if we set --no-variables we don't get warnings
from bootctl about it.
Daan De Meyer [Tue, 15 Aug 2023 08:03:13 +0000 (10:03 +0200)]
Reword systemd version requirement a bit
We should use wording that still makes sense when reading documentation
from the distro packaged version of mkosi as well. Let's also mention
that the systemd requirement is only for bootable disk images.
Daan De Meyer [Sun, 13 Aug 2023 17:40:01 +0000 (19:40 +0200)]
Rework make_image_output()
Instead of returning a tuple containing all the bits we're interested
in, let's just return a typed version of the repart json output and
calculate what we need based on that in install_unified_kernel(). We
also move the split paths logic into make_image().
Daan De Meyer [Thu, 10 Aug 2023 10:31:22 +0000 (12:31 +0200)]
Make sure the private tmpfs in bwrap() doesn't hide workspace
The workspace might be in /tmp so we need to make sure we mount it
first before we mount the workspace so that the workspace is on top
of the private tmpfs.
make mkosi docs from resources available via the documentation verb
This allows, especially when running different versions of mkosi, to always
have the right documentation on hand no matter how that version of mkosi was
installed.
Daan De Meyer [Tue, 8 Aug 2023 13:57:14 +0000 (15:57 +0200)]
Introduce preset dependencies
Instead of building presets in alphanumerical order, let's introduce
a proper concept of dependencies. Dependencies are configured with
the new "Dependencies=" option in the new "[Preset]" section. All
presets configured with "Dependencies=" are built before the current
preset.
We drop the alphanumerical preset in favor of explicit dependencies.
Daan De Meyer [Wed, 9 Aug 2023 06:48:29 +0000 (08:48 +0200)]
Don't reverse list option values found in the same option
Items from earlier settings should take precedence over items from
later settings, but that doesn't mean we should reverse items found
in the same setting.
Daan De Meyer [Tue, 8 Aug 2023 11:38:39 +0000 (13:38 +0200)]
Install extra packages for centos/alma/rocky to fix CI failure
This increases the size of the generated image a bit which makes
sure repart calculates a minimal partition size for the XFS
filesystem so that populating the partition doesn't run out of space.