Skip to content

Various tweaks to make mkosi-initrd easier to use - #4227

Merged
daandemeyer merged 6 commits into
systemd:mainfrom
keszybz:mkosi-initrd-stuff
Mar 23, 2026
Merged

Various tweaks to make mkosi-initrd easier to use#4227
daandemeyer merged 6 commits into
systemd:mainfrom
keszybz:mkosi-initrd-stuff

Conversation

@keszybz

@keszybz keszybz commented Mar 21, 2026

Copy link
Copy Markdown
Member

No description provided.

@github-actions

github-actions Bot commented Mar 21, 2026

Copy link
Copy Markdown

Claude review of PR #4227 (066034d)

Must fix

  • Copy-paste error in --show-summary man pagemkosi/resources/man/mkosi-initrd.1.md:69 — Description says "Show the man page" instead of describing the summary feature
  • List reset broken for default delimitermkosi/config.py:1248values == ["] is unreachable when delimiter is None because "".split() returns [], not ["], so setting a list option to empty no longer resets it
  • Copy-paste error in --show-documentation for mkosi-addonmkosi/resources/man/mkosi-addon.1.md:47 — Description says "Show the man page for mkosi-initrd" but this is the mkosi-addon man page; should say "Show the man page for mkosi-addon"

Suggestions

  • Whitespace splitting may break values with spaces (dismissed) — mkosi/config.py:1243 — The new default value.replace(",", " ").split() treats all whitespace as delimiters, which would break path-valued settings containing spaces (e.g. ExtraTree, SkeletonTree, BaseTree)
  • --show-summary not handled in addon.pymkosi/initrd.py:296 — The argument is added to shared initrd_common_args() but addon.py does not check it, so mkosi-addon -S is silently accepted and ignored
  • --show-summary not documented in mkosi-addon man pagemkosi/resources/man/mkosi-initrd.1.md:68 — The option is added to initrd_common_args() and handled in both initrd.py and addon.py, and documented in mkosi-initrd.1.md, but mkosi-addon.1.md is not updated to list it
  • Configuration paths in man page are ambiguous (dismissed) — mkosi/resources/man/mkosi-initrd.1.md:73 — The text says configuration is read from /usr/lib, /usr/local/lib, /run, /etc but include_system_config() actually reads from mkosi-initrd/ subdirectories under those paths (e.g. /etc/mkosi-initrd/). Consider listing the full paths for clarity

Nits

  • Empty set truthiness change in make_cpiomkosi/__init__.py:1547required_kernel_modules now returns a set (falsy when empty) instead of a generator (always truthy), which could trigger make_cpio's fallback of archiving everything if the set is ever empty
  • Stale help text for ExtraSearchPathmkosi/config.py:3852 — Help says "List of comma-separated paths" but the parser now also accepts whitespace as a separator
  • Commit message typoCommit c6de23a subject says "mkosi-initd" instead of "mkosi-initrd" (fixed after rebase)

Workflow run

Comment thread mkosi/run.py Fixed
Comment thread mkosi/resources/man/mkosi-initrd.1.md Outdated
Comment thread mkosi/config.py Outdated
Comment thread mkosi/config.py
if reset and len(values) == 1 and values[0] == "":
if delimiter is None:
# by default, split on commas and any whitespace
values = value.replace(",", " ").split()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude: suggestion: The new default value.replace(",", " ").split() treats all whitespace as delimiters. The old behavior with delimiter="," was value.replace(",", "\n").split("\n"), which preserved spaces within values.

This matters for settings whose values can contain spaces, particularly path-valued settings like ExtraTree, SkeletonTree, BaseTree, RuntimeTree, SandboxTree, PackageDirectory, etc. A config value like /path/to my files would now be split into three tokens.

While rare in practice, this is a silent behavior change that could break existing configurations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed extensively in the commit message, this is intentional.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really not sure we should break this compat. While we both probably abhor whitespace in path names, I fear they might be not unheard of nowadays.

Comment thread mkosi/__init__.py
@keszybz
keszybz force-pushed the mkosi-initrd-stuff branch from c0b2879 to 69b96c0 Compare March 21, 2026 12:37
Comment thread mkosi/initrd.py
Comment thread mkosi/config.py Outdated
@keszybz
keszybz force-pushed the mkosi-initrd-stuff branch 2 times, most recently from c6de23a to 8b08663 Compare March 21, 2026 14:09
Comment thread mkosi/resources/man/mkosi-addon.1.md Outdated
Comment thread mkosi/resources/man/mkosi-initrd.1.md
Comment thread mkosi/resources/man/mkosi-initrd.1.md
Comment thread mkosi/run.py Outdated
Comment thread mkosi/kmod.py Outdated
Comment thread mkosi/kmod.py
Comment thread mkosi/config.py
if reset and len(values) == 1 and values[0] == "":
if delimiter is None:
# by default, split on commas and any whitespace
values = value.replace(",", " ").split()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really not sure we should break this compat. While we both probably abhor whitespace in path names, I fear they might be not unheard of nowadays.

