]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
12 months agoLook up qemu and virt-fw-vars in extra search paths 2910/head
Daan De Meyer [Thu, 25 Jul 2024 05:41:21 +0000 (07:41 +0200)] 
Look up qemu and virt-fw-vars in extra search paths

Because qemu uses OVMF firmware descriptions from /usr, we look
those up in the same root that we'll be invoking qemu from. Because
virt-fw-vars operates on the same files, we also invoke it in the
same root that we find qemu in.

12 months agoRemove noisy debug logging
Daan De Meyer [Thu, 25 Jul 2024 08:31:38 +0000 (10:31 +0200)] 
Remove noisy debug logging

There could potentially be a huge amount of modules and firmware
which makes these log messages very noisy. Let's drop them to make
debug logs less annoying to parse.

12 months agoAssign return code before calling sys.excepthook()
Daan De Meyer [Thu, 25 Jul 2024 07:15:13 +0000 (09:15 +0200)] 
Assign return code before calling sys.excepthook()

It seems sys.excepthook() can raise its own exception? I'm not entirely
sure what's going on, but as a safety measure, let's assign the correct
return code before we invoke sys.excepthook() so that we always exit with
the right returncode.

12 months agoMerge pull request #2908 from DaanDeMeyer/kmod
Jörg Behrmann [Wed, 24 Jul 2024 16:47:26 +0000 (18:47 +0200)] 
Merge pull request #2908 from DaanDeMeyer/kmod

Various kernel modules improvements

12 months agoDon't clean tools tree unless at least -f is specified 2908/head
Daan De Meyer [Wed, 24 Jul 2024 15:27:26 +0000 (17:27 +0200)] 
Don't clean tools tree unless at least -f is specified

Otherwise if we run mkosi qemu and the cache is out of date we
remove the tools tree which we shouldn't do.

12 months agoAlways add all nls modules to the initramfs
Daan De Meyer [Wed, 24 Jul 2024 14:24:05 +0000 (16:24 +0200)] 
Always add all nls modules to the initramfs

Potentially required for mounting FAT filesystems so let's make sure
these are included.

12 months agoOnly include default kernel modules in default image
Daan De Meyer [Wed, 24 Jul 2024 13:47:10 +0000 (15:47 +0200)] 
Only include default kernel modules in default image

Let's add some coverage for the default modules list by enabling it
for the default image.

12 months agoAlways add raid modules to the initrd
Daan De Meyer [Wed, 24 Jul 2024 13:44:20 +0000 (15:44 +0200)] 
Always add raid modules to the initrd

Raid needs to be set up from the initrd so let's make sure the
modules required to do that are always available.

12 months agoAlways dm-multipath to the initrd
Daan De Meyer [Wed, 24 Jul 2024 13:43:52 +0000 (15:43 +0200)] 
Always dm-multipath to the initrd

Required for doing multipath so let's always add it to the initrd.

12 months agoAdd all crypto modules to the initramfs
Daan De Meyer [Wed, 24 Jul 2024 13:42:51 +0000 (15:42 +0200)] 
Add all crypto modules to the initramfs

There's various crypto directories all across the kernel modules
tree. Let's make sure we include all of them so that everything
required to do crypto is always available from the initrd.

12 months agoHandle softdep module dependencies properly
Daan De Meyer [Wed, 24 Jul 2024 13:41:15 +0000 (15:41 +0200)] 
Handle softdep module dependencies properly

The softdep lines are formatted a little differently and can contain
pre: and post: so we need to make sure we handle all those cases.

12 months agokernel-install: Only build UKI if we're configured as the UKI generator
Daan De Meyer [Wed, 24 Jul 2024 14:16:13 +0000 (16:16 +0200)] 
kernel-install: Only build UKI if we're configured as the UKI generator

12 months agoDon't copy /var/lib/pacman/local when copying repository metadata
Daan De Meyer [Wed, 24 Jul 2024 10:48:42 +0000 (12:48 +0200)] 
Don't copy /var/lib/pacman/local when copying repository metadata

/var/lib/pacman/local contains the local database of installed packages.
When using "--package-cache-dir /var", we'd end up copying the local
database of the host which means pacman thinks packages are already
installed in the image even though they aren't.

Fix this by not copying /var/lib/pacman/local.

Fixes #2904

