Daan De Meyer [Wed, 18 Oct 2023 10:00:53 +0000 (12:00 +0200)]
Beef up bundled images
Let's beef up the bundled images with all the packages from the tools
trees where applicable so that we can run easily run mkosi from these
images if needed for testing on different distributions.
Daan De Meyer [Wed, 18 Oct 2023 10:01:26 +0000 (12:01 +0200)]
Use with in spawn()
If we yield the Popen, we yield a context manager from a context
manager, which becomes hard to follow, since we'll only enter the
outer context manager, and not the inner Popen context manager. To
make things simpler, let's enter the Popen context manager in
spawn() itself.
Daan De Meyer [Wed, 18 Oct 2023 07:30:11 +0000 (09:30 +0200)]
Reword readme
Let's reduce the amount of detail we put in the readme and list the
installation methods in order of how easy-to-use they are. Let's also
only recommend using the distribution's package if it's sufficiently
recent.
Daan De Meyer [Tue, 17 Oct 2023 20:42:20 +0000 (22:42 +0200)]
Rework qemu device support checks
Let's implement an available() method on the QemuDeviceNode enum
and move the checks from load_config() to run_qemu() so they don't
impede showing the summary or other verbs.
Let's also prefer using the file descriptor as a check whether the
feature is available in run_qemu() instead of calling the available()
method, as by the time we get to run_qemu() the available() method
might return a different result.
Malte Poll [Tue, 17 Oct 2023 08:37:16 +0000 (10:37 +0200)]
make_tar: do not emit extended PAX headers for atime, ctime and mtime
The use of the --xattrs flag implies PAX headers (--format=pax).
In this mode, the tar will record atime, ctime and mtime as PAX headers (in addition to the usual USTAR header).
Removing the headers makes the output reproducible.
See also: https://www.gnu.org/software/tar/manual/html_node/PAX-keywords.html
Daan De Meyer [Fri, 13 Oct 2023 11:24:44 +0000 (13:24 +0200)]
Open qemu device nodes before unsharing user namespace
Where possible, we should open the qemu device nodes before we unshare
the user namespace as this might not be possible anymore after unsharing
the user namespace because we might lose access to the kvm group.
Currently this is only possible for /dev/vhost-vsock. I've opened
https://gitlab.com/qemu-project/qemu/-/issues/1936 to hopefully make
it work for /dev/kvm as well.
This is the default in the pacman.conf arch ships (https://gitlab.archlinux.org/archlinux/packaging/packages/pacman/-/blob/main/pacman.conf?ref_type=heads#L42)
and allows to build AUR packages in build scripts and installing them in
the final image.
Daan De Meyer [Thu, 12 Oct 2023 12:34:12 +0000 (14:34 +0200)]
Run qemu as the invoking user again
This commit also reworks InvokingUser to calculate all its members
on module import (when we haven't yet unshared the user namespace).
become_root() is also changed to modify the InvokingUser object
instead of returning the new uid, gid. Finally, we stop passing
around uid, gid everywhere and just use the InvokingUser object
directly as a singleton.
We also stop dropping privileges in mkosi itself. Instead, we prefer
running ssh, qemu and the embedded web server unprivileged. This
allows us to get rid of the logic to not unmount the last tools tree
as we will now always still have enough privileges to do so.
We also start passing file descriptors to swtpm and virtiofsd to avoid
race conditions where the socket hasn't been created yet before we
pass it to qemu or before we try to chown it.
Daan De Meyer [Fri, 13 Oct 2023 07:54:39 +0000 (09:54 +0200)]
Add WithRecommends=
While this can already be configured using dropins. The concept of
recommended packages seems widespread enough that we can provide an
option to enable/disable it via the configuration file.
Do not remount build root as ro in build chroot
The PR #1970 added an additional volatile overlay to the buildroot, which
currently can only be used from the host, i.e. without mkosi-chroot.
Once mkosi-chroot is run, the build overlay is readonly again.
Fixes https://github.com/systemd/mkosi/issues/1974.
Daan De Meyer [Wed, 11 Oct 2023 11:33:00 +0000 (13:33 +0200)]
Mount volatile overlay when running build scripts
When building multiple projects, it might be needed to make the
header files produced by an earlier build available to later builds.
Let's make this possible by not making the root directory read-only
but instead mounting a writable overlay on top of it so that all
changes made while running the build scripts are thrown away at the
end.
Daan De Meyer [Wed, 11 Oct 2023 09:27:30 +0000 (11:27 +0200)]
Run scripts with ".chroot" extension inside the image
Our current approach to running scripts inside the image is only
really applicable to shell scripts. Let's make it easier to run
scripts written in arbitrary languages inside the image by running
scripts with the ".chroot" extension inside the image.
Daan De Meyer [Tue, 10 Oct 2023 09:48:01 +0000 (11:48 +0200)]
Add RHEL support
To make RHEL work, we have to look up the necessary certificates and
add them to the generated repo files. This requires the image build to
be done from a system with a RHEL subscription.
Daan De Meyer [Tue, 10 Oct 2023 12:02:46 +0000 (14:02 +0200)]
Get rid of config_default_mirror()
The only advantage of having it in the config object is that we can
show it in the summary. If we're fine with just showing "default"
instead, we can inline the default mirror into the installer classes,
which is important for the next commit.
Daan De Meyer [Wed, 4 Oct 2023 19:02:10 +0000 (21:02 +0200)]
Don't leak cwd into MkosiConfig
Storing Path.cwd() in MkosiConfig makes it complicated to figure
out if a MkosiConfig instance is equal to MkosiConfig.default() as
that one executes after changing directory to a temporary directory,
so let's remove our default factories for the output and workspace
directory and add two methods on the MkosiConfig class instead that
replicate the functionality.
Daan De Meyer [Wed, 4 Oct 2023 11:30:19 +0000 (13:30 +0200)]
Parse setting paths before parsing main config file
Currently, paths either configure default values or append to a
list (When path_default is False, it's always a list based setting).
When paths are configuring default values, it makes more sense for
default values set in the mkosi.conf file to override path based
default values.
When appending to a list, (e.g. ExtraTrees=), it makes more sense
for the trees configured in the mkosi.conf to come after the tree
from the path (mkosi.extra).
Both these goals are achieved by parsing the path based values before
parsing the main mkosi.conf file.
Daan De Meyer [Wed, 4 Oct 2023 08:46:39 +0000 (10:46 +0200)]
Stop explicitly setting distribution in tests
We now default to "custom" when we can't figure out the host
distribution instead of failing so let's stop explicitly setting
the distribution in tests.
Joerg Behrmann [Wed, 4 Oct 2023 07:52:24 +0000 (09:52 +0200)]
config: factor out settings_lookup_by* and match_lookup from parse_config
All three (settings_lookup_by_name, settings_lookup_by_dest, and match_lookup)
only repackage global variables. Moving them outside makes them usable in other
places and only calculates them once instead of on every invocation of
parse_config.
json: add alternative default constructors to MkosiArgs and MkosiConfig
These can be used to get a default MkosiArgs/MkosiConfig just have if mkosi had
been called in an empty directory with no cmdline without adding defaults to
the attributes and allowing instances of MkosiArgs/MkosiConfig to be made with
missing keys.
- reformat overly long lines
- remove typing.Type in favour of type
- import Iterablefrom collections.abc instead of typing
- compare singletons with is
- don't use "ambiguous variable name: l"
Daan De Meyer [Tue, 3 Oct 2023 08:08:41 +0000 (10:08 +0200)]
Always set the ttyS0 credentials
Even when booting with GUI, we might still have a serial terminal,
so let's always set the serial terminal specific size credentials
as these don't affect the GUI terminals at all.
Daan De Meyer [Mon, 2 Oct 2023 08:24:19 +0000 (10:24 +0200)]
Only add console=ttyS0 and tty sizes when QemuGui= is disabled
With console=ttyS0, we don't get any boot logs when running qemu
in GUI mode. The tty sizes don't matter either when booting in GUI
mode as Linux can figure it out itself in that scenario.
Daan De Meyer [Sun, 1 Oct 2023 18:20:12 +0000 (20:20 +0200)]
Add RuntimeSize= setting
Currently we unconditionally grow disk images to 8G before booting
them in systemd-nspawn or qemu. Let's do better here by making the
size configurable and not growing the disk images by default.
We also move format_bytes() to config.py as most other formatting
functions are located there.
Instead, let's show individual tools tree packages in the summary.
This makes things a bit more consistent as we don't show default
initrd presets in the summary either (and making that happen is no
trivial task so we opt to do the reverse and not show default tools
trees either).
We also add a table to the documentation showing which packages are
in the default tools tree for which distributions.