Daan De Meyer [Thu, 23 Jan 2025 08:12:14 +0000 (09:12 +0100)]
Simplify crypto-policies copying
To make matters even more interesting, aside from a bunch of .txt
files in /usr/share/crypto-policies/DEFAULT, there's also the same
files in /usr/share/crypto-policies/back-ends/DEFAULT, but they do
have the .config extension there, so lets simplify the logic by
copying from that location.
Daan De Meyer [Wed, 22 Jan 2025 16:11:56 +0000 (17:11 +0100)]
Add support for FirmwareVariables=microsoft-mok
This new setting will use firmware variables with enrolled microsoft
keys and extend them with the required MOK variables to trust the
user's secure boot key/certificate.
This is the first time this appears in the partcular boot's logs and we always
ignore it and carry on. Let's sidestep checking whether it is this particular
error by masking the unit.
A possible reason might be that it gets pulled in by udev if a test using LVM
runs first.
Daan De Meyer [Wed, 22 Jan 2025 16:07:09 +0000 (17:07 +0100)]
Don't insist on pre-signed EFI binaries when ShimBootloader == signed
The whole point of shim is that you can use a presigned shim with
locally signed EFI binaries if the local key is enrolled in MOK, so
don't insist on presigned EFI binaries when a signed shim is requested.
Instead the new "signed" variants of the Bootloader= option can be used
to still force installation of presigned EFI binaries.
Daan De Meyer [Tue, 21 Jan 2025 22:33:37 +0000 (23:33 +0100)]
tests: Remove privilege dropping for image builds
This just does not work reliably at all. We change uid/gid but keep
all the environment variables which is just a recipe for issues. Let's
enforce running everything as root if one wants to run the tests that
require root privileges.
Daan De Meyer [Tue, 21 Jan 2025 22:47:57 +0000 (23:47 +0100)]
Move uid check back to have_cache()
We moved this to reuse_cache() before the introduction of mkosi-sandbox
because we would change uids during execution. Now that we don't do that
anymore, we can move the check back to have_cache().
Daan De Meyer [Tue, 21 Jan 2025 19:18:15 +0000 (20:18 +0100)]
tests: Skip booting from directory in user namespace with single user
We need newuidmap/newgidmap to be able to boot from a directory which
can't ever work in a user namespace with a single user so skip the
test in that case.
Daan De Meyer [Tue, 21 Jan 2025 21:41:06 +0000 (22:41 +0100)]
action: Only install package managers and debian-keyring
Instead, let's recommend users to use the default tools tree to get
their dependencies which is generally recommended as it reduces their
dependencies on what's installed on the host system.
Daan De Meyer [Tue, 21 Jan 2025 16:41:27 +0000 (17:41 +0100)]
mkosi-tools: Install systemd-ukify on Azure, CentOS and Fedora
systemd-ukify is not architecture dependant anymore so let's always
install it. It's also packaged in CentOS Stream and Azure Linux so
let's install it there as well.
Daan De Meyer [Tue, 21 Jan 2025 16:40:30 +0000 (17:40 +0100)]
mkosi-tools: Fix architecture condition
We need to match the architecture of the tools tree we're building,
not the host architecture. In practice these will always be the same
so this doesn't actually change behavior.
Daan De Meyer [Wed, 22 Jan 2025 11:32:35 +0000 (12:32 +0100)]
Make mkosi available inside mkosi sandbox via zipapp
Currently, mkosi has to be installed outside of /usr when using a
tools tree with mkosi sandbox to make it available inside mkosi
sandbox. Let's remove this restriction by packaging up the host's
mkosi as a zipapp and making the zipapp available in the sandbox.
Daan De Meyer [Wed, 22 Jan 2025 11:15:42 +0000 (12:15 +0100)]
Special case tools image in keyring_cache() and metadata_cache()
Similar to cache_tree_paths(), give the metadata and keyring cache
for the default tools tree a custom name to avoid conflicts with the
other image caches.
Daan De Meyer [Tue, 21 Jan 2025 21:21:38 +0000 (22:21 +0100)]
Rework crypto-policies again
Currently, we only write our own rpm-sequoia crypto policy if one
isn't provided by the tools tree. However, the centos stream 10 crypto
policy is restrictive enough that we can't build older centos releases
or opensuse images with it.
To fix this, let's switch things around again and go back to copying
the crypto policy from the tools tree into the sandbox tree and modifying
the rpm-sequoia policy to fit our needs. For mkosi sandbox, we do reuse
the crypto policies from the tools tree unmodified.
Note that we copy from /usr/share/crypto-policies/DEFAULT instead of
/etc/crypto-policies, as when using mkosi sandbox, we get
/etc/crypto-policies from the host which is full of symlink's to the host's
/usr, even if the tools tree might not be using crypto policies at all.
We also rename finalize_crypto_mounts() to finalize_certificate_mounts()
as it only handles certificates now.
Daan De Meyer [Tue, 21 Jan 2025 11:58:28 +0000 (12:58 +0100)]
Add support for pre-signed Bootloader variants without shim
Currently we only pick up pre-signed bootloader binaries if
ShimBootloader=signed is configured. Let's also add support for
installing pre-signed bootloader binaries without using shim.
Daan De Meyer [Mon, 20 Jan 2025 09:42:08 +0000 (10:42 +0100)]
Enforce that images with Overlay=yes only add files
Any extension images built with Overlay=yes should never override
files in the base image, so let's add some enforcement to make
sure that's the case by automatically removing files that already
exist in the base image.
Daan De Meyer [Sun, 19 Jan 2025 19:11:20 +0000 (20:11 +0100)]
Don't check for populated OS root if Format == none
Let's skip checking if the OS root is populated if Format == none
so that Format=none and Distribution=custom can be used to execute
arbitrary code in a build script without actually building an image.
Daan De Meyer [Sun, 19 Jan 2025 19:34:31 +0000 (20:34 +0100)]
Allow adding kernel modules in extension images
When building standalone extension images (without Overlay=yes),
let's process kernel modules but not run depmod. depmod produces a
single monolithic file which means we can't extend it from an
extension image without overriding the base file.
Daan De Meyer [Thu, 16 Jan 2025 23:07:07 +0000 (00:07 +0100)]
Add package manager back to the cache manifest
As detailed in the previous commit, it's important to cache the
package manager used in the cache manifest. If we don't, we'll end
up reusing the wrong metadata cache which won't have any metadata in
it for the new package manager.
Daan De Meyer [Thu, 16 Jan 2025 23:02:52 +0000 (00:02 +0100)]
Rebuild default tools tree before cleaning up other images
It turns out we have to put the used package manager in the cache
manifest as the metadata cache needs to be refreshed if the package
manager used changes, otherwise the metadata cache will be reused but
the new package manager won't actually be able to find any metadata
since the metadata cache contains metadata for another package manager.
To avoid running into all the problems we had previously trying to do
this, we have to make sure that the default tools tree is always available
whenever we run have_cache() on a (non-default tools tree) image, so that
the package manager we decide to use to build the image is always the same.
To achieve that, we make sure to rebuild the tools tree before doing checks
and cleaning up other images when doing a regular build. This means whenever
we call have_cache() the default tools tree will be available if it is used.
Daan De Meyer [Thu, 16 Jan 2025 21:42:23 +0000 (22:42 +0100)]
fedora: Use a lower repository metadata expire time for rawhide
Let's mimick Fedora's own rawhide repository configuration and use
a metadata expire time of 6h when building rawhide images so that
we don't end up keeping stale repository metadata around for too
long which will result in dnf being unable to find certain packages
as they will have been replaced by a newer version in rawhide already.
Daan De Meyer [Thu, 16 Jan 2025 13:53:16 +0000 (14:53 +0100)]
centos: Enable EPEL for c10s tools tree as well
Now that EPEL exists for c10s, let's enable it for the c10s tools
tree as EPEL has distribution-gpg-keys which is crucial to be able
to use c10s as a tools tree.