]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
19 months agoUse the directory mkosi was invoked in as the default for BuildSources= 2262/head
Daan De Meyer [Tue, 9 Jan 2024 19:22:59 +0000 (20:22 +0100)] 
Use the directory mkosi was invoked in as the default for BuildSources=

While parsing config, we use chdir(). Also, when a BuildSources=
match is found, BuildSources= is initialized to its default value
which is Path.cwd(). However, we want the default value to be the
top level directory that mkosi was invoked in, not the current working
directory that we happen to be in while parsing configuration. Let's
fix this by using the directory mkosi was invoked in instead of Path.cwd().

19 months agoMount in local mirror if it is provided.
Daan De Meyer [Tue, 9 Jan 2024 18:57:16 +0000 (19:57 +0100)] 
Mount in local mirror if it is provided.

19 months agoMount BuildSources= when executing package managers
Daan De Meyer [Tue, 9 Jan 2024 18:48:44 +0000 (19:48 +0100)] 
Mount BuildSources= when executing package managers

Users might have local packages which need to be mounted into the
sandbox as well. Let's make this possible by using BuildSources=.

19 months agoNEWS: reword a sentence and add punctuation
Zbigniew Jędrzejewski-Szmek [Tue, 9 Jan 2024 15:30:54 +0000 (16:30 +0100)] 
NEWS: reword a sentence and add punctuation

19 months agoFix typos in manpage
Luca Boccassi [Tue, 9 Jan 2024 15:35:24 +0000 (15:35 +0000)] 
Fix typos in manpage

19 months agoRelease 20 v20
Luca Boccassi [Tue, 9 Jan 2024 15:05:32 +0000 (15:05 +0000)] 
Release 20

19 months agoMake sure SYSTEMD_REPART_MKFS_OPTIONS_<fs> always applies
Daan De Meyer [Tue, 9 Jan 2024 12:12:37 +0000 (13:12 +0100)] 
Make sure SYSTEMD_REPART_MKFS_OPTIONS_<fs> always applies

Let's make sure we always use the extra mkfs options configured in
these environment variables.

We also stop filtering the environment we pass to systemd-repart.

19 months agoOnly run mount --make-rslave / if we didn't unshare a user namespace
Daan De Meyer [Tue, 9 Jan 2024 10:24:18 +0000 (11:24 +0100)] 
Only run mount --make-rslave / if we didn't unshare a user namespace

When unsharing a mount namespace in a different user namespace than
the parent mount namespace, all mounts are marked as slave by default
so we don't need to explicitly mark all of them as slave mounts.

19 months agoMerge pull request #2258 from DaanDeMeyer/policycoreutils
Jörg Behrmann [Tue, 9 Jan 2024 12:08:44 +0000 (13:08 +0100)] 
Merge pull request #2258 from DaanDeMeyer/policycoreutils

Add policycoreutils to tools trees

19 months agoAdd policycoreutils to tools trees 2258/head
Daan De Meyer [Tue, 9 Jan 2024 11:11:51 +0000 (12:11 +0100)] 
Add policycoreutils to tools trees

This package provides setfiles which is required for selinux
relabeling.

19 months agoAdd Ubuntu to tools trees docs packages list
Daan De Meyer [Tue, 9 Jan 2024 11:11:16 +0000 (12:11 +0100)] 
Add Ubuntu to tools trees docs packages list

19 months agoMerge pull request #2255 from DaanDeMeyer/simplify
Daan De Meyer [Tue, 9 Jan 2024 10:10:25 +0000 (11:10 +0100)] 
Merge pull request #2255 from DaanDeMeyer/simplify

Simplify apivfs_cmd() and chroot_cmd()

19 months agoUnshare IPC namespace when not in relaxed mode 2255/head
Daan De Meyer [Tue, 9 Jan 2024 09:26:03 +0000 (10:26 +0100)] 
Unshare IPC namespace when not in relaxed mode

Otherwise tests in the sandbox will think they have access to IPC
stuff when they actually don't.

Fixes #2256

19 months agoOnly set --security-label if the filesystem was relabeled
Daan De Meyer [Tue, 9 Jan 2024 07:49:00 +0000 (08:49 +0100)] 
Only set --security-label if the filesystem was relabeled

Otherwise we run into virtiofsd errors when operating on non relabeled
directories with --security-label enabled.

19 months agoSimplify apivfs_cmd() and chroot_cmd()
Daan De Meyer [Mon, 8 Jan 2024 22:31:37 +0000 (23:31 +0100)] 
Simplify apivfs_cmd() and chroot_cmd()

