Skip to content

Extras: User-selectable multiple explicit exports: sysexts and partitions (HMS-11288, HMS-11287) - #2700

Merged
supakeen merged 15 commits into
osbuild:mainfrom
supakeen:extras
Sep 21, 2026
Merged

supakeen merged 15 commits into
osbuild:mainfrom
supakeen:extras

Conversation

@supakeen

Copy link
Copy Markdown
Member

This PR introduces the concept of 'extras' to image-builder and its definitions. extras are specifically-typed additional artifacts with metadata that are part of a single image definition.

Some examples of extras:

  1. Partitions to be exported separately from the main artifacts disk image (for example /usr, /, etc).
  2. sysexts which are built against the main artifacts os pipeline.
  3. Files to be copied out of the main artifacts os pipeline.
  4. Copying out the UKI.
  5. Pipelines as long as they are explicitly listed as an extra for a given image type.

This PR has gone through a lot of cycles and time mostly due to the fact that we wanted to be generic (and kinda implicit) by allowing arbitrary pipeline exports. In the end we always needed explicitness (multiple pipeline exports still need to be listed in YAML) and more explicitness allows for more metadata, hence the addition of an extras.

Extras pipelines are always in the manifest and not conditionally inserted; I consider them to be part of the build and thus they should be able to be built everywhere the manifest goes.