12 months agoFix typo
Daan De Meyer [Wed, 24 Jul 2024 12:20:52 +0000 (14:20 +0200)] 
Fix typo

12 months agoaction: Dump the current clock source
Daan De Meyer [Tue, 23 Jul 2024 16:20:33 +0000 (18:20 +0200)] 
action: Dump the current clock source

This can have a non-trivial performance impact so let's dump the
clock source as extra debugging information.

12 months agoIf the image is nocow, make the ephemeral copy nocow as well
Daan De Meyer [Tue, 23 Jul 2024 20:36:55 +0000 (22:36 +0200)] 
If the image is nocow, make the ephemeral copy nocow as well

On btrfs, VM images are generally recommended to be made nocow as
cow (copy-on-write) and random writes don't play well together. Let's
take this into account in copy_ephemeral() and make the ephemeral
copy nocow as well if the source is nocow.

12 months agoMove needs_clean() check out of run_clean()
Daan De Meyer [Tue, 23 Jul 2024 13:11:08 +0000 (15:11 +0200)] 
Move needs_clean() check out of run_clean()

12 months agoDrop uid/gid from cache manifest
Daan De Meyer [Tue, 23 Jul 2024 20:59:22 +0000 (22:59 +0200)] 
Drop uid/gid from cache manifest

This does not work as we call have_cache() to determine whether
we need to clean the tools tree or not and when running as root to
boot after building an image the UID/GID will differ and the tools
tree will incorrectly be considered out of date.

Let's move the UID/GID check out of have_cache() and into reuse_cache()
instead. reuse_cache() always runs after we've already potentially
unshared the user namespace and become root, so checking the owner of
the cache directory against the current UID should be a valid check
there.

12 months agoMake sure mkosi works in the initramfs
Daan De Meyer [Mon, 22 Jul 2024 13:19:16 +0000 (15:19 +0200)] 
Make sure mkosi works in the initramfs

bubblewrap uses pivot_root() which doesn't work in the initramfs as
pivot_root() requires / to be a mountpoint which is not the case in
the initramfs. So, to make sure mkosi works from within the initramfs,
let's make / a mountpoint by recursively bind-mounting / (the directory)
to another location and then switching root into the bind mount directory.

12 months agoOnly pass --expand-environment=no if we have systemd-run 254 or newer
Daan De Meyer [Mon, 22 Jul 2024 18:11:35 +0000 (20:11 +0200)] 
Only pass --expand-environment=no if we have systemd-run 254 or newer

--expand-environment= was introduced in systemd v254.

12 months agoRevert "Force user namespace in bubblewrap if we're not running as root"
Daan De Meyer [Mon, 22 Jul 2024 15:31:42 +0000 (17:31 +0200)] 
Revert "Force user namespace in bubblewrap if we're not running as root"

This reverts commit 01ac080103f2bc61ecc23334b00334e421eebb8a.

We can't check the current uid in sandbox_cmd() as it might still
change, for example in start_virtiofsd() where before we run bwrap
we might run become_root_cmd() to become root.

12 months agoMake make_cpio() take a list of files relative to the root directory
Daan De Meyer [Sun, 21 Jul 2024 21:07:01 +0000 (23:07 +0200)] 
Make make_cpio() take a list of files relative to the root directory

We operate on absolute paths all the time in kmod.py only for them to
be made relative to the root directory just before they are passed to
cpio. Let's save on the amount of allocations by always operating on
paths relative to the root directory.

Because rglob() doesn't support returning paths relative to the given
directory, we chdir() into the root directory before globbing instead.

12 months agoIgnore symlinks in /boot when fixing up kernel images
Daan De Meyer [Mon, 22 Jul 2024 08:49:59 +0000 (10:49 +0200)] 
Ignore symlinks in /boot when fixing up kernel images

12 months agoMerge pull request #2891 from DaanDeMeyer/local-packages
Jörg Behrmann [Mon, 22 Jul 2024 08:58:40 +0000 (10:58 +0200)] 
Merge pull request #2891 from DaanDeMeyer/local-packages

Recommend PackageDirectories= to install local packages

12 months agoAdd configuration parsing rework to NEWS 2891/head
Daan De Meyer [Mon, 22 Jul 2024 08:01:41 +0000 (10:01 +0200)] 
Add configuration parsing rework to NEWS