We move the setpgid logic to run(), avoiding the need to pass a tools
argument to chroot_cmd() and apivfs_cmd().

We also try to remove as much logic from these functions as possible.
Since we can't really assume that any logic we execute during the
function will still hold true in the sandbox, so it's best to delay
any logic execution until we're already in the sandbox (using the
--ro-bind-try options of bubblewrap).

We also rework the /etc/resolv.conf handling to simply make sure that
/run/systemd/resolve exists in the chroot since if /etc/resolv.conf
points to /run it'll almost certainly be to
/run/systemd/resolv/stub-resolv.conf.

19 months agoBind mount /work into chroot instead of individual files/directories
Daan De Meyer [Mon, 8 Jan 2024 19:01:33 +0000 (20:01 +0100)] 
Bind mount /work into chroot instead of individual files/directories

Same effect with less code.

19 months agoMerge pull request #2253 from DaanDeMeyer/fix
Daan De Meyer [Mon, 8 Jan 2024 18:40:26 +0000 (19:40 +0100)] 
Merge pull request #2253 from DaanDeMeyer/fix

More sandboxing fixes

19 months agoUse /work for host scripts as well 2253/head
Daan De Meyer [Mon, 8 Jan 2024 15:56:31 +0000 (16:56 +0100)] 
Use /work for host scripts as well

Now that everything runs sandboxed, /work is free to use for host
scripts as well. At the same time, let's stop unconditionally
mounting the current working directory when running build scripts.

To keep things working smoothly, we'll make mounting the current
working directory the default value for BuildSources= instead.

19 months agoReset default values when assigning the empty string to list setting
Daan De Meyer [Mon, 8 Jan 2024 16:38:11 +0000 (17:38 +0100)] 
Reset default values when assigning the empty string to list setting

For list based settings, it makes more sense for the empty string
to get rid of any default value as well.

19 months agoChange directory to the root directory in Mkosi.default()
Daan De Meyer [Mon, 8 Jan 2024 16:34:32 +0000 (17:34 +0100)] 
Change directory to the root directory in Mkosi.default()

Let's make sure subsequent invocations of Mkosi.default() return
the same value even if we default some settings to the current
working directory.

19 months agodebian: Use ?exact-name() instead of ?name()
Daan De Meyer [Mon, 8 Jan 2024 14:55:55 +0000 (15:55 +0100)] 
debian: Use ?exact-name() instead of ?name()

19 months agoAlways use /var/tmp in apivfs_cmd()
Daan De Meyer [Mon, 8 Jan 2024 14:54:26 +0000 (15:54 +0100)] 
Always use /var/tmp in apivfs_cmd()

apivfs_cmd() is always executed from within a sandbox so we can
just reuse the sandboxes /var/tmp.

19 months agoDon't use host's /var/tmp in sandbox
Daan De Meyer [Mon, 8 Jan 2024 14:52:15 +0000 (15:52 +0100)] 
Don't use host's /var/tmp in sandbox

Instead, use a subdirectory of the host's /var/tmp. Because we want
to limit the lifetime of this directory to the lifetime of the sandbox,
we use a shell command to create and remove the directory.

19 months agoPut tmpfs on /tmp in sandbox when not in relaxed mode
Daan De Meyer [Mon, 8 Jan 2024 14:21:01 +0000 (15:21 +0100)] 
Put tmpfs on /tmp in sandbox when not in relaxed mode

Let's sandbox more by not using the host's /tmp but instead putting
a fresh tmpfs on /tmp. We used the host's /tmp before because the
definitions could potentially be in the host's /tmp but now that we
mount everything in explicitly that isn't a problem anymore.

19 months agoMount cache directory before all other mounts
Daan De Meyer [Mon, 8 Jan 2024 14:00:14 +0000 (15:00 +0100)] 
Mount cache directory before all other mounts

The cache directory could potentially be /var so to avoid overriding
other mounts we have to mount it first.

19 months agoOnly mount package manager specific directories into sandbox
Daan De Meyer [Mon, 8 Jan 2024 13:51:48 +0000 (14:51 +0100)] 
Only mount package manager specific directories into sandbox

19 months agoDon't rely on /tmp being mounted into the sandbox
Daan De Meyer [Mon, 8 Jan 2024 13:49:04 +0000 (14:49 +0100)] 
Don't rely on /tmp being mounted into the sandbox

Let's not rely on /tmp implicitly being mounted in the sandbox.

