diff --git a/data/distrodefs/README.md b/data/distrodefs/README.md index 9b53ffba6b..5d191dcc0b 100644 --- a/data/distrodefs/README.md +++ b/data/distrodefs/README.md @@ -6,8 +6,9 @@ disk or installer images for rpm based distributions. ## Overview -The definitions start with a "distros.yaml" file that contains details -about the supported distributions and distribution releases. +The definitions start with ".yaml" files that contain details +about the supported distributions and distribution releases. Each +".yaml" file's entries are appended to the previous in sorted order. Note that in order to be available a distribution needs an auxiliary repository JSON file under `./data/repositories` (or in a system @@ -58,10 +59,14 @@ to make a complete new distro. ### distros.yaml -The existing `distros.yaml` contains: +The existing `fedora.yaml` contains: - fedora + +The existing `rhel.yaml` contains: - rhel-{7,8,9,10} - centos-{8,9,10} +- almalinux-{9,10} +- almalinux_kitten-10 #### Example of a real distros.yaml snippet diff --git a/data/distrodefs/fedora.yaml b/data/distrodefs/fedora.yaml new file mode 100644 index 0000000000..5dbf96f8a0 --- /dev/null +++ b/data/distrodefs/fedora.yaml @@ -0,0 +1,65 @@ +--- +distros: + - &fedora_rawhide + name: fedora-44 + distro_like: fedora + preview: true + os_version: 44 + release_version: 44 + module_platform_id: platform:f44 + product: "Fedora" + ostree_ref_tmpl: "fedora/44/%s/iot" + iso_label_tmpl: "{{.Product}}-{{.Distro.MajorVersion}}-{{.ISOLabel}}-{{.Arch}}" + default_fs_type: "ext4" + defs_path: fedora + runner: &fedora_runner + name: org.osbuild.fedora44 + build_packages: + - "glibc" # ldconfig + - "systemd" # systemd-tmpfiles and systemd-sysusers + - "python3" # osbuild + oscap_profiles_allowlist: + - "xccdf_org.ssgproject.content_profile_ospp" + - "xccdf_org.ssgproject.content_profile_pci-dss" + - "xccdf_org.ssgproject.content_profile_standard" + bootstrap_containers: + x86_64: "registry.fedoraproject.org/fedora-toolbox:44" + aarch64: "registry.fedoraproject.org/fedora-toolbox:44" + ppc64le: "registry.fedoraproject.org/fedora-toolbox:44" + s390x: "registry.fedoraproject.org/fedora-toolbox:44" + # XXX: remove once fedora containers are part of the upstream + # fedora registry (and can be validated via tls) + riscv64: "ghcr.io/mvo5/fedora-buildroot:44" + + # XXX: add repos here too, that requires some churn, see + # https://github.com/osbuild/images/compare/main...mvo5:yaml-distroconfig?expand=1 + # and we will also need to think about backward compat, as currently + # dropping "$distro-$ver.json" files into + # /etc/osbuild-composer/repositories will define what distros are + # available via images and we will need to provide compatibility for + # that. + # + # Having the repos separated means when a new fedora release is out + # we will need to update two places which is clearly a regression from + # before. + + - &fedora_stable + <<: *fedora_rawhide + name: "fedora-{{.MajorVersion}}" + match: 'fedora-[1-9][0-9]+' + preview: false + os_version: "{{.MajorVersion}}" + release_version: "{{.MajorVersion}}" + module_platform_id: "platform:f{{.MajorVersion}}" + ostree_ref_tmpl: "fedora/{{.MajorVersion}}/%s/iot" + runner: + <<: *fedora_runner + name: "org.osbuild.fedora{{.MajorVersion}}" + bootstrap_containers: + x86_64: "registry.fedoraproject.org/fedora-toolbox:{{.MajorVersion}}" + aarch64: "registry.fedoraproject.org/fedora-toolbox:{{.MajorVersion}}" + ppc64le: "registry.fedoraproject.org/fedora-toolbox:{{.MajorVersion}}" + s390x: "registry.fedoraproject.org/fedora-toolbox:{{.MajorVersion}}" + # XXX: remove once fedora containers are part of the upstream + # fedora registry (and can be validated via tls) + riscv64: "ghcr.io/mvo5/fedora-buildroot:{{.MajorVersion}}" diff --git a/data/distrodefs/distros.yaml b/data/distrodefs/rhel.yaml similarity index 83% rename from data/distrodefs/distros.yaml rename to data/distrodefs/rhel.yaml index 60e6803ddd..58a1d9fe9e 100644 --- a/data/distrodefs/distros.yaml +++ b/data/distrodefs/rhel.yaml @@ -1,69 +1,5 @@ --- distros: - - &fedora_rawhide - name: fedora-44 - distro_like: fedora - preview: true - os_version: 44 - release_version: 44 - module_platform_id: platform:f44 - product: "Fedora" - ostree_ref_tmpl: "fedora/44/%s/iot" - iso_label_tmpl: "{{.Product}}-{{.Distro.MajorVersion}}-{{.ISOLabel}}-{{.Arch}}" - default_fs_type: "ext4" - defs_path: fedora - runner: &fedora_runner - name: org.osbuild.fedora44 - build_packages: - - "glibc" # ldconfig - - "systemd" # systemd-tmpfiles and systemd-sysusers - - "python3" # osbuild - oscap_profiles_allowlist: - - "xccdf_org.ssgproject.content_profile_ospp" - - "xccdf_org.ssgproject.content_profile_pci-dss" - - "xccdf_org.ssgproject.content_profile_standard" - bootstrap_containers: - x86_64: "registry.fedoraproject.org/fedora-toolbox:44" - aarch64: "registry.fedoraproject.org/fedora-toolbox:44" - ppc64le: "registry.fedoraproject.org/fedora-toolbox:44" - s390x: "registry.fedoraproject.org/fedora-toolbox:44" - # XXX: remove once fedora containers are part of the upstream - # fedora registry (and can be validated via tls) - riscv64: "ghcr.io/mvo5/fedora-buildroot:44" - - # XXX: add repos here too, that requires some churn, see - # https://github.com/osbuild/images/compare/main...mvo5:yaml-distroconfig?expand=1 - # and we will also need to think about backward compat, as currently - # dropping "$distro-$ver.json" files into - # /etc/osbuild-composer/repositories will define what distros are - # available via images and we will need to provide compatibility for - # that. - # - # Having the repos separated means when a new fedora release is out - # we will need to update two places which is clearly a regression from - # before. - - - &fedora_stable - <<: *fedora_rawhide - name: "fedora-{{.MajorVersion}}" - match: 'fedora-[1-9][0-9]+' - preview: false - os_version: "{{.MajorVersion}}" - release_version: "{{.MajorVersion}}" - module_platform_id: "platform:f{{.MajorVersion}}" - ostree_ref_tmpl: "fedora/{{.MajorVersion}}/%s/iot" - runner: - <<: *fedora_runner - name: "org.osbuild.fedora{{.MajorVersion}}" - bootstrap_containers: - x86_64: "registry.fedoraproject.org/fedora-toolbox:{{.MajorVersion}}" - aarch64: "registry.fedoraproject.org/fedora-toolbox:{{.MajorVersion}}" - ppc64le: "registry.fedoraproject.org/fedora-toolbox:{{.MajorVersion}}" - s390x: "registry.fedoraproject.org/fedora-toolbox:{{.MajorVersion}}" - # XXX: remove once fedora containers are part of the upstream - # fedora registry (and can be validated via tls) - riscv64: "ghcr.io/mvo5/fedora-buildroot:{{.MajorVersion}}" - - &rhel10 name: "rhel-{{.MajorVersion}}.{{.MinorVersion}}" match: 'rhel-10\.[0-9]{1,2}' diff --git a/pkg/distro/defs/loader.go b/pkg/distro/defs/loader.go index 0aba211df5..6dc52468ad 100644 --- a/pkg/distro/defs/loader.go +++ b/pkg/distro/defs/loader.go @@ -51,7 +51,9 @@ func dataFS() fs.FS { return dataFS } -// distrosYAML defines all supported YAML based distributions +// distrosYAML defines all supported YAML based distributions, since this can +// come from multiple sources we should make sure that we only have things in +// here that are easily merged type distrosYAML struct { Distros []DistroYAML } @@ -158,22 +160,38 @@ func (d *DistroYAML) runTemplates(id distro.ID) error { return errors.Join(errs...) } +// Load all YAML files directly in the root of the definitions filesystem. Each +// file is read in sorted order and the entries found under the `distros` key +// are appended together. +// Note that files are read separately from each other, so anchors and other +// references can only be done within the same file. func loadDistros() (*distrosYAML, error) { - f, err := dataFS().Open("distros.yaml") + dents, err := fs.Glob(dataFS(), "*.yaml") if err != nil { return nil, err } - defer f.Close() - decoder := yaml.NewDecoder(f) - decoder.KnownFields(true) + var allDistros distrosYAML - var distros distrosYAML - if err := decoder.Decode(&distros); err != nil { - return nil, err + for _, name := range dents { + f, err := dataFS().Open(name) + if err != nil { + return nil, err + } + defer f.Close() + + decoder := yaml.NewDecoder(f) + decoder.KnownFields(true) + + var distros distrosYAML + if err := decoder.Decode(&distros); err != nil { + return nil, err + } + + allDistros.Distros = append(allDistros.Distros, distros.Distros...) } - return &distros, nil + return &allDistros, nil } // NewDistroYAML return the given distro or nil if the distro is not