Daan De Meyer [Wed, 26 Feb 2025 11:14:38 +0000 (12:14 +0100)]
Introduce --run-build-scripts (-R) to always run build scripts
Currently we run "mkosi -t none" in systemd and mkosi-kernel to run
the build script(s) without rebuilding the entire image. Using the
"none" output format for this purpose is a hack. It also breaks when
using History=yes as running mkosi -t none will change the output
format in the history after which running mkosi qemu will fail saying
it can't boot the "none" output format.
Let's introduce a --run-build-scripts argument which will make us always
run the build scripts regardless of whether the image has already been
built or not. At the same time, remove various behaviors from the "none"
format that were solely added to enable the hack of using it to run build
scripts without rebuilding the image:
- Clean up outputs from the previous build when the "none" output format
is used
Daan De Meyer [Tue, 25 Feb 2025 17:46:16 +0000 (18:46 +0100)]
Enable Hyperscale rpm COW plugin
The CentOS Hyperscale SIG provides rpm/dnf plugins to enable rpm
COW which drastically speeds up image builds so let's ship the
necessary logic to make use of it when building images with the
Hyperscale experimental repositories.
Luca Boccassi [Tue, 25 Feb 2025 00:11:46 +0000 (00:11 +0000)]
mkosi-obs: sign bootloaders in ESPs
If there are bootloaders in the ESP(s), sign them too. Useful to
ensure everything is signed also with the certificate in the project
where the image is built.
Daan De Meyer [Sun, 23 Feb 2025 15:20:53 +0000 (16:20 +0100)]
Specify --suppress-sync when running package managers
Package managers tend to make sure of sync() and friends to ensure
that any files they write are actually written to disk. This is
important when a package manager is used to do system package upgrades,
but is unnecessary when using package managers to build OS images. So
let's make sync() and friends a noop when we invoke package managers
Daan De Meyer [Fri, 21 Feb 2025 09:57:39 +0000 (10:57 +0100)]
Reduce the number of filesystems we remount noexec/nosuid/nodev when root
For mkosi-initrd, /etc might very well contain executable scripts which
we should allow to run, so let's only mount /boot and /efi nodev/nosuid/noexec.
Philip Molloy [Thu, 20 Feb 2025 13:49:26 +0000 (14:49 +0100)]
README: Reference EXAMPLES and mkosi documentation
Generally, examples are a great way to get started with a new tool.
Additionally, there does not appear to be formal getting started
documentation for mkosi.
Daan De Meyer [Wed, 19 Feb 2025 14:21:18 +0000 (15:21 +0100)]
Clean up default tools tree package lists
- util-linux is not needed anymore since we do mounts ourselves now
- dpkg is pulled in by apt on arch and we don't list it explicitly elsewhere
- glibc-gconv-modules-extra should be pulled in by something else on opensuse by now
- python3-cryptography is only required on ubuntu, rest already has a dependency on
it in systemd-ukify or is already on systemd v257 which doesn't need it anymore
- libarchive-tools seems like a leftover that isn't installed anywhere else
Daan De Meyer [Wed, 19 Feb 2025 11:39:06 +0000 (12:39 +0100)]
mkosi-tools: Split off misc, package-manager and runtime profiles
Let's make the dependencies verb a little more flexible by splitting
off various profiles in mkosi-tools, the misc, package-manager and
runtime profiles. The misc profile contains all the useful tools we
install to make sure they're available in scripts. The package manager
contains non-native package managers and related tools. The runtime
profile contains all the tools required to boot images. The regular
configuration now only includes the tools required to build native images
with mkosi.
The default tools tree still includes both the misc, package-manager and
runtime profiles by default but the list of profiles can be changed with
the new ToolsTreeProfiles= setting. The dependencies verb includes neither
profile, but we now allow passing arbitrary settings to the dependency verb
as arguments so that packages from additional profiles can be requested if
needed.
Russell Bunch [Tue, 18 Feb 2025 16:58:52 +0000 (10:58 -0600)]
Search for underscores in `systemd-stub`
Building raw disk images of RHEL 9 x86-64 are failing with:
```
...‣ Unable to determine systemd-stub version, found '#### LoaderInfo: systemd-stub 252-46.el9_5.2 ####'
```
Changes the regex for `systemd-stub` to include underscores for RHEL95.
Daan De Meyer [Tue, 18 Feb 2025 10:06:43 +0000 (11:06 +0100)]
run: Wait for child process in try block in spawn()
If we only wait in finally block then any keyboard interrupt
triggered during the wait will leave the child process alive and
won't wait for it to exit. Let's make sure this doesn't happen by
waiting in the try block as well.
Daan De Meyer [Tue, 18 Feb 2025 09:44:11 +0000 (10:44 +0100)]
Drop boot counting support
Setting up boot counting for the initial UKI in an image does not
make sense as there's nothing to fall back to. The existing interface
where we pick up the number of tries from a file in /etc inside the
image was also rather bad so let's get rid of the boot counting
specifier.
Daan De Meyer [Sat, 15 Feb 2025 21:58:04 +0000 (22:58 +0100)]
Make sure we always delete workspace / "root" as a subvolume
Currently, we delete it as a subvolume if the build succeeds but not
if the build fails. Let's handle the deletion in setup_workspace() so
we delete it as a subvolume both on success and on failure.
Daan De Meyer [Fri, 14 Feb 2025 12:39:48 +0000 (13:39 +0100)]
Make Linux= support delayed specifiers
In mkosi-kernel, I want to add the following:
```
Linux=&b/kernel/arch/x86_64/boot/bzImage
```
So that I can run `mkosi -t none` to rebuild the kernel image and
`mkosi qemu` to boot into it. To make this work, let's add support
for a delayed specifier to Linux= that expands to the finalized
build directory.
Daan De Meyer [Thu, 13 Feb 2025 23:34:36 +0000 (00:34 +0100)]
Add BuildKey= and CacheKey= settings
Let's give users more control over how many different cache and
build subdirectories we maintain by introducing CacheKey= and
BuildKey= with support for delayed specifiers.
Daan De Meyer [Thu, 13 Feb 2025 21:23:41 +0000 (22:23 +0100)]
Move load_environment() into finalize_environment() method of Config
Let's stop showing all derived environment variables values in the
summary and let's stop passing them to the default tools and initrd
images since they'll be derived again there anyway.
Daan De Meyer [Thu, 13 Feb 2025 19:13:18 +0000 (20:13 +0100)]
docs: Various fixes
- Make sure we suffix all long CLI options with '='
- Make sure whenever we use a boolean option that we pass an argument
- Make sure we prefix with '--' whenever we pass extra arguments
Daan De Meyer [Thu, 13 Feb 2025 09:14:32 +0000 (10:14 +0100)]
Force ssh to use bash to run the ProxyCommand
We only have bash installed in the tools tree and by default ssh
will try to use the user's shell to execute the proxy command which
might not be available so force it use bash.
Daan De Meyer [Wed, 12 Feb 2025 09:49:59 +0000 (10:49 +0100)]
Require delimiting extra options for invoked commands with '--'
This is one of the biggest footguns when using mkosi so let's break
compat and fix it. Any options that should be passed to the command
invoked by mkosi when using various verbs should be delimited from
regular options now using '--'.
Daan De Meyer [Tue, 11 Feb 2025 14:58:38 +0000 (15:58 +0100)]
run: Simplify spawn()
Let's reduce the nesting by stopping usage of Popen() as a context
manager. It's __exit__() method doesn't handle anything important that
we don't already handle ourselves. Let's also only handle
FileNotFoundError when spawning the process but not after yielding.
Finally, get rid of the failed() nested function as it only has one
remaining caller.
Daan De Meyer [Tue, 11 Feb 2025 14:48:29 +0000 (15:48 +0100)]
mkosi-sandbox: Implement --pack-fds
This allows us to move the file descriptor packing logic from spawn()
to mkosi-sandbox. The main advantage here is that we can pass file
descriptors now without necessarily packing them together, which we now
only do for systemd-journal-remote which requires it.