12 months agoStop mounting build sources when running package managers
Daan De Meyer [Mon, 22 Jul 2024 05:46:13 +0000 (07:46 +0200)] 
Stop mounting build sources when running package managers

We now have PackageDirectories= to make local packages available
for installation so let's stop mounting build sources when running
package managers and tell users to use PackageDirectories= instead.

12 months agoRecommend PackageDirectories= to install local packages
Daan De Meyer [Mon, 22 Jul 2024 05:44:25 +0000 (07:44 +0200)] 
Recommend PackageDirectories= to install local packages

apt-get requires absolute paths to be specified and doesn't work
with relative paths. Let's instead recommend PackageDirectories=
which we know works the same for all distributions.

12 months agoMerge pull request #2888 from DaanDeMeyer/userns
Jörg Behrmann [Sun, 21 Jul 2024 20:51:29 +0000 (22:51 +0200)] 
Merge pull request #2888 from DaanDeMeyer/userns

Two sandboxing fixlets

12 months agoUse setresuid() and setresgid() 2888/head
Daan De Meyer [Sun, 21 Jul 2024 20:08:44 +0000 (22:08 +0200)] 
Use setresuid() and setresgid()

If we're invoked with sudo let's make sure we leak less of the fact
that we're invoked as root into the environment when running sync
scripts.

12 months agoForce user namespace in bubblewrap if we're not running as root
Daan De Meyer [Sun, 21 Jul 2024 20:07:32 +0000 (22:07 +0200)] 
Force user namespace in bubblewrap if we're not running as root

Depending on whether bwrap is installed setuid or not it might try
to not create a user namespace. Let's explicitly tell it to create
one if we're not invoking it as root to make sure one is always
created.

12 months agoAllow multilib and multilib-testing repositories for arch distribution
Guillaume [Sun, 21 Jul 2024 13:29:17 +0000 (09:29 -0400)] 
Allow multilib and multilib-testing repositories for arch distribution

12 months agoMerge pull request #2885 from DaanDeMeyer/tools
Jörg Behrmann [Sat, 20 Jul 2024 18:42:58 +0000 (20:42 +0200)] 
Merge pull request #2885 from DaanDeMeyer/tools

Choose default tools tree distribution based on host distribution

12 months agoChoose default tools tree distribution based on host distribution 2885/head
Daan De Meyer [Fri, 19 Jul 2024 08:51:57 +0000 (10:51 +0200)] 
Choose default tools tree distribution based on host distribution

Let's choose the default tools tree distribution based on the host
distribution instead of the target distribution. Why? When building
a Fedora image from Ubuntu, It's much more likely that apt-get will
be installed to build a Debian tools tree rather than requiring dnf
to be installed to build a Fedora tools tree.

12 months agoFix typing error with newer mypy
Daan De Meyer [Sat, 20 Jul 2024 13:53:12 +0000 (15:53 +0200)] 
Fix typing error with newer mypy

Python does not have block scoped variables which messes up typing
if you use the same variable name in 2 unrelated blocks so let's
rename this one to make mypy happy.

12 months agoMake ParseContext a regular class
Daan De Meyer [Fri, 19 Jul 2024 08:51:57 +0000 (10:51 +0200)] 
Make ParseContext a regular class

Let's simplify the config parsing implementation by making ParseContext
a regular class instead of a singleton. Additionally, we make ConfigAction
a global class and slightly change the behavior of --include= on the command
line by parsing all given includes after parsing all the other command line
arguments.

13 months agoMerge pull request #2882 from DaanDeMeyer/glob
Jörg Behrmann [Thu, 18 Jul 2024 19:52:13 +0000 (21:52 +0200)] 
Merge pull request #2882 from DaanDeMeyer/glob

Use PACKAGE_GLOBS in one more place

13 months agoTighten package globs 2882/head
Daan De Meyer [Thu, 18 Jul 2024 18:42:11 +0000 (20:42 +0200)] 
Tighten package globs

Debs don't do compression suffixes. Udebs aren't really used except
for stuff to do with the debian installer so ignore those as well.

13 months agoUse PACKAGE_GLOBS in one more place
Daan De Meyer [Thu, 18 Jul 2024 18:39:39 +0000 (20:39 +0200)] 
Use PACKAGE_GLOBS in one more place

13 months agoOnly pass kernel command line to ukify if there is one
Daan De Meyer [Thu, 18 Jul 2024 14:50:09 +0000 (16:50 +0200)] 
Only pass kernel command line to ukify if there is one

