Before this would have the uid:gid of root in the uidmap space
The link is now created in the staging area first to make the change atomic,
so that the wrong uid:gid pair is never seen in the output directory
Malte Poll [Thu, 25 May 2023 09:53:47 +0000 (11:53 +0200)]
ukify: always sign kernel inside of uki if secure boot is enabled
This overrides the auto detection of ukify and always signs the kernel bevore embedding it in the uki (even if the kernel is already signed).
Rationale: When building Fedora 37 images, the Fedora provided kernel is signed with an expired key (id 2574709492).
I would like to add an additional signature with my own signing key to enable kexec and other features that require a correctly signed kernel image.
Co-authored-by: Otto Bittner <cobittner@posteo.net>
Daan De Meyer [Wed, 24 May 2023 12:33:49 +0000 (14:33 +0200)]
Firstboot improvements
- Merge --root-password-hashed and --root-password-file into
--root-password. If prefixed with hashed:, we treat it as a hashed
root password.
- When not building an initrd, also store corresponding credentials
in /usr/lib/credstore, so that the settings work even if only /usr
is shipped in the final image. We don't do this for initrds since
those generally ship with /etc populated.
- Drop setting of firstboot.hostname which isn't actually used by
systemd-firstboot
Daan De Meyer [Sun, 21 May 2023 15:08:51 +0000 (17:08 +0200)]
Make mkosi the foreground process again when child process finishes
We currently get "Job mkosi has stopped" when fetching running the
summary verb. Let's fix this by making sure we make mkosi the foreground
process again when we finish running a child process.
Daan De Meyer [Tue, 16 May 2023 09:16:28 +0000 (11:16 +0200)]
Various dnf fixes
- Put the logs in a subdirectory of the workspace
- Make sure we configure the persistdir to be inside the workspace
as well. Otherwise dnf5 tries to use the system directory which fails
with a permission error
- Use the non-compat dnf5 option names instead of the compat ones
Daan De Meyer [Mon, 15 May 2023 13:55:32 +0000 (15:55 +0200)]
Pass firstboot settings to generated initrd as well
It generally doesn't make sense to have these differ between the
initrd and the rootfs, so let's pass these settings through to the
initrd as well.
The only setting we don't pass through is the root shell as configuring
a different root shell might mean installing extra packages which might
be undesireable in the initrd.
Daan De Meyer [Thu, 11 May 2023 11:42:21 +0000 (13:42 +0200)]
Use /efi as the ESP path when building the image
We used to use /boot because kernel-install would hardcode it but since
we don't use kernel-install anymore, let's use /efi instead. This way,
if anyone wants to install grub, they can do so in /boot and package
/boot up as an XBOOTLDR partition.
Daan De Meyer [Thu, 11 May 2023 11:53:15 +0000 (13:53 +0200)]
ci: Simplify checks
Instead of mounting the filesystem and checking the contents of the
failed-services file, let's just shut down the machine with a non-zero
exit status if there are failed services. This works for both nspawn
and qemu now that we have the vsock notify socket set up.
Daan De Meyer [Thu, 11 May 2023 08:55:18 +0000 (10:55 +0200)]
action: Allow unprivileged access to kvm, vhost-vsock and vhost-net devices
These are restricted on Debian/Ubuntu but we want to allow running
unprivileged qemu so let's loosen the permissions on these devices
to make that possible.
Daan De Meyer [Thu, 11 May 2023 08:45:54 +0000 (10:45 +0200)]
Propagate systemd exit status from the VM
Let's make use of the new vmm.notify_socket credential to fetch
systemd's exit status from the VM and propagate it as our own exit
status, just like already happens automatically for containers with
systemd-nspawn.
Daan De Meyer [Tue, 9 May 2023 09:09:26 +0000 (11:09 +0200)]
Add some very basic cache invalidation
Let's compare the packages, build packages, repositories and the
contents of the prepare script. This doesn't cover everything but
should be sufficient to catch most changes without having to run
with "-ff".
Daan De Meyer [Tue, 9 May 2023 08:16:05 +0000 (10:16 +0200)]
Get rid of build_stuff()
The distinction between build_stuff() and build_image() is quite
arbitrary these days. build_stuff() used to build multiple images,
and build_image() would build a single image, but that's not the
case anymore, so let's merge build_stuff() into build_image().
Daan De Meyer [Tue, 9 May 2023 08:07:20 +0000 (10:07 +0200)]
Get rid of init_mount_namespace()
Let's just unshare the mount namespace as well as part of
become_root(). Also stop making every mount a slave mount, since
we don't really care about host mounts propagating into our mount
namespace.
Daan De Meyer [Sun, 7 May 2023 17:42:53 +0000 (19:42 +0200)]
Make KernelModulesInclude take priority over KernelModulesExclude=
If exclude takes priority over include, it becomes hard to exclude
directories of drivers except for a few. If include takes priority
over exclude, we can do stuff like exclude "drivers/gpu/*" and
include "drivers/gpu/nvidia" to only include nvidia drivers.
The current behavior easily be reproduced by adding exclude "*"
followed by include patterns.
Daan De Meyer [Sun, 7 May 2023 16:18:13 +0000 (18:18 +0200)]
Add KernelModulesInclude= and KernelModulesExclude=
These are like KernelModulesInitrdInclude= and
KernelModulesInitrdExclude= but they apply to the image itself
instead of to the kernel modules initrd.
The main use case is when using mkosi as an initramfs builder and
you want to exclude kernel modules from the initramfs but it can
also be useful when distros only ship large kernel packages that
you want to trim down.
Daan De Meyer [Sun, 7 May 2023 13:16:31 +0000 (15:16 +0200)]
arch: Always exclude initramfs generator if we're doing a bootable image
The current condition is wrong as we'll generate an initrd ourselves
if none are provided by the user, so update the condition to not install
initramfs generators unless generating a bootable image is explicitly
disabled.
Daan De Meyer [Sun, 7 May 2023 13:05:23 +0000 (15:05 +0200)]
Kernel modules initramfs improvements
- Use relative paths over full absolute paths
- Put all the firmware directories into the initramfs as well (just
the dirs, not all the firmware files)
- Return sets from resolve kernel modules function
- Operate on sorted lists of the sets to improve reproduciblity
- Split out filter_kernel_modules()
- Take builtin modules into account as well
- Use name field instead of filename from modinfo output
- Stop using joinpath() in favor of parentheses
Daan De Meyer [Sun, 7 May 2023 07:10:19 +0000 (09:10 +0200)]
Give disk images some extra free disk space when we boot them
truncate creates the extra disk space sparse so this doesn't affect
the host's disk usage. The extra disk space will have to be partitioned
to be usable inside the image though (but this is perfect for systemd's
use case as we want to partition the free space with systemd-repart).
Daan De Meyer [Sat, 6 May 2023 11:31:22 +0000 (13:31 +0200)]
Make key generation generic
Let's put generated keys in mkosi.key and mkosi.crt, and remove the
secure boot nomenclature from the key generation options. This allows
us to reuse the keys for other signing operations as well.
Daan De Meyer [Sat, 6 May 2023 11:17:43 +0000 (13:17 +0200)]
Reduce ESP default size to 512MB
Now that we compress the Debian kernel modules initramfs, we can
reduce the default ESP size to 512MB again as it's large enough to
fit the Debian initramfs even with all kernel modules included.
Daan De Meyer [Fri, 5 May 2023 14:15:41 +0000 (16:15 +0200)]
Kernel modules initrd improvements
- Let's compress the kernel modules initrd on Debian to at least
reduce the disk usage required for the initrd. Not required for other
distros since those compress their kernel modules already individually.
- Add option --kernel-modules-initrd to enable/disable usage of the
kernel modules initrd. Can be used to disable it if the main initrd
already contains the necessary kernel modules
- Add options --kernel-modules-initrd-include/exclude to allow
including/excluding the initrds to put in the kernel modules initrd
by regex patterns.
Daan De Meyer [Fri, 5 May 2023 09:02:34 +0000 (11:02 +0200)]
Drop man page from the repo
Let's just generate it on demand with pandoc when needed instead of
storing it in the repo. I initially pushed for putting in the repo
because the mkosi AUR package pulled in hundreds of Haskell dependencies
for pandoc when installing mkosi to build the manpage, but that's an
Arch issue and not something to solve in mkosi. Also, mkosi moved
from the AUR to the community repo these days so it's not an issue
on Arch anymore either.
Daan De Meyer [Thu, 4 May 2023 10:47:24 +0000 (12:47 +0200)]
Rework output related logic
- Let's store the output as a "base" name without any suffixes from
which we construct all other output paths.
- Let's not allow --output to be specified as a path anymore and
always put it in the configured output directory.
- Let's return all output paths as strings instead of paths. As
strings, we'll get typing errors if we try to use these as paths
without joining them with a directory first, which can be either the
output directory or the staging directory.
- Let's always create a symlink from the "base" name to the full
output path so it can be referred to regardless of the output
format, compression or image version that's used.
- Let's make sure we compress split partitions if requested
fedora: do not explicitly pull in filelists on F>=38
After the discussion in https://bugzilla.redhat.com/show_bug.cgi?id=2180842
glibc was updated to provide /sbin/ldconfig in F38 and rawhide. The
issue remains for only a few packages, and any that are frequently
installed are likely to be fixed quickly. So let's drop the work-around
for F>=38, which allows a smaller download to be made.
Daan De Meyer [Wed, 3 May 2023 12:15:22 +0000 (14:15 +0200)]
opensuse: Use dnf instead of zypper
Let's reduce the number of package managers we use by using dnf to
build opensuse images.
The only caveat is that extra GPG keys are listed in repomd.xml for
the opensuse repos, so we have to download that file and parse it to
figure out the extra keys that we have to write to the repo configs.
Ensure output is compatible with systemd-sysupdate
When using `systemd-sysupdate` it is wise to use split artifacts and to
compress artifacts. These changes ensure that split artifacts are compressed
and the file paths are stored in the checksum.
Please note that `systemd-sysupdate` expects a checksum name of `SHA256SUMS`
and uses the contained file names to determine which files to download. The
compression suffix is also used to determine how to decompress files.
Additional CI checks have been added to make sure no regressions in output
format occur.