Comment thread mkosi/resources/man/mkosi-addon.1.md Outdated
Comment thread mkosi/resources/man/mkosi-initrd.1.md Outdated
The tools that mkosi invokes are often quite verbose. So let's also
print what those executed commands are by default. This makes it
easier to figure out what is going on and doesn't change the total
number of printed lines too much.
@keszybz

keszybz commented Mar 22, 2026

Copy link
Copy Markdown
Member Author

I'm really not sure we should break this compat. While we both probably abhor whitespace in path names, I fear they might be not unheard of nowadays.

For some reason github doesn't allow me to reply under that comment. But maybe it's better to break it out into a top-level thread anyway.

So… I thought about excluding those "user-controlled paths" from this change too. If you think that's better, I can do that. Nevertheless, I seriously doubt that mkosi users are using any paths with spaces. Actually, UNIX paths are allowed to embed commas too (and newlines, FWIW), so the syntax already wasn't allowing some kinds of paths. @daandemeyer WDYT?

keszybz added 5 commits March 22, 2026 12:30
This makes the callers a bit simpler because then they don't need
to do explicit conversions of the returned object.

There are a few callers which previously turned the value into a
set, and one other caller which passed the value to make_cpio,
which turns it into a list with sorted(files). So the change should
be a noop.
Configuration like 'FirmwareFiles=intel/ibt-0093-* intel/ipu/*' would be
interpreted as a single word. This is surprising and not useful. In
practice, none of the names that we use should ever have a space in
them. Change the parsing for host names, profile names, artifact output
lists, includes, dependency names, scripts, repository names, manifest
formats, repart directories, packages, package directories, trees, files
to remove, uki profiles, initrds, device trees, module and firmware
include/exclude lists to accept any-whitespace|comma instead of just
newline|comma as separators.

(The parsers that used space|newline as separators are not touched.)

Arguably, this is a compat break. But I think it's unlikely to matter in
any practical case and the removal of the surprising behaviour is more
important. The case where a space would be most likely to be used is
RemoveFiles… Fortunately that setting takes a glob so the user can just
"escape" the path with space as '?' or something to make it work.
This is quite useful to figure out what configuration is used.

(I considered adding an option to allow arbitrary mkosi verbs.
But most verbs either don't make sense or don't work. E.g. 'shell'
could be potentially useful but it doesn't support cpio atm. So
limiting this to 'summary' for now seems OK. Having an easy way
to show the config will be useful even if we add a more generic
hookup into mkosi later.)
@keszybz
keszybz force-pushed the mkosi-initrd-stuff branch from 8b08663 to 066034d Compare March 22, 2026 11:31
Comment thread mkosi/run.py Dismissed
@behrmann

Copy link
Copy Markdown
Contributor

Actually, UNIX paths are allowed to embed commas too (and newlines, FWIW), so the syntax already wasn't allowing some kinds of paths.

That's true, everything but null bytes and path separators is fine, but I think of the "weird" characters, spaces are by far the most common. I've seen commas used in file names, but we never supported this and nobody ever complained about this, so I guess nobody ever ran into this. We have had users running into the problem that they assumed whitespace would split, so I agree this is a real issue for users, but I'm not sure exchanging one for the other is the solution.

I think a way to have our cake and eat it, too, would be to run everything through shlex (the unescape branch above), so that spaces could be escaped.

@keszybz

keszybz commented Mar 22, 2026

Copy link
Copy Markdown
Member Author

I think a way to have our cake and eat it, too, would be to run everything through shlex (the unescape branch above), so that spaces could be escaped.

Yes, that could be done too. But that's a compat break too. I'd be happy to implement that, if there's agreement that this is the way to go.

@daandemeyer

Copy link
Copy Markdown
Contributor

I agree with @keszybz, I think it will be extremely unlikely to see paths with spaces in mkosi config files, let's take a a risk here, though I won't stop anyone from implementing the shlex solution in a follow up PR either.

@daandemeyer
daandemeyer merged commit 05bc826 into systemd:main Mar 23, 2026
55 checks passed
@keszybz
keszybz deleted the mkosi-initrd-stuff branch March 26, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants