Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions pkg/distro/defs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ Conditions can be used and *only* the "append" action is supported,
this means that the packages from the conditions is appended to the
original package sets.

### platforms_override

This can be used to override the platforms for the image type based
on some condition. See the rhel-8 "ami" image type for an example
where the `aarch64` architecture is only available for rhel-8.9+.

### conditions

Conditions are expressed using the following form:
Expand Down Expand Up @@ -112,11 +118,12 @@ shared and merge via the `<<:` operation.

The `when` part of the condition can contain one or more
of:
- distro_name
- arch
- version_less_than
- version_equal
- version_greater
- `distro_name`
- `not_distro_name`
Copy link
Member

Choose a reason for hiding this comment

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

Why is this in backticks unlike the others?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put all into backticks now, my editor was making the distro part of not_distro_name italic, but maybe that is just an artifact and GH is rendering it fine I did not double check.

- `arch`
- `version_less_than`
- `version_equal`
- `version_greater`
If multiple conditions are given under `when` they are
considered logical AND and only if they all match is
the condition executed.
Expand Down
81 changes: 76 additions & 5 deletions pkg/distro/defs/distros.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ distros:
- ec2
- ec2-sap
- ec2-ha
# rhel9 & cs9 share the same list
# of allowed profiles so a single
# allow list can be used
oscap_profiles_allowlist: &oscap_profile_allowlist_rhel10
# rhel & centos share the same list of allowed profiles so a
# single allow list can be used
oscap_profiles_allowlist: &oscap_profile_allowlist_rhel
- "xccdf_org.ssgproject.content_profile_anssi_bp28_enhanced"
- "xccdf_org.ssgproject.content_profile_anssi_bp28_high"
- "xccdf_org.ssgproject.content_profile_anssi_bp28_intermediary"
Expand Down Expand Up @@ -138,7 +137,7 @@ distros:
runner:
name: org.osbuild.centos10
build_packages: *rhel10_runner_build_packages
oscap_profiles_allowlist: *oscap_profile_allowlist_rhel10
oscap_profiles_allowlist: *oscap_profile_allowlist_rhel

- <<: *centos10
name: "almalinux_kitten-10"
Expand All @@ -149,6 +148,78 @@ distros:
vendor: "almalinux"
ostree_ref_tmpl: "almalinux/10/%s/edge"

- &rhel8
name: "rhel-{{.MajorVersion}}.{{.MinorVersion}}"
match: "rhel-8.[0-9]{,[0-9]}"
# rhel8 support being named "rhel-81" for "rhel-8.1" or "rhel-810" for "rhel-8.10" etc
transform_re: "^(?P<name>rhel)-(?P<major>8)(?P<minor>[0-9]{1,2})$"
distro_like: rhel-8
product: "Red Hat Enterprise Linux"
os_version: "8.{{.MinorVersion}}"
release_version: 8
module_platform_id: "platform:el8"
vendor: "redhat"
ostree_ref_tmpl: "rhel/8/%s/edge"
default_fs_type: "xfs"
defs_path: rhel-8
iso_label_tmpl: "RHEL-{{.Distro.MajorVersion}}-{{.Distro.MinorVersion}}-0-BaseOS-{{.Arch}}"
conditions:
"edge image types require FDO which aren't available on older versions":
when:
version_less_than: "8.6"
ignore_image_types:
- "edge-simplified-installer"
- "edge-raw-image"
"azure eap7 is only available for rhel8.6+":
when:
version_less_than: "8.6"
ignore_image_types:
- "azure-eap7-rhui"
"Azure image types require hyperv-daemons which isn't available on older versions":
when:
version_less_than: "8.6"
arch: "aarch64"
ignore_image_types:
- "azure-rhui"
- "vhd"
runner:
name: "org.osbuild.rhel{{.MajorVersion}}{{.MinorVersion}}"
build_packages: &rhel8_runner_build_packages
- "glibc" # ldconfig
- "systemd" # systemd-tmpfiles and systemd-sysusers
- "platform-python" # osbuild
# The RHEL 8 runner in osbuild runs with platform-python but
# explicitly symlinks python 3.6 to /etc/alternatives (which in turn
# is the target for /usr/bin/python3) for the stages.
# https://github.com/osbuild/osbuild/blob/ea8261cad6c5c606c00c0f2824c3f483c01a0cc9/runners/org.osbuild.rhel82#L61
# Install python36 explicitly for RHEL 8.
- "python36"
oscap_profiles_allowlist: *oscap_profile_allowlist_rhel
bootstrap_containers:
x86_64: "registry.access.redhat.com/ubi{{.MajorVersion}}/ubi:latest"
aarch64: "registry.access.redhat.com/ubi{{.MajorVersion}}/ubi:latest"
ppc64le: "registry.access.redhat.com/ubi{{.MajorVersion}}/ubi:latest"
s390x: "registry.access.redhat.com/ubi{{.MajorVersion}}/ubi:latest"