19 months agoMerge pull request #2252 from DaanDeMeyer/ci
Daan De Meyer [Mon, 8 Jan 2024 13:47:29 +0000 (14:47 +0100)] 
Merge pull request #2252 from DaanDeMeyer/ci

ci: Enable Debian builds with tools trees again

19 months agoFix grub sandboxing 2252/head
Daan De Meyer [Mon, 8 Jan 2024 13:02:19 +0000 (14:02 +0100)] 
Fix grub sandboxing

19 months agoRemove a few TODOs and FIXMEs
Daan De Meyer [Mon, 8 Jan 2024 11:50:23 +0000 (12:50 +0100)] 
Remove a few TODOs and FIXMEs

19 months agodebian: Use testing again instead of unstable for default image
Daan De Meyer [Mon, 8 Jan 2024 11:43:27 +0000 (12:43 +0100)] 
debian: Use testing again instead of unstable for default image

systemd v255 is now in testing so let's use testing again instead
of unstable.

19 months agoci: Enable Debian builds with tools trees again
Daan De Meyer [Mon, 8 Jan 2024 11:41:35 +0000 (12:41 +0100)] 
ci: Enable Debian builds with tools trees again

The required fix in systemd is now in Debian so let's try enabling
these again.

19 months agoMount certificate directories into curl sandbox
Daan De Meyer [Mon, 8 Jan 2024 11:33:09 +0000 (12:33 +0100)] 
Mount certificate directories into curl sandbox

curl needs access to certificates to do its job so mount them in.

19 months agoMerge pull request #2250 from DaanDeMeyer/fix
Daan De Meyer [Mon, 8 Jan 2024 11:23:16 +0000 (12:23 +0100)] 
Merge pull request #2250 from DaanDeMeyer/fix

sandbox: Only mount host dirs that exist

19 months agoStart virtiofsd with --security-label 2250/head
Daan De Meyer [Mon, 8 Jan 2024 10:32:27 +0000 (11:32 +0100)] 
Start virtiofsd with --security-label

This makes sure selinux relabeling works as expected when booting
off virtiofs

19 months agoMount /sys, /run and /dev in relaxed mode as well
Daan De Meyer [Mon, 8 Jan 2024 10:32:14 +0000 (11:32 +0100)] 
Mount /sys, /run and /dev in relaxed mode as well

19 months agoOnly mount /etc/resolv.conf into sandbox if not in relaxed mode
Daan De Meyer [Mon, 8 Jan 2024 10:25:37 +0000 (11:25 +0100)] 
Only mount /etc/resolv.conf into sandbox if not in relaxed mode

In relaxed mode we already mount /etc so no need to mount resolv.conf
separately.

19 months agosandbox: Only mount host dirs that exist
Daan De Meyer [Mon, 8 Jan 2024 10:20:52 +0000 (11:20 +0100)] 
sandbox: Only mount host dirs that exist

19 months agoUpdate NEWS
Daan De Meyer [Mon, 8 Jan 2024 09:44:04 +0000 (10:44 +0100)] 
Update NEWS

19 months agoUse bubblewrap to set up the tools tree instead of doing it ourselves
Daan De Meyer [Tue, 2 Jan 2024 07:37:40 +0000 (08:37 +0100)] 
Use bubblewrap to set up the tools tree instead of doing it ourselves

The problem with overmounting the host's /usr (in a private mount
namespace) is that we have no control over the symlinks in the root
directory (/lib, /bin, /lib64) and if these symlinks don't match
between the host distribution and the tools tree distribution, all
kinds of weird breakage starts happening. For example, using Fedora
tools trees on Arch Linux is currently broken because /lib64 on Arch
Linux points to /usr/lib whereas on Fedora it points to /usr/lib64.

Because we can't (and shouldn't) modify the symlinks of the host's
root filesystem, we need to set up the tools tree in a sandbox that
we chroot into, so that we have full control over the rootfs of the
sandbox and can make sure the symlinks are correct. Luckily, we
already do just that with bubblewrap, except that currently we mount
the tools tree over /usr ourselves and then just carry that over into
the bubblewrap sandbox.

Instead, we stop mounting over the host's /usr ourselves and have
bubblewrap pick the right /usr itself. We also copy the symlinks from
the tools tree or the host if there is no tools tree.

Because we don't mount over the host's /usr anymore, we have to run
every tool that should come from the tools tree with bubblewrap now.
The side effect of this is that almost all of our tools now run
sandboxed. We also have to make use of find_binary() everywhere
instead of shutil.which() to make sure we look for binaries in the
tools tree when required. Various other codepaths that look into /usr
also have to be modified to look into the tools tree when needed.