If we don't have any kernel command line arguments, don't pass
--cmdline to ukify.

Turns out systemd-stub will hang on boot when .cmdline contains only
a null terminator so with this change we avoid that from happening.

13 months agoDon't fail if kernel-install is not installed
Daan De Meyer [Thu, 18 Jul 2024 08:24:27 +0000 (10:24 +0200)] 
Don't fail if kernel-install is not installed

13 months agoInstall rpmautospec on Fedora and CentOS Stream 9 with EPEL
Daan De Meyer [Wed, 17 Jul 2024 14:58:57 +0000 (16:58 +0200)] 
Install rpmautospec on Fedora and CentOS Stream 9 with EPEL

Required for building some rpms so let's make sure these are installed.

13 months agoMerge pull request #2878 from DaanDeMeyer/stuff
Daan De Meyer [Wed, 17 Jul 2024 13:03:23 +0000 (15:03 +0200)] 
Merge pull request #2878 from DaanDeMeyer/stuff

Various small improvements

13 months agoAdd a repart partition definition for the root partition into the default image 2878/head
Daan De Meyer [Wed, 17 Jul 2024 10:42:04 +0000 (12:42 +0200)] 
Add a repart partition definition for the root partition into the default image

This makes sure the partition is grown on boot to fill the disk, which
is required for RuntimeSize= to work properly.

13 months agoOnly remount various directories if invoked as root
Daan De Meyer [Wed, 17 Jul 2024 10:41:25 +0000 (12:41 +0200)] 
Only remount various directories if invoked as root

If we weren't invoked as root we aren't allowed to write to any of
these anyway so no need to remount them read-only.

13 months agoSort one package list
Daan De Meyer [Wed, 17 Jul 2024 10:41:10 +0000 (12:41 +0200)] 
Sort one package list

13 months agoAdd unprivileged user to default image
Daan De Meyer [Wed, 17 Jul 2024 10:40:14 +0000 (12:40 +0200)] 
Add unprivileged user to default image

Makes testing as an unprivileged user easier. We also install sudo
and polkit in the default image to make auth work.

13 months agoFail when trying to change universal settings in subimages
Daan De Meyer [Tue, 16 Jul 2024 09:48:04 +0000 (11:48 +0200)] 
Fail when trying to change universal settings in subimages

Let's error out when users try to configure universal settings in
subimages since these will always be overridden.

13 months agoMake sure we always update the local repository metadata
Daan De Meyer [Mon, 15 Jul 2024 12:56:04 +0000 (14:56 +0200)] 
Make sure we always update the local repository metadata

The latest release of dnf5 introduced a change in behavior causing us
to not always sync the local repository metadata. To mitigate this, let's
always specify --refresh or similar for all package managers when we sync
the local repository to make sure its metadata is updated.

13 months agoOnly create local repository if actually needed
Daan De Meyer [Mon, 15 Jul 2024 07:22:21 +0000 (09:22 +0200)] 
Only create local repository if actually needed

13 months agoUse the same SPDX license identifier everywhere
Daan De Meyer [Mon, 15 Jul 2024 10:48:24 +0000 (12:48 +0200)] 
Use the same SPDX license identifier everywhere

13 months agoMerge pull request #2868 from DaanDeMeyer/packagedir
Jörg Behrmann [Sun, 14 Jul 2024 20:12:09 +0000 (22:12 +0200)] 
Merge pull request #2868 from DaanDeMeyer/packagedir

Two small improvements

13 months agoAdd DISTRIBUTION_ARCHITECTURE environment variable 2868/head
Daan De Meyer [Sun, 14 Jul 2024 14:51:53 +0000 (16:51 +0200)] 
Add DISTRIBUTION_ARCHITECTURE environment variable

13 months agoMake volatile packages available in local repository earlier 2867/head
Daan De Meyer [Sat, 13 Jul 2024 13:38:30 +0000 (15:38 +0200)] 
Make volatile packages available in local repository earlier

By making the volatile packages available earlier, we can query,
install and cache their dependencies in a prepare script.

13 months agoAdd --expand-environment+no to systemd-run command line
Daan De Meyer [Sat, 13 Jul 2024 06:56:34 +0000 (08:56 +0200)] 
Add --expand-environment+no to systemd-run command line