- &centos8
<<: *rhel8
name: centos-8
distro_like: rhel-8
product: "CentOS Stream"
os_version: "8-stream"
vendor: "centos"
default_fs_type: "xfs"
iso_label_tmpl: "CentOS-Stream-{{.Distro.MajorVersion}}-BaseOS-{{.Arch}}"
runner:
name: org.osbuild.centos8
build_packages: *rhel8_runner_build_packages
oscap_profiles_allowlist: *oscap_profile_allowlist_rhel
bootstrap_containers:
# we need the toolbox container because stock centos has e.g. no
# mount util
x86_64: "quay.io/toolbx-images/centos-toolbox:stream{{.MajorVersion}}"
aarch64: "quay.io/toolbx-images/centos-toolbox:stream{{.MajorVersion}}"

- &rhel7
name: "rhel-{{.MajorVersion}}.{{.MinorVersion}}"
match: "rhel-7.[0-9]{,[0-9]}"
Expand Down
23 changes: 16 additions & 7 deletions pkg/distro/defs/fedora/distro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
- "org.fedoraproject.Anaconda.Modules.Users"
additional_dracut_modules:
- "net-lib"
- "dbus-broker"
squashfs_rootfs: true
conditions:
"f41 dracut requires ifcfg, rootfs is squashfs":
Expand All @@ -183,12 +184,14 @@
shallow_merge:
additional_dracut_modules:
- "ifcfg"
- "dbus-broker"
"f40 and lower uses ifcfg in dracut and squashfs+ext4 rootfs":
when:
version_less_than: "41"
shallow_merge:
additional_dracut_modules:
- "ifcfg"
- "dbus-broker"
squashfs_rootfs: false

image_config:
Expand Down Expand Up @@ -770,8 +773,9 @@ image_types:
payload_pipelines: ["os", "ostree-commit", "commit-archive"]
exports: ["commit-archive"]
required_partition_sizes: *default_required_dir_sizes
image_config:
image_config: &image_config_iot_commit
<<: *image_config_iot_enabled_services
install_weak_deps: false
dracut_conf:
- filename: "40-fips.conf"
config:
Expand Down Expand Up @@ -930,6 +934,9 @@ image_types:
payload_pipelines: ["os", "ostree-commit", "container-tree", "container"]
exports: ["container"]
required_partition_sizes: *default_required_dir_sizes
image_config:
<<: *image_config_iot_commit
install_weak_deps: true
platforms:
- *x86_64_installer_platform
- *aarch64_installer_platform
Expand All @@ -944,8 +951,8 @@ image_types:
bootable: true
image_func: "iot"
ostree:
name: "fedora"
remote: "fedora-iot"
name: "fedora-iot"
remote_name: "fedora-iot"
build_pipelines: ["build"]
payload_pipelines: ["ostree-deployment", "image", "xz"]
exports: ["xz"]
Expand Down Expand Up @@ -1023,8 +1030,8 @@ image_types:
bootable: true
image_func: "iot"
ostree:
name: "fedora"
remote: "fedora-iot"
name: "fedora-iot"
remote_name: "fedora-iot"
build_pipelines: ["build"]
payload_pipelines: ["ostree-deployment", "image", "qcow2"]
exports: ["qcow2"]
Expand Down Expand Up @@ -1488,9 +1495,10 @@ image_types:
boot_iso: true
image_func: "iot_installer"
iso_label: "IoT"
variant: "IoT"
ostree:
name: "fedora-iot"
remote: "fedora-iot"
remote_name: "fedora-iot"
build_pipelines: ["build"]
payload_pipelines:
- "anaconda-tree"
Expand Down Expand Up @@ -1843,9 +1851,10 @@ image_types:
default_size: 10_737_418_240 # 10 * datasizes.GibiByte
image_func: "iot_simplified_installer"
iso_label: "IoT"
variant: "IoT"
ostree:
name: "fedora"
remote: "fedora-iot"
remote_name: "fedora-iot"
build_pipelines: ["build"]
payload_pipelines:
- "ostree-deployment"
Expand Down
32 changes: 32 additions & 0 deletions pkg/distro/defs/id.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package defs

import (
"fmt"
"regexp"

"github.com/osbuild/images/pkg/distro"
)

// ParseID parse the given nameVer into a distro.ID. It will also
// apply any matching `transform_re`. This is needed to support distro
// names like "rhel-810" without dots.
//
// If no transformations are needed it will return "nil"
func ParseID(nameVer string) (*distro.ID, error) {
distros, err := loadDistros()
if err != nil {
return nil, err
}

for _, d := range distros.Distros {
re, err := regexp.Compile(d.TransformRE)
if err != nil {
return nil, err
}
if l := re.FindStringSubmatch(nameVer); len(l) == 4 {
transformed := fmt.Sprintf("%s-%s.%s", l[re.SubexpIndex("name")], l[re.SubexpIndex("major")], l[re.SubexpIndex("minor")])
return distro.ParseID(transformed)
}
}
return nil, nil
}
Loading
Loading