Also, because we don't unshare the user namespace in the main mkosi
process anymore now, we can get rid of a lot of chown()'s in qemu.py
and opening the qemu device file descriptors can be moved into
run_qemu() itself.

We also don't have to make sure all python modules are loaded anymore
as the host's /usr is never overmounted so the required python modules
will be available for the entire runtime of the mkosi process.

Because virtiofsd is now executed with bubblewrap, we use bubblewrap
to set up the required uidmap instead of relying on virtiofsd to do it
with newuidmap/newgidmap. Note that this breaks RuntimeTrees= as
virtiofsd unconditionally tries to drop groups with setgroups() which
fails with EPERM in an unprivileged user namespace set up by bubblewrap.
This is fixed by https://gitlab.com/virtio-fs/virtiofsd/-/merge_requests/207
which is still awaiting review.

To make this work codewise, this commit renames the bwrap() function
to sandbox_cmd() (similar to chroot_cmd() and apivfs_cmd()) which now
returns a command line instead of executing the command itself. run()
is modified to take an extra "sandbox" arguments which is simply the
part of the full command that sets up the sandbox. Context and Config
both learn new sandbox() methods which set up the sandbox for each
object respectively (mostly by adding extra bind mounts).

Because almost every call to run() now takes a sandbox, this gives us
a lot of control over the individual environment for each tool we run.
We make use of this to restrict each tool we run to the minimal possible
sandbox that that tool needs to run. By specifically mounting in the
required paths for each tool we run, we also make sure these are always
available instead of relying that somewhere we mount a path that has the
input in it.

Because we allow passing arbitrary options to mkosi qemu, mkosi boot and
various other verbs, we run these verbs with a relaxed sandbox, where we
mount in most directories from the host. This means that whatever
directories users specify will be available.

In terms of CI, the extra sandboxing means that our previous approach of
building various systemd binaries from source and symlinking them to
/usr/bin doesn't work anymore. Instead, we opt to always use tools trees
and drop the host builds from the testing matrix. This also simplifies
and speeds up the github action as we don't have to compile systemd and
xfsprogs from source and we have to install fewer packages.

19 months agoMerge pull request #2246 from DaanDeMeyer/fixes
Daan De Meyer [Fri, 5 Jan 2024 18:47:15 +0000 (19:47 +0100)] 
Merge pull request #2246 from DaanDeMeyer/fixes

Various fixes and improvements

19 months agoAdd groupadd script 2246/head
Daan De Meyer [Fri, 5 Jan 2024 13:26:06 +0000 (14:26 +0100)] 
Add groupadd script

19 months agoaction: Print id output when setting up /dev/kvm and friends
Daan De Meyer [Fri, 5 Jan 2024 13:04:51 +0000 (14:04 +0100)] 
action: Print id output when setting up /dev/kvm and friends

Useful debugging information.

19 months agoDon't copy xattrs from mkosi.extra and friends
Daan De Meyer [Fri, 5 Jan 2024 13:01:26 +0000 (14:01 +0100)] 
Don't copy xattrs from mkosi.extra and friends

These directories and files might have selinux xattrs and such that
we don't want to end up in the image so let's make sure that we don't
copy xattrs from skeleton and extra trees.

19 months agoUse recognizable tag names for RuntimeTrees= mounts
Daan De Meyer [Thu, 4 Jan 2024 12:26:06 +0000 (13:26 +0100)] 
Use recognizable tag names for RuntimeTrees= mounts

This makes it easier to do the mount manually in images with systemd
older than v254.

19 months agoAdd RuntimeScratch= setting
Daan De Meyer [Thu, 4 Jan 2024 12:17:27 +0000 (13:17 +0100)] 
Add RuntimeScratch= setting

When booting output formats that reside almost entirely in memory
(initrd, UKI, ESP), doing any kind of write heavy operation in the
booted VM has a high chance of leading to OOM errors as all files
will be written in memory.

When booting disk images, unless one is using RuntimeSize=, one will
often run into disk space issues when writing lots of data.

When booting off virtiofs and doing write heavy operations, virtiofsd
can run out of file descriptors or become very slow.

To allow doing write heavy operations in all these scenarios, let's
add RuntimeScratch= which mounts extra scratch space to /var/tmp that
can be used for write heavy operations.

19 months agoUpdate qemu kvm device version
Daan De Meyer [Thu, 4 Jan 2024 13:17:21 +0000 (14:17 +0100)] 
Update qemu kvm device version