Otherwise systemd will try to expand environment variables in our
command instead of the shell.

13 months agoShare the package directory across all image builds
Daan De Meyer [Fri, 12 Jul 2024 15:07:22 +0000 (17:07 +0200)] 
Share the package directory across all image builds

This allows packages built by one image to easily be installed in
another image when using mkosi.images.

13 months agoMerge pull request #2864 from DaanDeMeyer/build
Daan De Meyer [Fri, 12 Jul 2024 13:21:20 +0000 (15:21 +0200)] 
Merge pull request #2864 from DaanDeMeyer/build

Various fixes to streamline using build scripts in subimages

13 months agoDrop per subimage build directory again 2864/head
Daan De Meyer [Fri, 12 Jul 2024 12:27:55 +0000 (14:27 +0200)] 
Drop per subimage build directory again

Let's leave this up to the individual subimage build scripts instead,
so that it's also possible for different subimages to share a build
directory if they want to do so.

13 months agoMark various settings as universal
Daan De Meyer [Fri, 12 Jul 2024 12:27:02 +0000 (14:27 +0200)] 
Mark various settings as universal

Let's make BuildSources=, BuildSourcesEphemeral=, WithTests= and
WithNetwork= universal so that packages can easily be built in a
subimage instead of in the main image build.

13 months agoIntroduce PassEnvironment=
Daan De Meyer [Fri, 12 Jul 2024 12:25:44 +0000 (14:25 +0200)] 
Introduce PassEnvironment=

We can't mark Environment= as a universal setting as only some environment
variables should be universal and others shouldn't be. So let's introduce
PassEnvironment= to mark specific environment variables as universal so that
they are passed to subimage builds.

13 months agoDrop --append documentation
Daan De Meyer [Fri, 12 Jul 2024 12:23:31 +0000 (14:23 +0200)] 
Drop --append documentation

13 months agoFix Images= and Dependencies= documentation
Daan De Meyer [Fri, 12 Jul 2024 12:23:07 +0000 (14:23 +0200)] 
Fix Images= and Dependencies= documentation

13 months agoFix spacing in documentation
Daan De Meyer [Fri, 12 Jul 2024 12:19:59 +0000 (14:19 +0200)] 
Fix spacing in documentation

13 months agoMake $BUILDDIR accessible to various scripts
Daan De Meyer [Fri, 12 Jul 2024 12:17:02 +0000 (14:17 +0200)] 
Make $BUILDDIR accessible to various scripts

Let's allow scripts to access the build directory so that outputs produced
by previous (sub)image builds can be accessed. Let's mount the build directory
read-only so that these scripts can't actually write to it.

13 months agoMerge pull request #2863 from DaanDeMeyer/apt
Daan De Meyer [Thu, 11 Jul 2024 11:55:25 +0000 (13:55 +0200)] 
Merge pull request #2863 from DaanDeMeyer/apt

Set RPM_FORCE_DEBIAN=1 for zypper and dnf

13 months agoSet RPM_FORCE_DEBIAN=1 for zypper and dnf 2863/head
Daan De Meyer [Thu, 11 Jul 2024 11:46:39 +0000 (13:46 +0200)] 
Set RPM_FORCE_DEBIAN=1 for zypper and dnf

This stops rpm on Ubuntu from printing noisy warnings about aliens.

13 months agoInstall binutils in default image
Daan De Meyer [Thu, 11 Jul 2024 11:41:36 +0000 (13:41 +0200)] 
Install binutils in default image

13 months agoFix partition identification for mount.usr=PARTUUID
Nick Labich [Thu, 11 Jul 2024 07:08:25 +0000 (03:08 -0400)] 
Fix partition identification for mount.usr=PARTUUID

13 months agoFix --profile
Daan De Meyer [Thu, 11 Jul 2024 06:19:21 +0000 (08:19 +0200)] 
Fix --profile

The attribute might be set on either the cli or the config namespace
so don't assume it's set on the config namespace.

Fixes #2860

13 months agoDowngrade SELinuxRelabel=yes to SELinuxRelabel=auto for the initrd
Daan De Meyer [Wed, 10 Jul 2024 14:33:44 +0000 (16:33 +0200)] 
Downgrade SELinuxRelabel=yes to SELinuxRelabel=auto for the initrd

