Daan De Meyer [Tue, 28 Jan 2025 19:47:30 +0000 (20:47 +0100)]
Don't call have_cache() in reuse_cache()
By the time reuse_cache() is called, we've already cleaned up old
cached images if needed, so just check if they still exist and reuse
them if they do.
Daan De Meyer [Tue, 28 Jan 2025 19:18:36 +0000 (20:18 +0100)]
Replace check_uid with a "tools" image check in have_cache()
We have access to the config object in have_cache() and this argument
is specifically intended to be used whenever we pass the default tools
tree to have_cache(), so let's just do the check based on config.image
in have_cache() itself.
Martin Hundebøll [Mon, 27 Jan 2025 14:45:01 +0000 (15:45 +0100)]
Fix verity signature check in case keys are configured
The repart json output includes the architecture in the partiton type
string, so the same must be included when checking for a verity
signature partition.
Daan De Meyer [Mon, 27 Jan 2025 14:05:45 +0000 (15:05 +0100)]
mkosi-tools: Drop fish and zsh
These are a bit too exquisite to have in the default tools tree and
we don't start a shell in mkosi-sandbox by default anymore, so let's
stick to just having bash in the default tools tree.
zypper allows to use the `$releasever` variable in repo URLs (see zypper(8) man
page). When mkosi uses zypper repos from the host instead of the default ones,
this variable needs to be replaced with the host's `VERSION_ID`, otherwise repo
URLs are incomplete.
Daan De Meyer [Mon, 27 Jan 2025 10:10:13 +0000 (11:10 +0100)]
Log command line for abnormal signals
If we're not killed by SIGINT or SIGTERM, let's log the command line
as in this scenario it's very likely the process we were running crashed
with SIGABRT or SIGSEGV.
Daan De Meyer [Sat, 25 Jan 2025 21:28:21 +0000 (22:28 +0100)]
mkosi-initrd: Add two more modules
Three more generic modules that are needed in the initrd.
- mxm-wmi is a standard for switchable laptop graphics
- usb-storage is obviously for USB storage devices
- partport (https://docs.kernel.org/admin-guide/parport.html)
seems generic enough that we should include it in the initrd.
Daan De Meyer [Fri, 24 Jan 2025 12:04:45 +0000 (13:04 +0100)]
Make sure all config paths are absolute
With all the chdir() we do while parsing configuration, let's make
sure our config paths are absolute so that they don't suddenly
change meaning when we chdir().
Daan De Meyer [Thu, 23 Jan 2025 20:19:38 +0000 (21:19 +0100)]
Use resource_path() to access files in our own module
__file__ doesn't work if mkosi is packaged up as a zipapp, let's
use resource_path() which is specifically intended to solve this
problem and works regardless of whether we're in a zipapp or not.
Daan De Meyer [Thu, 23 Jan 2025 17:02:28 +0000 (18:02 +0100)]
Do not check uid in have_cache() for default tools tree
If the tools tree has a cache, it's complete, we're not going to
modify it anymore, and it doesn't matter whether the files in it
are owned by root or an unprivileged user, we'll be able to execute
binaries from it regardless, so let's not check the ownership when
we invoke have_cache() on it.
Daan De Meyer [Thu, 23 Jan 2025 14:27:48 +0000 (15:27 +0100)]
Create zipapp for mkosi sandbox like we do in generate-zipapp.sh
Otherwise we run into ModuleNotFoundError trying to run a zipapp
created from a packaged version of mkosi. This is the same
workaround that's already used in generate-zipapp.sh.
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.