Turns out the required patch was not included in 8.3 but will be
included in 9.0.

19 months agoInstall tmux in default images
Daan De Meyer [Thu, 4 Jan 2024 13:06:09 +0000 (14:06 +0100)] 
Install tmux in default images

Helps with debugging

19 months agoRevert "Copy over kernel images from /boot for opensuse as well"
Daan De Meyer [Thu, 4 Jan 2024 18:45:33 +0000 (19:45 +0100)] 
Revert "Copy over kernel images from /boot for opensuse as well"

Opensuse leap is too old for us to support since it's still split
usr so let's revert this commit.

This reverts commit 36c63f3cd9de9196d57bc09ecfe2af8659eafd50.

19 months agoFix importlib usage
Daan De Meyer [Fri, 5 Jan 2024 08:23:55 +0000 (09:23 +0100)] 
Fix importlib usage
We have to use as_file() on the final path, not the module path.

Because as_file() only learned to support directories in python 3.12,
we backport the 3.12 implementation temporarily in mkosi itself.

Because as_file() does not apply the executable bit, we apply it
ourselves after parsing the config. This requires delaying the check
if scripts are executable to some later point so we can parse the
config without failing because scripts are not executable.

This fixes mkosi zipapps.

19 months agoCopy over kernel images from /boot for opensuse as well
Daan De Meyer [Thu, 4 Jan 2024 09:49:21 +0000 (10:49 +0100)] 
Copy over kernel images from /boot for opensuse as well

On Tumbleweed they're already in /usr/lib/modules but on older
releases they aren't so copy them over like we do for debian.

19 months agoci: Disable jobs with arch linux tools trees for now.
Daan De Meyer [Thu, 4 Jan 2024 14:59:24 +0000 (15:59 +0100)] 
ci: Disable jobs with arch linux tools trees for now.

Arch has qemu 8.2 which has severely broken TCG acceleration
(see https://gitlab.com/qemu-project/qemu/-/issues/2070). Let's disable
the jobs with arch tools trees until the bug is fixed.

19 months agoAllow building default ubuntu image for jammy
Daan De Meyer [Wed, 3 Jan 2024 21:14:31 +0000 (22:14 +0100)] 
Allow building default ubuntu image for jammy

Useful for debugging CI failures since CI also runs jammy.

We also make sure the shared configuration is included after the
distribution specific configuration so we can set defaults in the
distribution specific configuration and use it in the shared
configuration.

19 months agoMerge pull request #2236 from DaanDeMeyer/fixes
Daan De Meyer [Wed, 3 Jan 2024 18:30:20 +0000 (19:30 +0100)] 
Merge pull request #2236 from DaanDeMeyer/fixes

Various fixes and improvements

19 months agoinitrd: Install util-linux-core on Fedora
Daan De Meyer [Wed, 3 Jan 2024 15:33:21 +0000 (16:33 +0100)] 
initrd: Install util-linux-core on Fedora

With https://bodhi.fedoraproject.org/updates/FEDORA-2023-7ba9a1b546,
sulogin is moved to util-linux-core on Fedora which means util-linux-core
has everything required for the initrd so let's use util-linux-core instead
of util-linux to save on disk space.

19 months agoOnly mount cache overlay if base trees are specified and Overlay= is not enabled 2236/head
Daan De Meyer [Wed, 3 Jan 2024 13:46:16 +0000 (14:46 +0100)] 
Only mount cache overlay if base trees are specified and Overlay= is not enabled

The setup() method of some distributions creates files in the root
directory which means that checking if the root directory is empty
doesn't work. Instead, let's check if any base trees were specified
explicitly.

19 months agoCache skeleton trees
Daan De Meyer [Wed, 3 Jan 2024 13:44:09 +0000 (14:44 +0100)] 
Cache skeleton trees

These are only intended for files that affect package manager
operation so we should be able to cache this step without any issues
since if the skeleton tree is changed, users are likely going to want
to throw away their cache regardless.

19 months agotree: Simplify copy_tree() a little
Daan De Meyer [Wed, 3 Jan 2024 13:43:41 +0000 (14:43 +0100)] 
tree: Simplify copy_tree() a little

19 months agoUnshare fewer namespaces
Daan De Meyer [Tue, 2 Jan 2024 16:11:12 +0000 (17:11 +0100)] 
Unshare fewer namespaces

These were primarily unshared to get the systemd unit test suite passing.
Now that the systemd test suite passes even if these are not unshared,
let's stop unsharing them as they don't make much sense for the operations
were doing and nspawn doesn't run when some of these are unshared.

19 months agoAdd more keyword only arguments for kmod functions
Daan De Meyer [Tue, 2 Jan 2024 12:45:35 +0000 (13:45 +0100)] 
Add more keyword only arguments for kmod functions

19 months agoStop using bwrap() for systemd-dissect
Daan De Meyer [Tue, 2 Jan 2024 12:40:18 +0000 (13:40 +0100)] 
Stop using bwrap() for systemd-dissect

systemd-dissect needs to mount stuff in the current mount namespace,
bwrap always creates a new mount namespace, so we can't sandbox
systemd-dissect.

19 months agoRemove clobber argument from copy_tree()
Daan De Meyer [Tue, 2 Jan 2024 12:35:27 +0000 (13:35 +0100)] 
Remove clobber argument from copy_tree()

Unused so let's remove it.

19 months agoRename various symbols
Daan De Meyer [Mon, 1 Jan 2024 16:49:08 +0000 (17:49 +0100)] 
Rename various symbols

- Let's get rid of the Mkosi prefix everywhere. Python has namespaced
modules for a reason, let's make use of that.
- Let's also rename State to Context, to match systemd where Context
is generally used as well instead of State.

19 months agoUse functools.total_ordering for GenericVersion
Daan De Meyer [Mon, 1 Jan 2024 14:20:16 +0000 (15:20 +0100)] 
Use functools.total_ordering for GenericVersion

19 months agoDon't specify smm at all if it's not supported
Daan De Meyer [Wed, 3 Jan 2024 14:04:11 +0000 (15:04 +0100)] 
Don't specify smm at all if it's not supported

19 months agoPreserve target directories stat when copying extra/skeleton trees
Daan De Meyer [Tue, 2 Jan 2024 20:55:05 +0000 (21:55 +0100)] 
Preserve target directories stat when copying extra/skeleton trees

When copying extra and skeleton trees, let's not touch the permissions
of directories that already exist in the image's root directory. 99%
of the time, the directories are only in the extra tree to make sure
the files go in the right directory in the image's root directory and
serve no other purpose so it makes sense to ignore their metadata in
this case.

Because cp does not support this natively (either all permissions are
copied for directories and files or none are copied), we implement this
ourselves by saving the necessary permissions before we call cp and
restoring them afterwards).