Otherwise we fail if there's no policy installed in the initramfs.
Putting a policy in the initramfs isn't really a thing so let's not
fail if there is one available but still relabel if there is one
installed.

13 months agodebian/ubuntu: Exclude docs in extract_tar() if WithDocs=no
Daan De Meyer [Wed, 10 Jul 2024 08:37:50 +0000 (10:37 +0200)] 
debian/ubuntu: Exclude docs in extract_tar() if WithDocs=no

Fixes #2851

13 months agoDon't require extra trees and initrds to exist if Format=none
Daan De Meyer [Wed, 10 Jul 2024 06:39:47 +0000 (08:39 +0200)] 
Don't require extra trees and initrds to exist if Format=none

We don't use these if Format=none so let's not check if they exist.

13 months agoModernize mkosi rpm build configuration
Daan De Meyer [Wed, 10 Jul 2024 06:38:32 +0000 (08:38 +0200)] 
Modernize mkosi rpm build configuration

13 months agoMerge pull request #2850 from DaanDeMeyer/cache
Daan De Meyer [Wed, 10 Jul 2024 08:27:47 +0000 (10:27 +0200)] 
Merge pull request #2850 from DaanDeMeyer/cache

Track local packages in cache manifest

13 months agoAdd `mkosi.pkgmngr` path to `PackageManagerTrees=`
Michael Ferrari [Wed, 10 Jul 2024 00:29:49 +0000 (02:29 +0200)] 
Add `mkosi.pkgmngr` path to `PackageManagerTrees=`

13 months agoTrack local packages in cache manifest 2850/head
Daan De Meyer [Mon, 8 Jul 2024 21:26:39 +0000 (23:26 +0200)] 
Track local packages in cache manifest

Let's track the modification timestamps of the packages from configured
package directories so we can rebuild the image if new packages appear
or are removed or changed.

13 months agoIntroduce VolatilePackageDirectories=
Daan De Meyer [Tue, 9 Jul 2024 12:24:10 +0000 (14:24 +0200)] 
Introduce VolatilePackageDirectories=

For packages that should not be available when building the cached
image but should be available when installing volatile packages.

Additionally, we have build scripts write their packages to a separate
directory instead of the repository directory and later on pass these
packages as a separate volatile package directory to the default initrd
build.

This will allow us to introduce proper caching for package directories
in the next commit.

13 months agoOnly install systemd-ukify on Fedora on UEFI architectures
Daan De Meyer [Sat, 6 Jul 2024 22:32:24 +0000 (00:32 +0200)] 
Only install systemd-ukify on Fedora on UEFI architectures

- systemd-ukify is only available on Fedora on UEFI architectures,
so let's not try to install it on other architectures.
- systemd-ukify is not in CentOS Stream 10 at the moment, so let's
not try to install it on CentOS just yet.

13 months agoDecouple local repository from package directory
Daan De Meyer [Tue, 9 Jul 2024 12:08:02 +0000 (14:08 +0200)] 
Decouple local repository from package directory

In preparation for the next commit, let's decouple the location of
the local repository from the location of the package directory where
scripts can look for packages.

13 months agoSimplify createrepo()
Daan De Meyer [Tue, 9 Jul 2024 12:01:21 +0000 (14:01 +0200)] 
Simplify createrepo()

13 months agoOptimize hash_file()
Daan De Meyer [Mon, 8 Jul 2024 21:26:10 +0000 (23:26 +0200)] 
Optimize hash_file()

Let's reduce unnecessary copies.

13 months agoIntroduce PACKAGE_GLOBS constant
Daan De Meyer [Mon, 8 Jul 2024 21:25:52 +0000 (23:25 +0200)] 
Introduce PACKAGE_GLOBS constant

13 months agoMerge pull request #2845 from DaanDeMeyer/repositories
Daan De Meyer [Tue, 9 Jul 2024 08:55:49 +0000 (10:55 +0200)] 
Merge pull request #2845 from DaanDeMeyer/repositories

Enable EPEL again for CentOS default tools tree

13 months agoEnable EPEL again for CentOS default tools tree 2845/head
Daan De Meyer [Sat, 6 Jul 2024 22:32:24 +0000 (00:32 +0200)] 
Enable EPEL again for CentOS default tools tree