This PR comes with two concrete implementations of extras. sysext (#2662) and partition (#2632) but really they're just in a supporting role here for the idiom of extras.

I'm still not especially fond of some things but I think it's largely in a good enough state to land and iterate on without it blocking any potential use cases or breaking current ones.

Note: extras can practically export multiple pipelines, current ones do not. If we were to do that and those exports would have the same extension then we need to be careful as we can't currently disambiguate in the output-name template. We can introduce that once we cross that bridge. It's fine as long as we have, for example, a single extra export two pipelines: one that creates partition.raw and one that creates a partition.raw.sig or such.


A quick example of how this would look like. Firstly available extras are listed in the output of the describe command. The format is an 'extra reference' which is $type:$name.

€ image-builder describe qcow2
# ...
extras:
  - sysext:nginx
  - sysext:podman
  - partition:usr
# ...

When building the image type normally we get what we expect, however when we build we can enable additional extras to be produced. (In the future we will probably include either globbing for extras an 'all extras' flag).

€ image-builder build
    --with-extra sysext:nginx
    --with-extra sysext:podman
    --with-extra partition:usr
  qcow2
# ...
Image build successful: teamsbc-46-makalu-virt-x86_64/teamsbc-46-makalu-virt-x86_64.raw.xz
Image build successful: teamsbc-46-makalu-virt-x86_64/teamsbc-46-makalu-virt-nginx-x86_64.erofs
Image build successful: teamsbc-46-makalu-virt-x86_64/teamsbc-46-makalu-virt-podman-x86_64.erofs
Image build successful: teamsbc-46-makalu-virt-x86_64/teamsbc-46-makalu-virt-usr-x86_64.raw.xz
€ ls -larth teamsbc-46-makalu-virt-x86_64 
total 710M
drwxr-xr-x. 9 user user 4.0K Sep 18 08:42 ..
-rw-r--r--. 1 root root 472K Sep 18 08:42 teamsbc-46-makalu-virt-x86_64.osbuild-manifest.json
-rw-r--r--. 1 root root 270M Sep 18 08:45 teamsbc-46-makalu-virt-usr-x86_64.raw.xz
-rw-r--r--. 1 root root 351M Sep 18 08:45 teamsbc-46-makalu-virt-x86_64.raw.xz
-rw-r--r--. 1 root root 3.6M Sep 18 08:48 teamsbc-46-makalu-virt-nginx-x86_64.erofs
-rw-r--r--. 1 root root  86M Sep 18 08:50 teamsbc-46-makalu-virt-podman-x86_64.erofs
-rw-r--r--. 1 root root 114K Sep 18 08:50 teamsbc-46-makalu-virt-x86_64.buildlog

This doesn't yet implement extras for bootable container based systems. However this will be a follow-up. We'll do that by allowing bootable containers to supply an extras.yaml file in the well-known locations we use for other sources of configuration: https://osbuild.org/docs/developer-guide/projects/image-builder/advanced/bootc/sources-of-configuration/#filesystem

Replace `ExcludeDocs`, `GPGKeyFiles`, `InstallLangs`, `ImageID`,
`ImageVersion` and `RPMKeysBinary` fields that are all in
`OSCustomizations` with a single `BaseRPMOptions`.

This makes it easier in the future to store the same `BaseRPMOptions`
onto other customizations so multiple pipelines can use the same
customizations.

Signed-off-by: Simon de Vlieger <[email protected]>
`NewXZ`, `NewZstd`, `NewGzip` and `GetCompressionPipeline` get a `name`
argument. If it's empty then the previous default name is used.

This is necessary so we can export multiple artifacts in the future.
Currently we can't have two pipelines with the same name so pipelines
that can appear multiple times need to have unique names (or be set to
unique names).

Signed-off-by: Simon de Vlieger <[email protected]>
Allow defining `extras` for image types. Extras are things that are
built 'on top of' (or together with) an image type and thus they are
intimately coupled together.

As an example you can take `systemd` sysexts which are the diff between
an OS pipeline and another pipeline. Files inside the image that need to
be exported separately. Partitions that we want to export separately as
well.

This commit only makes *room* for those extras to be defined in the
future. This is so that it can land independent of what extras we decide
to implement.

Signed-off-by: Simon de Vlieger <[email protected]>
@supakeen
supakeen requested a review from a team as a code owner September 18, 2026 06:53
@supakeen supakeen changed the title many: extras (user-selectable multiple explicit exports) many: extras (user-selectable multiple explicit exports) (HMS-11288) Sep 18, 2026
Create new pipeline generators (`SysextTree` and `SystextPrep`) that are
to be used to build `systemd` systemd extensions in the future.

`SysextTree` installs packages into a tree using the same RPM options
(passed through Customizations) and (optionally) the same packages from
a reference pipeline.

`SysextPrep` (prepare) diffs the `SysextTree` against a filesystem
reference pipeline which would usually be the `OS` pipeline or a
pipeline that contains a `bootc` deployment. The `SyextPrep` tree then
contains only file differences between these two pipelines.

Signed-off-by: Simon de Vlieger <[email protected]>
Add `sysext` as an extras type. These extras are made up of a
name (key) and a package set that will be plumbed into the image
functions to generate additional pipelines when defined.

Signed-off-by: Simon de Vlieger <[email protected]>
Generate pipelines in the image generators if sysexts are defined in the
definitions.

That includes copying around some fields and bits and bobs and injecting
the appropriate pipelines including one dependent on the format of the
sysext.

Signed-off-by: Simon de Vlieger <[email protected]>
Create a new `PartitionImage` pipeline which takes in a previous
pipeline which generated a (raw) image and then extracts a given
partition from it. The partition is (currenltly) selectable by its mount
point only.

Signed-off-by: Simon de Vlieger <[email protected]>
Add `partitions` as a new extras type alongside sysexts. Each partition
defines a mountpoint to extract into a separate extra with an optional
filename and compression.

This allows to split out partitions (for example `/usr`) together with
the full image build.

Signed-off-by: Simon de Vlieger <[email protected]>
Plumb the partitions definitions from the loader through imagetype into
the `DiskImage` pipeline generator.

Each split parttition extracts its partition from the raw image with an
optional compression pipeline.

Signed-off-by: Simon de Vlieger <[email protected]>
We need an easy way to go from 'human' names to pipeline names and an
easy way to list available extras for an image type.

`ExportPipelineNames()` is the former. It uses the same plumbing as is
used for generating the pipeline names in the image functions so they
always match.

`Extras` just returns a pre-formatted list of `type:name` pairs for
extras.

Signed-off-by: Simon de Vlieger <[email protected]>
Add tests that assert output name behavior before we start touching the
code for it. This ensures we don't accidentally break something.

`TestDefaultOutputTmplBackwardCompat` tests that the default output
template produces `{distro}-{imagetype}-{arch}`.

`TestBuildIntegrationSingleOutput` ensures that a build (without
additional flags) produces one image and has the expected file.

`TestOutputFilenameStable` makes sure that the output filename and its
extension match what's defined in `.Filename()` (because we'll drop its
usage in a follow-up commit).