19 months agoPreserve ownership when copying base trees
Daan De Meyer [Tue, 2 Jan 2024 20:52:31 +0000 (21:52 +0100)] 
Preserve ownership when copying base trees

Base trees ownership should be kept intact when copying, otherwise
we lose valuable information.

19 months agoAdd more ovmf locations
Daan De Meyer [Wed, 3 Jan 2024 08:01:54 +0000 (09:01 +0100)] 
Add more ovmf locations

debian removed their old variables in favor of new ones so let's
make sure we look for the new ones as well.

19 months agoci: Install systemd-ukify Debian/Ubuntu when available
Joerg Behrmann [Mon, 1 Jan 2024 15:03:58 +0000 (16:03 +0100)] 
ci: Install systemd-ukify Debian/Ubuntu when available

Debian unstable has split off ukify into its own package so let's
update our debian images to accomodate that change.

19 months agoDon't use smm on aarch64
Daan De Meyer [Wed, 3 Jan 2024 07:50:29 +0000 (08:50 +0100)] 
Don't use smm on aarch64

This property is only supported on the x86 machines so stop trying
to use it on arm.

19 months agoExtend ukify hint
Daan De Meyer [Tue, 2 Jan 2024 19:21:59 +0000 (20:21 +0100)] 
Extend ukify hint

Let's also mention ToolsTree=default and that Bootable=no doesn't
need ukify to be available.

Fixes #2220

19 months agoMount /etc/alternatives if it exists
Cornelius Hoffmann [Tue, 2 Jan 2024 16:51:09 +0000 (17:51 +0100)] 
Mount /etc/alternatives if it exists

In (at least) Debian, some binaries such as awk point to
/etc/alternatives which would not exist and cause apt-key to fail
without specifying the exact keyring (e.g. when using /etc/apt/trusted.gpg.d)

Fixes #2227

19 months agoDisable debsig for dpkg by default as they do in debian.
Cornelius Hoffmann [Tue, 2 Jan 2024 15:39:18 +0000 (16:39 +0100)] 
Disable debsig for dpkg by default as they do in debian.

From the default dpkg.conf:
# Do not enable debsig-verify by default; since the distribution is not using
# embedded signatures, debsig-verify would reject all packages.
no-debsig