Now that we have a Repositories= match, we can conditionally enable
EPEL for CentOS Stream 9 only and override the repositories when we
call mkosi dependencies. This means that the CentOS Stream 9 default
tools tree will have all the EPEL packages but we won't list them in
the output of mkosi dependencies.

We also add various missing packages to the CentOS Stream default tools
tree.

13 months agoAdd Repositories= match
Daan De Meyer [Sat, 6 Jul 2024 22:20:00 +0000 (00:20 +0200)] 
Add Repositories= match

13 months agoMerge pull request #2847 from DaanDeMeyer/config
Daan De Meyer [Tue, 9 Jul 2024 06:06:39 +0000 (08:06 +0200)] 
Merge pull request #2847 from DaanDeMeyer/config

Rework configuration parsing (again)

13 months agomkosi-initrd: Always add virtio_console module to initramfs
Daan De Meyer [Mon, 8 Jul 2024 22:25:38 +0000 (00:25 +0200)] 
mkosi-initrd: Always add virtio_console module to initramfs

13 months agoRework configuration parsing (again) 2847/head
Daan De Meyer [Sun, 7 Jul 2024 15:22:40 +0000 (17:22 +0200)] 
Rework configuration parsing (again)

As explained in #2846, there are multiple issues with the current
implementation of mkosi.images. Let's take what we learned from the
default initrd and the default tools tree and apply it mkosi.images.

Specifically, all issues arise from the fact that we apply every option
from the global configuration (including CLI arguments) to the images
from mkosi.images/. To avoid the issues that arise from this (e.g --package
abc installing abc in all images), we made configuration values override
CLI arguments again so that we could override faulty CLI arguments again
in subimages so that they would only apply to the main image (e.g. set
Format= explicitly for each subimage so that --format on the command line
only applies to the main image).

Because we still wanted to allow configurable settings that can be modified
via the command line, we introduced the default specifier '@' which can be
prefixed to a setting to set a default value instead of overriding the value.
The '@' specifier is generally used in the global image independent
configuration to specify default values that can be overridden from the command
line. This specifier has led to a lot of confusion, along with the behavior that
the CLI does not override the configuration.

From the default tools tree and default initrd, we learned that what works
very well is to only have specific settings from the main image configuration
apply to the default tools tree and default initrd. For example, the distribution,
release, mirror and architecture should be the same for the main image and the
initrd, but the packages from the main image should not all be installed in the
initrd.

We can apply this idea to the images from mkosi.images/ as well, if we
introduce the assumption that all images defined in mkosi.images are
subimages intended to be included in some way or form in the main image.
This assumption allows us to divide all settings into either image specific
settings or "universal" settings that should apply to the main image and all
its subimages. The universal settings are passed on to each subimage. The image
specific settings are not.

This idea also allows us to define the "main" image outside of mkosi.images
again. Since only "universal" settings are passed on, we can safely define
an output format and such again in the global configuration, as we know this
won't be passed on to subimages.

It also allows us to make CLI arguments override configuration again. Since
there is no need anymore for subimages to override the CLI configuration as
inappropriate CLI configuration such as extra packages will only apply to the
main image and not any subimages from mkosi.images/. Because CLI configuration
overrides file configuration again, we also don't need the '@' specifier anymore,
as default values can simply be set without '@', since the CLI will override
the configuration file values by default.

We also lose the need for --append, because the sole use for --append was again
to override file based configuration.

Note that configuration from mkosi.local.conf is special in that it
should override settings from other configuration files, but not settings
that are specified on the CLI.

This commit implements all of what's mentioned above, specifically:

- CLI configuration now always trumps file based configuration.
- The '@' specifier is dropped automatically during parsing
- The main image is now always added from global configuration, even
if there are images in mkosi.images/. The main image is always built
last, and cannot be used as a dependency in the Dependencies= setting
for images defined in mkosi.images/.
- The Dependencies= setting for the main image now is used to specify
which subimages from mkosi.images/ to build. By default all subimages
are built.
- A universal tag is introduced for settings and appropriate settings
are marked as universal. Universal settings are passed on from the
main image configuration to subimage configuration.
- The Images= setting is removed, as it's role is replaced by
Dependencies=.
- The old name mkosi.presets and the Preset section name are removed
as they have been deprecated for a long time now.
- The config parsing tests are extended to cover more cases.
- All builtin configuration is adapted to stop using the '@' specifier.
- The documentation is updated in accordance with the changes.

