Respect user-provided values for split artifacts and implement match patterns
Only use default suffixes for split artifacts if the user didn't provide a name. Ask for names instead of paths for split artifacts and always place them in the output directory. Otherwise the SHA256SUMS file won't work.
Closes #1177
To include version, partition UUID or partition size in the filenames add the patterns to the output configuration flags.
OutputSplitRoot=ExampleOS_@v_@[email protected]
OutputSplitVerity=ExampleOS_@v_@[email protected]
[email protected]
Right now partitions allow @v, @u, @s and @r while the kernel only allows @v.
Marked as draft as files with match patterns aren't cleaned up yet.
This is ready for review.
I've tested these changes and they work like a charm :smile: . It would be appreciated if you'd also add a couple more substitution options:
-
@i: Image ID -
@z: Default suffix
This is the configuration with just your changes now.
[Output]
ImageID = FooBarOS
Verity = Yes
SplitArtifacts = Yes
CompressOutput = xz
OutputSplitRoot = FooBarOS_@[email protected]
OutputSplitVerity = FooBarOS_@[email protected]
With these additional changes the updated configuration is below.
[Output]
ImageID = FooBarOS
Verity = Yes
SplitArtifacts = Yes
CompressOutput = xz
OutputSplitRoot = @i_@v_@u.@z
OutputSplitVerity = @i_@v_@u.@z
Remember that mkosi supports defaults and overrides for configuration options, which means overriding CompressOutput= or ImageID= could be done without changing these output templates.
Just because I think it's a good idea doesn't mean that it is, but like most humans I have an opinion.
@i: Image ID@z: Default suffix
This seems useful.
In addition I would change the Output= option into a match pattern so the primary image and all other artifacts can use wildcards as well. But this likely requires some refactoring so I'd postpone this until after this PR lands.
@DaanDeMeyer, @behrmann I'd recommend we run with this PR over #1133. Can you take a look and I'll (likely) close off the other PR?
@pyfisch Still traveling this week. Will have a closer look Sunday or Monday.
Heads up that I'm implementing support for this in systemd-repart (https://github.com/systemd/systemd/pull/24746) along with a few other things so once we merge repart support we'll drop most of this again
@DaanDeMeyer The repart addition to systemd looks interesting but it's the sysupdate tool that needs the UUID information the most. I think we're likely to see these changes remain in mkosi.
@mcassaniti The idea is to do all disk image handling with repart, so we implement the split output formatting in repart, and mkosi will just forward the format string to repart's SplitName= option. I already added a specifier to SplitName= to insert the partition UUID.
@DaanDeMeyer It's great that split artifacts will be added to repart.
Quote by @DaanDeMeyer https://github.com/systemd/mkosi/issues/1124#issuecomment-1217875990:
I almost want to start distributing statically linked versions of nspawn, repart, and dissect with mkosi just so we can finally move forward a bit instead of waiting ages for distros to catch up.
If repart would be distributed with mkosi the implementation in repart could be used in a few weeks instead of years. I use a rolling release distribution so I will have access to the --split option in repart relatively soon either way (although not necessarily integrated into mkosi).
Is it a good idea to still add this to mkosi if it will be replaced in the future? Does anyone want to use split artifacts with match patterns on distributions with long term support?
If I take a look at what every other project does in this space it's usually add the feature and require a specific version of supporting tools when it makes sense.
Considering mkosi offers a GitHub action and a lot of workflows are using Ubuntu 20.04, it's either bundle static binaries or support systemd v245.
Considering mkosi offers a GitHub action and a lot of workflows are using Ubuntu 20.04, it's either bundle static binaries or support systemd v245.
We already require 22.04 on Github Actions for the github action to work, though the same issue still exists there since systemd will still be out of date. I'll look into providing a static version of repart for Ubuntu to circumvent this issue.
I think systemd-repart will be the preferred way to create GPT images and split artifacts in the future. For this reason I won't continue on this PR.