19 months agoUpdate link to systemd's mkosi files
Nils K [Fri, 29 Dec 2023 21:37:21 +0000 (22:37 +0100)] 
Update link to systemd's mkosi files

19 months agoAdd missing item title in documentation
Lars Christensen [Fri, 29 Dec 2023 12:50:56 +0000 (13:50 +0100)] 
Add missing item title in documentation

19 months agoMount scripts into sandbox as well
Daan De Meyer [Tue, 26 Dec 2023 15:21:06 +0000 (16:21 +0100)] 
Mount scripts into sandbox as well

The script might not come from the directory mkosi is running in so
we have to make sure it gets mounted into the sandbox.

19 months agoUse signed-by instead of setting Dir::Etc::trusted
Daan De Meyer [Fri, 22 Dec 2023 16:44:52 +0000 (17:44 +0100)] 
Use signed-by instead of setting Dir::Etc::trusted

apt complains about using the latter so let's use signed-by.

19 months agoMove creation of /etc/static symlink to package manager tree setup
Daan De Meyer [Fri, 22 Dec 2023 15:55:29 +0000 (16:55 +0100)] 
Move creation of /etc/static symlink to package manager tree setup

bwrap's --symlink is not idempotent, so let's create the symlink
when setting up the package manager tree instead.

19 months agoDrop SYSTEMD_LOG_LEVEL=debug when installing systemd-boot
Daan De Meyer [Fri, 22 Dec 2023 15:37:17 +0000 (16:37 +0100)] 
Drop SYSTEMD_LOG_LEVEL=debug when installing systemd-boot

This seems to have gotten in accidentally.

19 months agoMerge pull request #2212 from DaanDeMeyer/usr
Daan De Meyer [Fri, 22 Dec 2023 15:37:58 +0000 (16:37 +0100)] 
Merge pull request #2212 from DaanDeMeyer/usr

Overlay /usr from package manager trees on top of /usr in bwrap()

19 months agoMake sure we cache state from package managers as well 2212/head
Daan De Meyer [Fri, 22 Dec 2023 14:39:44 +0000 (15:39 +0100)] 
Make sure we cache state from package managers as well

To do this we start using cache/ and lib/ directories underneath
the cache directory.

We also fix our cleanup logic to only remove the relevant directories
in case the cache directory is configured to be /var or similar.

19 months agoMount entire /etc from package manager tree into sandbox
Daan De Meyer [Fri, 22 Dec 2023 14:29:06 +0000 (15:29 +0100)] 
Mount entire /etc from package manager tree into sandbox

Instead of mounting individual directories, let's just mount the
entire /etc into the sandbox. This allows any tool we run through
the sandbox to pick up configuration from the package manager tree
without having to add explicit support for it in mkosi.

This also removes our special casing for uki.conf. ukify will now
pick up its configuration from its canonical location just like all
the other tools.

19 months agoOverlay /usr from package manager trees on top of /usr in bwrap()
Daan De Meyer [Fri, 22 Dec 2023 13:30:50 +0000 (14:30 +0100)] 
Overlay /usr from package manager trees on top of /usr in bwrap()

Let's allow package manager configuration to be put in /usr as well
by simply overlaying /usr from the package manager tree on top of
/usr.

19 months agoMerge pull request #2211 from malt3/fix/bwrap/mount-readonly-nix-store
Daan De Meyer [Fri, 22 Dec 2023 13:39:55 +0000 (14:39 +0100)] 
Merge pull request #2211 from malt3/fix/bwrap/mount-readonly-nix-store

bwrap: mount readonly nix store

19 months agobubblewrap: add /etc/static symlink 2211/head
Malte Poll [Fri, 22 Dec 2023 12:06:11 +0000 (13:06 +0100)] 
bubblewrap: add /etc/static symlink

On NixOS, ssl certificates are stored as follows:

/etc/ssl/certs/ca-bundle.crt -> /etc/static/ssl/certs/ca-bundle.crt
/etc/static -> /nix/store/<HASH>-etc/etc

Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
19 months agoMount package manager trees
Daan De Meyer [Fri, 22 Dec 2023 11:18:40 +0000 (12:18 +0100)] 
Mount package manager trees

Now that /etc and /var are free game when running within bwrap()
because we don't mount in the directories from the host anymore,
let's take advantage of that by mounting all our package manager
configuration to the canonical location in /etc instead of configuring
the package managers via their CLI or config file to look in the
right directory.