13 months agoFix empty strings for lists and dicts
Daan De Meyer [Mon, 8 Jul 2024 17:41:16 +0000 (19:41 +0200)] 
Fix empty strings for lists and dicts

Parse functions should return None to pick the default value. Also,
we don't get any values at all if unescape=True and the empty string
is passed so make sure we handle that case as well.

13 months agoDon't do caching if we have base trees
Daan De Meyer [Mon, 8 Jul 2024 14:39:32 +0000 (16:39 +0200)] 
Don't do caching if we have base trees

Instead of doing a complicated scheme with cache overlays which
aren't invalidated when the base tree changes, let's not do caching
when there are base trees. We assume that if there's a base tree
only a minimal amount of extra packages is installed that is sufficiently
fast without caching.

13 months agoUse list type for Images= and Dependencies= instead of tuple
Daan De Meyer [Mon, 8 Jul 2024 13:40:25 +0000 (15:40 +0200)] 
Use list type for Images= and Dependencies= instead of tuple

Also remove the unneeded JSON transformer/parser.

13 months agoRevert "action: Remove apparmor disable logic"
Daan De Meyer [Mon, 8 Jul 2024 12:19:42 +0000 (14:19 +0200)] 
Revert "action: Remove apparmor disable logic"

Turns out this hasn't been shipped in the default image yet.

This reverts commit 90cb8d54a0c65f46f0c7462be74a4135576edddf.

13 months agoMake INVOKING_USER.chown() take /tmp and /var/tmp into account
Daan De Meyer [Mon, 8 Jul 2024 10:45:23 +0000 (12:45 +0200)] 
Make INVOKING_USER.chown() take /tmp and /var/tmp into account

Let's also chown the directory to be user owned if located in /tmp
or /var/tmp.

13 months agoUse subdirectory of build directory for each subimage
Daan De Meyer [Mon, 8 Jul 2024 08:15:36 +0000 (10:15 +0200)] 
Use subdirectory of build directory for each subimage

Instead of sharing the build directory between all images, let's
use a subdirectory of the build directory for subimages.

This requires us to unshare the user namespace in run_build() before
we create the directories so that we always have permissions to create
any nested build directories.

13 months agoResolve source path in mount_base_trees()
Daan De Meyer [Mon, 8 Jul 2024 07:28:46 +0000 (09:28 +0200)] 
Resolve source path in mount_base_trees()

We want to check the extension on the resolved path, not on any
symlinks, so let's make sure we resolve the path first.

13 months agoDrop dead code
Daan De Meyer [Sun, 7 Jul 2024 13:44:16 +0000 (15:44 +0200)] 
Drop dead code

We don't read configuration for the genkey verb anymore so this can
be dropped.

13 months agoUse return value of finalize_value() in one more place
Daan De Meyer [Sun, 7 Jul 2024 13:39:13 +0000 (15:39 +0200)] 
Use return value of finalize_value() in one more place

Doesn't change behavior, just slightly easier to read.

13 months agoSimplify parse_new_includes()
Daan De Meyer [Sun, 7 Jul 2024 13:35:27 +0000 (15:35 +0200)] 
Simplify parse_new_includes()

We don't need to keep track of the current amount of includes since
those includes are already tracked in parsed_includes and will be
ignored. Slightly less efficient but this shouldn't matter here.

We also store the inode in parsed_includes before we parse the config
to make sure we don't try to parse it more than once.

13 months agoRename finalize_default() to finalize_value()
Daan De Meyer [Sun, 7 Jul 2024 13:33:52 +0000 (15:33 +0200)] 
Rename finalize_default() to finalize_value()

Fits what the function does better.

13 months agoMerge pull request #2843 from DaanDeMeyer/opensuse
Daan De Meyer [Sat, 6 Jul 2024 21:38:12 +0000 (23:38 +0200)] 
Merge pull request #2843 from DaanDeMeyer/opensuse

opensuse: Add support for aarch64

13 months agoopensuse: Install qemu-ovmf-x86_64 and qemu-uefi-aarch64 in tools tree 2843/head
Daan De Meyer [Sat, 6 Jul 2024 19:27:08 +0000 (21:27 +0200)] 
opensuse: Install qemu-ovmf-x86_64 and qemu-uefi-aarch64 in tools tree

Let's make sure the UEFI firmware for both x86-64 and arm64 is
available.