stages/systemd: don't validate keys

In Python 3.14 configparser started validating keys. We use hacky bits
to write duplicate keys which means we have delimiters in our keys which
is now no longer allowed.

Let's explicitly turn off key validation for now as suggested by
mhroncok in [1].

[1]: https://github.com/osbuild/osbuild/issues/2109#issuecomment-2964585958

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This commit is contained in:
Simon de Vlieger 2025-06-12 08:32:23 +02:00 committed by Simon de Vlieger
parent c3ea64e19e
commit 44cb7934db

View file

@ -34,6 +34,13 @@ def main(tree, options):
# prevent conversion of the option name to lowercase
config.optionxform = lambda option: option
# In Python 3.14 configparser validates key contents and doesn't allow delimiters in them. Due to the hack several
# lines above we explicitly use some interesting behavior to write duplicate keys by including the delimiter in them.
# We need to disable the key validation check. Thanks to mrhoncok [1] for this workaround. In time we should probably
# revisit how we write unit files because configparser isn't the best for this.
# [1]: https://github.com/osbuild/osbuild/issues/2109#issuecomment-2964585958
config._validate_key_contents = lambda key: None # pylint: disable=protected-access
for section, opts in cfg.items():
if not config.has_section(section):
config.add_section(section)