This also makes us look for rpm configuration in /etc/rpm instead
of /usr/lib/rpm as that's now possible.

19 months agobubblewrap: try to mount /nix/store readonly
Malte Poll [Fri, 22 Dec 2023 11:41:10 +0000 (12:41 +0100)] 
bubblewrap: try to mount /nix/store readonly

Similar to most usrmerged systems, NixOS stores all installed
binaries and libraries in /nix/store.
To make mkosi work on NixOS, the nix store should be mounted by default.

Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
19 months agoMake sure we mount in extra search paths
Daan De Meyer [Fri, 22 Dec 2023 09:33:52 +0000 (10:33 +0100)] 
Make sure we mount in extra search paths

20 months agoInstall centos/fedora packaging tools in default images
Daan De Meyer [Thu, 21 Dec 2023 20:15:23 +0000 (21:15 +0100)] 
Install centos/fedora packaging tools in default images

Useful for doing Fedora/CentOS packaging work.

20 months agoFail when trying to inspect ephemeral images
Daan De Meyer [Thu, 21 Dec 2023 19:57:29 +0000 (20:57 +0100)] 
Fail when trying to inspect ephemeral images

Any changes to these are thrown away after exit so can't inspect
them.

20 months agoUpdate NEWS
Daan De Meyer [Thu, 21 Dec 2023 18:02:55 +0000 (19:02 +0100)] 
Update NEWS

20 months agoMerge pull request #2201 from DaanDeMeyer/sandbox
Daan De Meyer [Thu, 21 Dec 2023 17:31:08 +0000 (18:31 +0100)] 
Merge pull request #2201 from DaanDeMeyer/sandbox

Sandbox more in bwrap()

20 months agoRun more binaries with bwrap() 2201/head
Daan De Meyer [Thu, 21 Dec 2023 15:00:44 +0000 (16:00 +0100)] 
Run more binaries with bwrap()

Let's sandbox more of the image build. This isolates more of the
build from the host which reduces the chance of leaking in host
specific details into the image.

20 months agoSandbox more in bwrap()
Daan De Meyer [Wed, 20 Dec 2023 20:31:56 +0000 (21:31 +0100)] 
Sandbox more in bwrap()

Let's not make the full root filesystem available to commands
running in bwrap(). Instead, limit it to some select directories.

- /usr
- Various directories from /etc. Note that this also means we can
  get rid of mount_tools() as all these directories are now mounted
  in bwrap() instead. This also allows us to get rid of the overlay
  hack in mount_tools() to create the necessary mount points. The
  goal is to get rid of as many of these as possible over time.
- /var/tmp
- /tmp

Because to make this work we have to pass MkosiConfig into bwrap(),
we split off a new file bubblewrap.py with all the bubblewrap stuff.

To avoid having to import MkosiState and bwrap() into tree.py,
install_tree() is moved __init__.py

20 months agoMake RepartOffline= apply to extension images as well
Daan De Meyer [Thu, 21 Dec 2023 12:44:14 +0000 (13:44 +0100)] 
Make RepartOffline= apply to extension images as well

20 months agoRun depmod and modinfo on host again
Daan De Meyer [Thu, 21 Dec 2023 10:07:36 +0000 (11:07 +0100)] 
Run depmod and modinfo on host again

Running these in the chroot is much slower when building images for
another architecture. Also, we might soon have a way to prevent dnf
from running depmod (see
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2743), so
let's adopt that when it is merged.

20 months agoInstall kmod in default tools tree
Daan De Meyer [Thu, 21 Dec 2023 11:36:01 +0000 (12:36 +0100)] 
Install kmod in default tools tree

20 months agoAdd ubu-keyring to CentOS/Fedora default tools trees
Daan De Meyer [Thu, 21 Dec 2023 15:22:25 +0000 (16:22 +0100)] 
Add ubu-keyring to CentOS/Fedora default tools trees

And remove the CI exclusions related to missing ubuntu keyring in
CentOS/Fedora.

20 months agoMerge pull request #2199 from DaanDeMeyer/selinux
Jörg Behrmann [Thu, 21 Dec 2023 15:44:03 +0000 (16:44 +0100)] 
Merge pull request #2199 from DaanDeMeyer/selinux

Add SelinuxRelabel= setting

20 months agoMerge pull request #2196 from DaanDeMeyer/opensuse
Daan De Meyer [Thu, 21 Dec 2023 14:05:28 +0000 (15:05 +0100)] 
Merge pull request #2196 from DaanDeMeyer/opensuse

ci: Build dnf based distros with opensuse tools tree