-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework configuration parsing (again) #2847
Conversation
Fits what the function does better.
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.
Doesn't change behavior, just slightly easier to read.
05fb034
to
239ca7c
Compare
This breaks backwards compat in the following ways:
Anyone building single images without using |
Just went to test it out (adjusting my config for this) and noticed that
|
c77e18a
to
491c5e6
Compare
Added both as universal settings.
I've fixed that now by making sure we resolve symlinks in
Have a shared snippet with the |
Also changed the behavior to automatically drop the '@' specifier in mkosi itself to reduce the breakage caused by this PR |
e070b95
to
9249677
Compare
We don't read configuration for the genkey verb anymore so this can be dropped.
We want to check the extension on the resolved path, not on any symlinks, so let's make sure we resolve the path first.
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.
55e6cb7
to
b1efe11
Compare
Added one more fix to make sure that |
Let's also chown the directory to be user owned if located in /tmp or /var/tmp.
In systemd/mkosi#2847, the '@' specifier is removed, CLI arguments take priority over configuration files again and the "main" image is defined at the top level instead of in mkosi.images/. Additionally, not every setting from the top level configuration is inherited by the images in mkosi.images/ anymore, only settings which make sense to be inherited are inherited. This commit gets rid of all the usages of '@', moves the "main" image configuration from mkosi.images/system to the top level and gets rid of various hacks we had in place to deal with quirks of the old configuration parsing logic. We also remove usages of Images= and --append as these options are removed by the mentioned PR.
4830f1d
to
513d638
Compare
In systemd/mkosi#2847, the '@' specifier is removed, CLI arguments take priority over configuration files again and the "main" image is defined at the top level instead of in mkosi.images/. Additionally, not every setting from the top level configuration is inherited by the images in mkosi.images/ anymore, only settings which make sense to be inherited are inherited. This commit gets rid of all the usages of '@', moves the "main" image configuration from mkosi.images/system to the top level and gets rid of various hacks we had in place to deal with quirks of the old configuration parsing logic. We also remove usages of Images= and --append as these options are removed by the mentioned PR.
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.
As explained in systemd#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.
In systemd/mkosi#2847, the '@' specifier is removed, CLI arguments take priority over configuration files again and the "main" image is defined at the top level instead of in mkosi.images/. Additionally, not every setting from the top level configuration is inherited by the images in mkosi.images/ anymore, only settings which make sense to be inherited are inherited. This commit gets rid of all the usages of '@', moves the "main" image configuration from mkosi.images/system to the top level and gets rid of various hacks we had in place to deal with quirks of the old configuration parsing logic. We also remove usages of Images= and --append as these options are removed by the mentioned PR.
In systemd/mkosi#2847, the '@' specifier is removed, CLI arguments take priority over configuration files again and the "main" image is defined at the top level instead of in mkosi.images/. Additionally, not every setting from the top level configuration is inherited by the images in mkosi.images/ anymore, only settings which make sense to be inherited are inherited. This commit gets rid of all the usages of '@', moves the "main" image configuration from mkosi.images/system to the top level and gets rid of various hacks we had in place to deal with quirks of the old configuration parsing logic. We also remove usages of Images= and --append as these options are removed by the mentioned PR.
In systemd/mkosi#2847, the '@' specifier is removed, CLI arguments take priority over configuration files again and the "main" image is defined at the top level instead of in mkosi.images/. Additionally, not every setting from the top level configuration is inherited by the images in mkosi.images/ anymore, only settings which make sense to be inherited are inherited. This commit gets rid of all the usages of '@', moves the "main" image configuration from mkosi.images/system to the top level and gets rid of various hacks we had in place to deal with quirks of the old configuration parsing logic. We also remove usages of Images= and --append as these options are removed by the mentioned PR. (cherry picked from commit 20345a8)
I have two images which are strongly related but neither is a subimage or dependency of the other. What is the best way to have such a configuration with the new config mechanism? More specifically I have a system image and a separate installer. If I move the former to the main image I will not be able to build the latter separate if I understand correctly (or at least I have no clue what to pass on the command line to only build the installer). |
@septatrix My suggestion here is to have two different configuration which you build separate using |
I came up with a different solution in the meantime. I set The directory approach seems a bit annoying because in the installer I need to reference the split artifacts from the system image |
Also: Will |
@septatrix Yes we'll always start the main image now. We had to introduce limitations to the feature to make it usable. We're not aiming for mkosi to be a general purpose build system. If mkosi.images doesn't fit your needs, you'll need to add something on top to orchestrate multiple image builds. |
Okay, in that case I will need to resort to |
It also seems like I need a separate |
|
This works only to a certain degree. |
Yeah I'm sorry about that, but we had to consider all the users not using mkosi.images as well |
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.
This commit implements all of what's mentioned above, specifically:
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/.
which subimages from mkosi.images/ to build. By default all subimages
are built.
are marked as universal. Universal settings are passed on from the
main image configuration to subimage configuration.
Dependencies=.
as they have been deprecated for a long time now.