ruff [1] is a new very fast linter that combines rules from many commonly used
linters like pyflakes, isort or pyupgrade.
This commit uses the rules from pycodestyle (enabeled by default), pyflakes,
isort and pyupgrade and reintroduces the 119 character line length limit that
was used in the past with black and flake8, but was lost when black was disabled.
Georges Discry [Fri, 15 Sep 2023 20:01:26 +0000 (22:01 +0200)]
Warn when a setting is in the wrong section
Except for the `[Match]` section, a setting can be set in any of the
valid sections because the actual section is ignored. This fuzziness
works because each setting is used in only one section so there is not
conflict.
Instead of silently parsing such a file, a warning is now displayed with
a hint on how to fix it. In the future, this could become an error.
Make sure the root directory is a regular directory if Overlay= is enabled
overlayfs combined with a btrfs subvolume as the upperdir results in
EXDEV when trying to access files from a lowerdir, so let's make sure
we use a regular directory when Overlay= is enabled.
If we replace /tmp, we'll also make any directories located in /tmp
inaccessible, e.g. the workspace directory. Work around the problem
by reusing the host's /tmp.
Since we are defaulting to testing for Debian tools trees, we will always fight
testing being occasionally broken, e.g. when packages disappear because their
newer versions can't transition from unstable.
ToolsTreePackages= adds the ability to keep using a default tools tree, but add
custom packages on top.
This matches against the systemd version on the host. This is
useful for conditionally using a tools tree if the systemd version
on the host is too old.
This requires two things:
1. We need to generate a split initrd again to pass to -initrd
2. We need to synthesize a root= argument as we can't rely on
gpt-auto-generator since we're not using EFI.
We move the partition and root= specific stuff to a new file
partition.py so we can access it from qemu.py as well.
We also introduce extract_pe_section() since we now use the logic
twice.
Let's introduce a new "auto" mode where we decide the firmware
based on whether we built a cpio image or a disk image. Let's also
use this as the new default.
Install ca-certificates in tools tree and make sure it's used
Too old ca-certificates on the host can cause package manager failures
when using a tools tree, so let's install ca-certificates into the
tools tree and make sure it is used.
Make the empty string reset settings to their default value
If the empty string is assigned, we should make sure the setting
is assigned its default value so let's make sure we return None in
that case after all
We also simplify the match callbacks to not take optional values
anymore. If the value is set to None, then we automatically fail
the match.
This causes issues on CentOS Stream 8 with errors about not being
able to find builtin modules.
Aside from the issues, running modinfo on builtin modules also does
not make a lot of sense. We run modinfo to fetch module and firmware
dependencies, but a builtin module that has non-builtin module
dependencies is not really valuable because the dependent module has
to be loaded from disk then. The same goes for firmware dependencies.
Instead of requiring users to always set up a tools tree preset, let's
allow specifying "default" as the tools tree to have mkosi build a default
tools tree itself. This default tools tree includes all the software that
might be necessary to build an image (excluding software that might be
required by various user scripts).
For distributions that do not have a rolling release variant, we use the
closest matching distribution. e.g. for CentOS, we use Fedora and for
Ubuntu we use Debian.
Only pass extra tools to ukify when not using tools tree
If we're using a tools tree, we don't want to use any binaries
specifed in extra search paths as they will very likely be incompatible
with the tools tree being used.
We generally don't want host configuration to influence the image build,
so let's make sure we override whatever distro shipped configuration file
with an empty one to avoid the host system interfering with the image build.
ci: enable jammy-proposed-updates to test new libzypp
I got some patches backported to jammy to try and fix https issues,
enable proposed-updates so that it can be tested before moving to
the release stage
For distro kernels, depmod is already executed by the package
manager, so let's make sure we don't rerun it unless needed.
To make this work, we have to run depmod and modinfo from inside the
image, as running modinfo from the host on files generated by depmod
from the image can lead to all sorts of compatibility issues so we opt
to run both depmod and modinfo from inside the image.
The only reason that MkosiConfigParser is a class is to store the
lookup hashmaps required for configuration parsing. Yet we can
easily do that as well by just declaring the functions that need
those inline in a function. So let's simplify the configuration
parsing interface by replacing MkosiConfigParser with a function
parse_config().
Replace `!` operator for lists with empty string assignment
Let's behave more like systemd and replace the `!` operator for
removing values from lists with assigning the empty string to remove
all values instead.
Daan De Meyer [Mon, 28 Aug 2023 11:24:59 +0000 (13:24 +0200)]
Rework ini file parsing
Python's configparser module is rather inadequate for our purposes.
Specifically, it's built around every setting only being specified once
in a config file and even though we got it to kind of parse more than
one of the same setting with our own custom dict type, there's a lot of
limitations involved. Specifically, assigning the empty value is
impossible with the current approach. To avoid all these issues, let's
introduce our own ini parser.
This also splits off the matching logic into a new method match_config()
and moves setting the debugging level just after we've parsed CLI options
so we get debug messages from the parser as well.
Daan De Meyer [Mon, 28 Aug 2023 09:35:23 +0000 (11:35 +0200)]
Read paths after parsing configuration files
Let's first take into account the main configuration file before parsing
any configured paths. This allow the main configuration files to reset
any configured settings without resetting its own defaults configured via
paths.
Daan De Meyer [Thu, 31 Aug 2023 09:37:55 +0000 (11:37 +0200)]
Ignore ssh configuration files when running ssh
When in a user namespace, the ssh config files from /etc/ will be
owned by nobody which makes ssh fail. Let's ignore these configuration
files when running ssh to avoid such failures.
Paul Meyer [Fri, 25 Aug 2023 14:53:08 +0000 (16:53 +0200)]
normalize mtime
If set, the time stamp from SOURCE_DATE_EPOCH is used to normalize
mtime of files. We also need to pass the environment trough when
mkosi is invoking itself.