Introduce CACHE_UID/CACHE_GID for use in the cache manifest
The INVOKING_USER uid and gid are potentially modified in become_root(),
causing cache mismatches depending on whether have_cache() is called
inside or outside of the user namespace.
Let's instead introduce two new constants resolved at module load time
which won't change.
Use the builtin constants for --include= to include the default initrd
and tools tree so that parse_config() makes the scripts executable for
us instead of having to do it ourselves.
opensuse: Don't install distribution-release by default
distribution-release is a virtual package that is satisfied by
multiple packages. By installing it by default in the first transaction
we can't override it anymore later. Let's fix the issue by not explicitly
installing distribution-release.
To make sure openSUSE-release is pulled in by default to satisfy
distribution-release, we install patterns-base-minimal_base which has
a Suggests dependency on openSUSE-release.
In systemd, we want to have a default set of kernel command line
arguments and override a few of them via the command line. Introduce
--append so that we can specify settings via the command line that
are parsed after all configuration have files have been parsed to
make this possible.
This setting mounts the build sources and build directory into a
booted container/virtual machine in the same location that they were
mounted to do the build.
This helps both with making gdb more useful in the container as the
sources will be available for use by gdb without having to do any
source directory mapping. It also helps with doing incremental builds
inside the container.
Make sure the build directory is owner by root (in the userns)
The build directory will (unless mkosi-as-caller is used) contain
files owned by root (in the userns). To make sure the correct uidmap
is used when using this directory in RuntimeTrees=, let's make sure
the directory is owned by root (in the userns).
Translate paths to SELinux policy files to /buildroot
The setfiles call was broken by 62cee058cb116684294831c4cab20924dde93e45
because the binary policy and file context files were still using the
host path in the run arguments.
Fixes the error `Error opening
/home/user/.cache/mkosi/mkosi-workspaceb5nodee6/root/etc/selinux/targeted/policy/policy.33:
No such file or directory`
Check in spawn() whether the command we're trying to run is available
Currently, if we try to run a command within a sandbox, we fail with
an unclear error if the program is not installed. This is because our
FileNotFoundError exception handler is never triggered as the program
we run via subprocess is almost always "sh" or "bwrap". Let's make sure
we also check for the actual program we're going to run in the sandbox
and show a clear error if it's not available.
Pass environment the usual way when we're invoking the package manager
Let's only use "env" in the package manager scripts we make available
when running user scripts. If we're invoking the package manager ourselves,
pass the environment in the usual way.
In some setups, there might not be any essential packages, so make
sure we always install base-files so that the base directory layout
is always populated.
Instead of passing namespace and defaults everywhere, have every
nested function operate on the function global object and simply reset
the objects to the copy we took after we finish parsing a single image
definition.
Daan De Meyer [Sun, 31 Mar 2024 17:54:22 +0000 (19:54 +0200)]
Add ForwardJournal= to enable log forwarding of VMs and containers
In systemd v256, journald will support forwarding to systemd-journal-remote
via the new journal.forward_to_socket credential. Let's expose this
functionality via a new ForwardJournal= setting, which specifies a path to
which logs should be forwarded.
Daan De Meyer [Wed, 27 Mar 2024 22:48:36 +0000 (23:48 +0100)]
Support mkosi ssh for multiple running instances of the same image
Let's add a stopgap solution until systemd-machined supports everything
we need. We maintain a super basic JSON state file in the runtime directory
that is used to map a machine name to the corresponding SSH proxy command.
We also store the path to the ssh key in there so that mkosi ssh can be
run from every directory.
The new Machine= option allows selecting the machine name to use. Unless
set explicitly, we also use the machine name as the hostname for the machine.
Daan De Meyer [Wed, 27 Mar 2024 13:43:58 +0000 (14:43 +0100)]
Add CleanScripts=
Clean scripts can be used to remove any outputs that mkosi doesn't
know about, e.g. packages built in mkosi build scripts and copied
to the output directory.
Daan De Meyer [Wed, 27 Mar 2024 10:25:08 +0000 (11:25 +0100)]
Extension image fixes
- Insist on /usr/lib/os-release existing and read only from it instead
of /etc/os-release
- Don't fail if /usr/lib/os-release doesn't exist when building a sysext
or confext.
- Skip more operations when building sysext/confext images
Daan De Meyer [Tue, 26 Mar 2024 11:17:51 +0000 (12:17 +0100)]
Switch back to debian testing
unstable breaks too much to be useful for CI. To keep CI green, we
stop installing pacman-package-manager in the default images and disable
debian tools tree in CI.