Signed-off-by: Simon de Vlieger <[email protected]>
Support passing extras one the command line which are exported together
with the main export; which is the export as defined in the image type.

This is an explicit way for the user to opt-in to exporting additional
artifacts. In the future other extras can be added to allow for named
pipelines to be exported, or other bits and bobs.

This follows pretty lengthy chats and discussions around allowing the
export of any pipeline. For now we opt for the explicit route, only
extras defined can be exported so we have the additional metadata to do
this right.

Signed-off-by: Simon de Vlieger <[email protected]>
Fail early when a requested extra does not exist, before manifest
generation and the build so we're a bit quicker and don't have users
passing nonexistent extras.

Signed-off-by: Simon de Vlieger <[email protected]>
Show available extras by name in the describe subcommand output. This
lets users discover which extras are available for `--with-extras`.

Signed-off-by: Simon de Vlieger <[email protected]>
@supakeen

supakeen commented Sep 19, 2026 •

Copy link
Copy Markdown
Member Author

Though I didn't want this PR to be too much about the concrete extras themselves (more the concept of extras) we're bound to have some ideas/questions for them.


How should the partition splitting work for volume-based mountpoints (btrfs, lvm). I think it'd be OK to export the partition that the volume is on and I have a commit I can squash in that does just that.

Right now in this PR it fails if people define a partition extra that refers to a btrfs subvolume or such.

If a mount point is inside a container type then we walk up to the plain
partition and export the entire thing instead of erroring out during
manifest generation.

Perhaps this behavior is debatable but when documented I think it's
right; and there's not really anything else we can do *except* not
supporting this.

Signed-off-by: Simon de Vlieger <[email protected]>
@supakeen

Copy link
Copy Markdown
Member Author

Though I didn't want this PR to be too much about the concrete extras themselves (more the concept of extras) we're bound to have some ideas/questions for them.

How should the partition splitting work for volume-based mountpoints (btrfs, lvm). I think it'd be OK to export the partition that the volume is on and I have a commit I can squash in that does just that.

Right now in this PR it fails if people define a partition extra that refers to a btrfs subvolume or such.

I've pushed my commit that does this (it's the last one).

@supakeen supakeen changed the title many: extras (user-selectable multiple explicit exports) (HMS-11288) many: extras (user-selectable multiple explicit exports) (HMS-11288, HMS-11287) Sep 21, 2026

@achilleas-k achilleas-k left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice work on all of this. I'm very happy with how the new pipelines look. Still not entirely happy with the way we define these, but we're not locked into that so we can see how it feels going forward and iterate.

Thank you.

LGTM!

Regarding the last commit (exporting volumes from inside containers): I agree that the behaviour in the PR is probably the best workaround for btrfs subvolumes, but I think for LVM logical volumes, it's possible to dd the logical volume separately instead of the whole partition (volume group), isn't it?

Comment thread cmd/image-builder/cmd.go
SilenceUsage: true,
Args: cobra.ExactArgs(1),
}
buildCmd.Flags().StringArray("with-extra", nil, `include an extra by type:name in the build (e.g. --with-extra sysext:nginx)`)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think instead of an example it would be more useful to mention where one can find the supported extras. Pointing users towards using describe to get a list of supported extra names would be better.

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.

Agreed, but let's not back it out over this 🙂

@achilleas-k achilleas-k changed the title many: extras (user-selectable multiple explicit exports) (HMS-11288, HMS-11287) Extras: User-selectable multiple explicit exports: sysexts and partitions (HMS-11288, HMS-11287) Sep 21, 2026
@supakeen
supakeen added this pull request to the merge queue Sep 21, 2026
Merged via the queue into osbuild:main with commit 03f0ebc Sep 21, 2026
56 checks passed
@supakeen
supakeen deleted the extras branch September 21, 2026 20:16
@supakeen supakeen mentioned this pull request Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants