Skip to content

[wip] distro: drop "distro/{fedora,rhel/rhel10}" and name it "distro/generic" - #1537

Closed
mvo5 wants to merge 37 commits into
osbuild:mainfrom
mvo5:yaml-distroconfig-3
Closed

mvo5 wants to merge 37 commits into
osbuild:mainfrom
mvo5:yaml-distroconfig-3

Conversation

@mvo5

@mvo5 mvo5 commented May 16, 2025

Copy link
Copy Markdown
Contributor

This is a spike/WIP branch of the YAMLlification work to showcase the direction. It is conceptually similar to #1462, i.e. this PR will most likely get closed and individual PRs will be created based on the changes/learnings.

With this PR we have no "pkg/distros/fedora" anymore but instead a new "pkg/distro/generic" that integrates into the distrofactory and will offer any distribution that is found in "pkg/distro/defs/distros.yaml". Here "fedora-{43,..,40}" are defined fully in YAML and as the next step we would take one of the rhels and define it as a generic/pure-YAML distro too.

With that we can add the following to distro/defs/distros.yaml:

 - name: simonos-1
    os_version: 1
    release_version: 1
    module_platform_id: platform:f43
    product: "SimonOS"
    iso_label_tmpl: "{{.Product}}-{{.OsVersion}}-{{.ImgTypeLabel}}-{{.Arch}}"
    defs_path: fedora
    runner:
      name: org.osbuild.linux
      build_packages:
        - "glibc"  # ldconfig
        - "systemd"  # systemd-tmpfiles and systemd-sysusers
        - "python3"  # osbuild

and then generate a valid manifest for simonos-1:

$ go build && ./gen-manifests -distros simonos-1 -config config.json -arches x86_64 -types container -output /tmp/ -metadata=false
..
Starting job simonos_1-x86_64-container-.json
Finished job simonos_1-x86_64-container-.json      
...

There is a bunch of work/open questions of course still:

  • rename pkg/distros/def/ -> data/distros/, rename "/distro.yaml" -> "/images.yaml" (strawman names)
  • ensure the new generic/images.go covers and behaves like rhel/images.go (they are extremly similar so fingerscrossed)
  • reporegistry is interesting, I would like to move the repos into the "distros.yaml" and get rid of it entirely but there are backwards compatibity issues that we need to be careful about plus its central to the API right now to get the available images (that one probably needs some careful thinking)
  • the "checkOptions()" code is a huge questions mark, its highly distro specific right now, I hope we can add something like "[allowed,denied}_customzations" to each imagetype to make it generic but its a lot and AFAICT there the test coverage is spotty for them
  • converting all image types for RHEL-X into yaml before we can start defining RHEL-X as a pure-yaml
  • code cleanup/architecture: defs.ImageTypeYAML needs methods for e.g. PartitionTable() instead of the current weird way of calling them, need to think about pkg/distro/generic vs just pkg/distro and/or pkg/distro/defs
  • ...
  • profit!

mvo5 added a commit to mvo5/images that referenced this pull request May 20, 2025
This commit makes the `manifest.RootfsType` marshallable via
JSON/YAML so that we can use it in the image defintions.

This will be useful for:
osbuild#1239
osbuild#1537
mvo5 added a commit to mvo5/images that referenced this pull request May 21, 2025
This commit makes the `manifest.RootfsType` marshallable via
JSON/YAML so that we can use it in the image defintions.

This will be useful for:
osbuild#1239
osbuild#1537
github-merge-queue Bot pushed a commit that referenced this pull request May 21, 2025
This commit makes the `manifest.RootfsType` marshallable via
JSON/YAML so that we can use it in the image defintions.

This will be useful for:
#1239
#1537
@mvo5
mvo5 force-pushed the yaml-distroconfig-3 branch 5 times, most recently from 3543b54 to e6e9bb2 Compare May 22, 2025 20:21
@mvo5 mvo5 changed the title [wip] distro: drop "distro/fedora" and name it "distro/generic" [wip] distro: drop "distro/{fedora,rhel/rhel10}" and name it "distro/generic" May 22, 2025
mvo5 and others added 20 commits May 26, 2025 11:33
Instead of hard-coding the architectures just build them
dynamically from the image type YAML.
This commit goes over the go code and remove parts that are
no longer needed/tweaks because the distro loading is now
more flexible.
This cleans up various yaml issues like indents, trailing spaces, etc.
This commit moves the `fedora` distro definitions into pure
YAML. The goal is to get rid of the `distros/fedora` directory
and to be able to fully define arbitrary distros in YAML.

Note that this introduces a small maintenance regression
(temporarely): when adding a new fedora version it used
to be enough to just drop a "fedora-$ver.json" file into
the `data/repositories` dir and the factory will take care
of providing the distro. With this new YAML 2 extra lines
in `defs/distros.yaml` are needed. This will eventually
become (almost) as simple as before when we merge the
default repositories into `distros.yaml` too (but we
are not there yet, for a preview see:
https://github.com/osbuild/images/compare/main...mvo5:yaml-distroconfig?expand=1
Moving there will also mean thinking about the "old" way
to define/limit what distros are available, i.e. the composer
rpm is using /etc/osbuild-composer/repositories to limit what
distros are buildable.
This commit moves the fedora code to use the `distros.yaml`
file to get the image definitions from there.
This commit adds a new `runner.RunnerConf` that allows to
fully define runners in YAML. This will be used as part
of the `distros.yaml` when defining a distro in pure YAML.
This is another step into generalizing the distro creation by
making use of the new `runner.RunnerConf` to configure the
runner via YAML.
Add a note about moving the default distro image config into
distros.yaml or keep it in the image types file.

Keeping it in the image types file has the advantage that
things are "in-sync" naturally, i.e. when having a
`rhel-10/images.yaml` and `distros.yaml` like this:
```yaml
distros:
 - name: "centos-10"
   defs_dir: ./rhel-10
 - name: "rhel-10.0"
   defs_dir: ./rhel-10
```
there is no need to duplicate the default distro config. OTOH
it feels more "natural" to have the DefaultImageConfig as
part of the above.
This uses a per distro ISO label to customize the label
on the iso images. It needs to be per-distro because the
distros have slightly different layouts.
The "distro/fedora" is finally no longer fedora specific,
it takes all of the data from the distros.yaml and the
<distro_name>/distro.yaml now. Reflect this by renaming
"fedora" -> "generic" and update the defs loader to be
able to load arbitrary distro names and using the
`defs_path` property.

Note that this is most likely not the final layout of
the code, having pkg/disro/defs and pkg/distro/generic
may not be necessary and it might be simpler to just
unify them into a single pkg/distro/$name or even just
pkg/distro. OTOH having the distro "images" functions
in their own pacakge might be nice, so we need to
explore this a bit more.
The UEFIVendor on centos/rhel is set based on the distro
vendor. To support this this new key is used. We should
consider to just remove `UEFIVendor` but for now this
is good enough to get centos going.
This commit moves the image types themselfs into pure YAML
and also moves rhel10 into a generic distro.
Not all image types are available for centos, we need a
way to decide what image types are available where.

This is a crude way of doing it, we must go back to it.
mvo5 added 17 commits May 26, 2025 11:39
We can no longer hardcode the default fstype in the distro
specific go code, it needs to come from the YAML. Add
support for this.
The `osCustomizations()` for the generic distro (originally
fedora) does not know about X11KeymapLayouts customizations.

This commit fixes this (also there should be a bigger
refactor, the amount of data copying we need to do in
osCustomizations() feels a bit much.
This moves the handling of unattended kickstart into YAML, we have
drift between the `imageInstallerImage()` and in fedora we set
additional kernel options (but also have a note there that it
does not work) when the kickstart is set to unattended. But we
do not do that on rhel.
@mvo5

mvo5 commented Jun 2, 2025

Copy link
Copy Markdown
Contributor Author

Closing this in favor of #1577 - most of the points from the original description are addressed there

@mvo5 mvo5 closed this Jun 2, 2025
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