From 2a3aafe6b4c644e04b57c1dca9239d271359db7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Sch=C3=BCller?= Date: Fri, 5 Apr 2024 16:03:17 +0200 Subject: [PATCH] tests: fix tests due to restructuring images repo COMPOSER-2185 Just a followup of https://issues.redhat.com/browse/COMPOSER-2185 and it's PR https://github.com/osbuild/images/pull/529 also updating images and osbuild-composer repos --- cmd/osbuild-dnf-json-tests/main_test.go | 2 +- internal/cloudapi/v2/imagerequest_test.go | 2 +- .../images/pkg/customizations/oscap/oscap.go | 3 + .../images/pkg/distro/{rhel9 => rhel}/arch.go | 34 +- .../images/pkg/distro/rhel/defaults.go | 32 + .../images/pkg/distro/rhel/distribution.go | 135 ++++ .../pkg/distro/{rhel9 => rhel}/images.go | 130 ++-- .../images/pkg/distro/rhel/imagetype.go | 346 ++++++++++ .../images/pkg/distro/rhel/rhel10/ami.go | 286 +++++++++ .../images/pkg/distro/rhel/rhel10/azure.go | 303 +++++++++ .../pkg/distro/rhel/rhel10/bare_metal.go | 26 + .../images/pkg/distro/rhel/rhel10/distro.go | 242 +++++++ .../images/pkg/distro/rhel/rhel10/options.go | 79 +++ .../pkg/distro/rhel/rhel10/package_sets.go | 78 +++ .../distro/rhel/rhel10/partition_tables.go | 179 ++++++ .../images/pkg/distro/rhel/rhel10/qcow2.go | 200 ++++++ .../images/pkg/distro/rhel/rhel10/ubi.go | 96 +++ .../images/pkg/distro/rhel/rhel10/vmdk.go | 80 +++ .../images/pkg/distro/{ => rhel}/rhel9/ami.go | 283 ++++----- .../pkg/distro/{ => rhel}/rhel9/azure.go | 223 +++---- .../pkg/distro/{ => rhel}/rhel9/bare_metal.go | 81 +-- .../images/pkg/distro/rhel/rhel9/distro.go | 401 ++++++++++++ .../pkg/distro/{ => rhel}/rhel9/edge.go | 397 ++++++------ .../images/pkg/distro/{ => rhel}/rhel9/gce.go | 89 ++- .../images/pkg/distro/rhel/rhel9/options.go | 192 ++++++ .../distro/{ => rhel}/rhel9/package_sets.go | 21 +- .../{ => rhel}/rhel9/partition_tables.go | 17 +- .../pkg/distro/{ => rhel}/rhel9/qcow2.go | 122 ++-- .../images/pkg/distro/{ => rhel}/rhel9/sap.go | 3 +- .../images/pkg/distro/{ => rhel}/rhel9/ubi.go | 35 +- .../images/pkg/distro/rhel/rhel9/vmdk.go | 80 +++ .../osbuild/images/pkg/distro/rhel9/distro.go | 592 ------------------ .../images/pkg/distro/rhel9/imagetype.go | 490 --------------- .../osbuild/images/pkg/distro/rhel9/vmdk.go | 69 -- .../images/pkg/distrofactory/distrofactory.go | 5 +- .../images/pkg/distroidparser/idparser.go | 5 +- .../osbuild/images/pkg/dnfjson/dnfjson.go | 10 +- .../osbuild/images/pkg/image/bootc_disk.go | 43 +- .../osbuild/images/pkg/manifest/build.go | 7 +- .../osbuild/images/pkg/manifest/pipeline.go | 2 +- .../osbuild/images/pkg/manifest/raw_bootc.go | 142 +++++ .../bootc_install_to_filesystem_stage.go | 16 +- .../pkg/osbuild/container_deploy_stage.go | 2 +- .../images/pkg/osbuild/selinux_stage.go | 1 + .../pkg/splunk_logger/LICENSE | 201 ------ vendor/modules.txt | 4 +- 46 files changed, 3717 insertions(+), 2069 deletions(-) rename vendor/github.com/osbuild/images/pkg/distro/{rhel9 => rhel}/arch.go (65%) create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/defaults.go create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/distribution.go rename vendor/github.com/osbuild/images/pkg/distro/{rhel9 => rhel}/images.go (86%) create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/imagetype.go create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/ami.go create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/azure.go create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/bare_metal.go create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/distro.go create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/options.go create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/package_sets.go create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/partition_tables.go create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/qcow2.go create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/ubi.go create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/vmdk.go rename vendor/github.com/osbuild/images/pkg/distro/{ => rhel}/rhel9/ami.go (63%) rename vendor/github.com/osbuild/images/pkg/distro/{ => rhel}/rhel9/azure.go (78%) rename vendor/github.com/osbuild/images/pkg/distro/{ => rhel}/rhel9/bare_metal.go (81%) create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/distro.go rename vendor/github.com/osbuild/images/pkg/distro/{ => rhel}/rhel9/edge.go (61%) rename vendor/github.com/osbuild/images/pkg/distro/{ => rhel}/rhel9/gce.go (78%) create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/options.go rename vendor/github.com/osbuild/images/pkg/distro/{ => rhel}/rhel9/package_sets.go (79%) rename vendor/github.com/osbuild/images/pkg/distro/{ => rhel}/rhel9/partition_tables.go (90%) rename vendor/github.com/osbuild/images/pkg/distro/{ => rhel}/rhel9/qcow2.go (54%) rename vendor/github.com/osbuild/images/pkg/distro/{ => rhel}/rhel9/sap.go (97%) rename vendor/github.com/osbuild/images/pkg/distro/{ => rhel}/rhel9/ubi.go (75%) create mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/vmdk.go delete mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel9/distro.go delete mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel9/imagetype.go delete mode 100644 vendor/github.com/osbuild/images/pkg/distro/rhel9/vmdk.go create mode 100644 vendor/github.com/osbuild/images/pkg/manifest/raw_bootc.go delete mode 100644 vendor/github.com/osbuild/osbuild-composer/pkg/splunk_logger/LICENSE diff --git a/cmd/osbuild-dnf-json-tests/main_test.go b/cmd/osbuild-dnf-json-tests/main_test.go index 8be2a758c18..9b82ca0bf2e 100644 --- a/cmd/osbuild-dnf-json-tests/main_test.go +++ b/cmd/osbuild-dnf-json-tests/main_test.go @@ -13,7 +13,7 @@ import ( "github.com/osbuild/images/pkg/arch" "github.com/osbuild/images/pkg/blueprint" "github.com/osbuild/images/pkg/distro" - "github.com/osbuild/images/pkg/distro/rhel9" + "github.com/osbuild/images/pkg/distro/rhel/rhel9" "github.com/osbuild/images/pkg/dnfjson" "github.com/osbuild/images/pkg/ostree" "github.com/osbuild/images/pkg/reporegistry" diff --git a/internal/cloudapi/v2/imagerequest_test.go b/internal/cloudapi/v2/imagerequest_test.go index 773a8aa03d4..590eb354d32 100644 --- a/internal/cloudapi/v2/imagerequest_test.go +++ b/internal/cloudapi/v2/imagerequest_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/osbuild/images/pkg/arch" - "github.com/osbuild/images/pkg/distro/rhel9" + "github.com/osbuild/images/pkg/distro/rhel/rhel9" "github.com/osbuild/images/pkg/distro/test_distro" "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/common" diff --git a/vendor/github.com/osbuild/images/pkg/customizations/oscap/oscap.go b/vendor/github.com/osbuild/images/pkg/customizations/oscap/oscap.go index ffc06db9c6b..1e70665d9af 100644 --- a/vendor/github.com/osbuild/images/pkg/customizations/oscap/oscap.go +++ b/vendor/github.com/osbuild/images/pkg/customizations/oscap/oscap.go @@ -19,6 +19,9 @@ const ( AnssiBp28High Profile = "xccdf_org.ssgproject.content_profile_anssi_bp28_high" AnssiBp28Intermediary Profile = "xccdf_org.ssgproject.content_profile_anssi_bp28_intermediary" AnssiBp28Minimal Profile = "xccdf_org.ssgproject.content_profile_anssi_bp28_minimal" + CcnAdvanced Profile = "xccdf_org.ssgproject.content_profile_ccn_advanced" + CcnBasic Profile = "xccdf_org.ssgproject.content_profile_ccn_basic" + CcnIntermediate Profile = "xccdf_org.ssgproject.content_profile_ccn_intermediate" Cis Profile = "xccdf_org.ssgproject.content_profile_cis" CisServerL1 Profile = "xccdf_org.ssgproject.content_profile_cis_server_l1" CisWorkstationL1 Profile = "xccdf_org.ssgproject.content_profile_cis_workstation_l1" diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel9/arch.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/arch.go similarity index 65% rename from vendor/github.com/osbuild/images/pkg/distro/rhel9/arch.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel/arch.go index 52e1f4de96f..4afd68b6cf0 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/rhel9/arch.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/arch.go @@ -1,26 +1,31 @@ -package rhel9 +package rhel import ( "errors" "fmt" "sort" + "github.com/osbuild/images/pkg/arch" "github.com/osbuild/images/pkg/distro" "github.com/osbuild/images/pkg/platform" ) -type architecture struct { - distro *distribution - name string +type Architecture struct { + distro *Distribution + arch arch.Arch imageTypes map[string]distro.ImageType imageTypeAliases map[string]string } -func (a *architecture) Name() string { - return a.name +func (a *Architecture) Name() string { + return a.arch.String() } -func (a *architecture) ListImageTypes() []string { +func (a *Architecture) Distro() distro.Distro { + return a.distro +} + +func (a *Architecture) ListImageTypes() []string { itNames := make([]string, 0, len(a.imageTypes)) for name := range a.imageTypes { itNames = append(itNames, name) @@ -29,7 +34,7 @@ func (a *architecture) ListImageTypes() []string { return itNames } -func (a *architecture) GetImageType(name string) (distro.ImageType, error) { +func (a *Architecture) GetImageType(name string) (distro.ImageType, error) { t, exists := a.imageTypes[name] if !exists { aliasForName, exists := a.imageTypeAliases[name] @@ -44,7 +49,7 @@ func (a *architecture) GetImageType(name string) (distro.ImageType, error) { return t, nil } -func (a *architecture) addImageTypes(platform platform.Platform, imageTypes ...imageType) { +func (a *Architecture) AddImageTypes(platform platform.Platform, imageTypes ...*ImageType) { if a.imageTypes == nil { a.imageTypes = map[string]distro.ImageType{} } @@ -52,8 +57,8 @@ func (a *architecture) addImageTypes(platform platform.Platform, imageTypes ...i it := imageTypes[idx] it.arch = a it.platform = platform - a.imageTypes[it.name] = &it - for _, alias := range it.nameAliases { + a.imageTypes[it.name] = it + for _, alias := range it.NameAliases { if a.imageTypeAliases == nil { a.imageTypeAliases = map[string]string{} } @@ -65,6 +70,9 @@ func (a *architecture) addImageTypes(platform platform.Platform, imageTypes ...i } } -func (a *architecture) Distro() distro.Distro { - return a.distro +func NewArchitecture(distro *Distribution, arch arch.Arch) *Architecture { + return &Architecture{ + distro: distro, + arch: arch, + } } diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/defaults.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/defaults.go new file mode 100644 index 00000000000..1461a30754e --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/defaults.go @@ -0,0 +1,32 @@ +package rhel + +import ( + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" +) + +const ( + // location for saving openscap remediation data + oscapDataDir = "/oscap_data" + + UEFIVendor = "redhat" +) + +// CentOS- and RHEL-based OS image configuration defaults +var defaultDistroImageConfig = &distro.ImageConfig{ + Timezone: common.ToPtr("America/New_York"), + Locale: common.ToPtr("C.UTF-8"), + Sysconfig: []*osbuild.SysconfigStageOptions{ + { + Kernel: &osbuild.SysconfigKernelOptions{ + UpdateDefault: true, + DefaultKernel: "kernel", + }, + Network: &osbuild.SysconfigNetworkOptions{ + Networking: true, + NoZeroConf: true, + }, + }, + }, +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/distribution.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/distribution.go new file mode 100644 index 00000000000..fa3d0bd292c --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/distribution.go @@ -0,0 +1,135 @@ +package rhel + +import ( + "errors" + "fmt" + "sort" + "strings" + + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/runner" +) + +type Distribution struct { + name string + product string + osVersion string + releaseVersion string + modulePlatformID string + vendor string + ostreeRefTmpl string + runner runner.Runner + arches map[string]distro.Arch + defaultImageConfig *distro.ImageConfig + + // distro specific function to check options per image type + CheckOptions CheckOptionsFunc +} + +func (d *Distribution) Name() string { + return d.name +} + +func (d *Distribution) Releasever() string { + return d.releaseVersion +} + +func (d *Distribution) OsVersion() string { + return d.osVersion +} + +func (d *Distribution) Product() string { + return d.product +} + +func (d *Distribution) ModulePlatformID() string { + return d.modulePlatformID +} + +func (d *Distribution) OSTreeRef() string { + return d.ostreeRefTmpl +} + +func (d *Distribution) Vendor() string { + return d.vendor +} + +func (d *Distribution) ListArches() []string { + archNames := make([]string, 0, len(d.arches)) + for name := range d.arches { + archNames = append(archNames, name) + } + sort.Strings(archNames) + return archNames +} + +func (d *Distribution) GetArch(name string) (distro.Arch, error) { + arch, exists := d.arches[name] + if !exists { + return nil, errors.New("invalid architecture: " + name) + } + return arch, nil +} + +func (d *Distribution) AddArches(arches ...*Architecture) { + if d.arches == nil { + d.arches = map[string]distro.Arch{} + } + + // Do not make copies of architectures, as opposed to image types, + // because architecture definitions are not used by more than a single + // distro definition. + for idx := range arches { + d.arches[arches[idx].Name()] = arches[idx] + } +} + +func (d *Distribution) IsRHEL() bool { + return strings.HasPrefix(d.name, "rhel") +} + +func (d *Distribution) GetDefaultImageConfig() *distro.ImageConfig { + return d.defaultImageConfig +} + +func NewDistribution(name string, major, minor int) (*Distribution, error) { + var rd *Distribution + switch name { + case "rhel": + if minor == -1 { + return nil, errors.New("RHEL requires a minor version") + } + + rd = &Distribution{ + name: fmt.Sprintf("rhel-%d.%d", major, minor), + product: "Red Hat Enterprise Linux", + osVersion: fmt.Sprintf("%d.%d", major, minor), + releaseVersion: fmt.Sprintf("%d", major), + modulePlatformID: fmt.Sprintf("platform:el%d", major), + vendor: "redhat", + ostreeRefTmpl: fmt.Sprintf("rhel/%d/%%s/edge", major), + runner: &runner.RHEL{Major: uint64(major), Minor: uint64(minor)}, + defaultImageConfig: defaultDistroImageConfig, + } + case "centos": + if minor != -1 { + return nil, fmt.Errorf("CentOS does not have minor versions, but got %d", minor) + } + + rd = &Distribution{ + name: fmt.Sprintf("centos-%d", major), + product: "CentOS Stream", + osVersion: fmt.Sprintf("%d-stream", major), + releaseVersion: fmt.Sprintf("%d", major), + modulePlatformID: fmt.Sprintf("platform:el%d", major), + vendor: "centos", + ostreeRefTmpl: fmt.Sprintf("centos/%d/%%s/edge", major), + runner: &runner.CentOS{Version: uint64(major)}, + defaultImageConfig: defaultDistroImageConfig, + } + default: + return nil, fmt.Errorf("unknown distro name: %s", name) + } + + return rd, nil +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel9/images.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/images.go similarity index 86% rename from vendor/github.com/osbuild/images/pkg/distro/rhel9/images.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel/images.go index 50fd9622d21..8e427d6aa09 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/rhel9/images.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/images.go @@ -1,4 +1,4 @@ -package rhel9 +package rhel import ( "fmt" @@ -22,7 +22,7 @@ import ( ) func osCustomizations( - t *imageType, + t *ImageType, osPackageSet rpmmd.PackageSet, options distro.ImageOptions, containers []container.SourceSpec, @@ -33,12 +33,12 @@ func osCustomizations( osc := manifest.OSCustomizations{} - if t.bootable || t.rpmOstree { + if t.Bootable || t.RPMOSTree { osc.KernelName = c.GetKernel().Name var kernelOptions []string - if t.kernelOptions != "" { - kernelOptions = append(kernelOptions, t.kernelOptions) + if t.KernelOptions != "" { + kernelOptions = append(kernelOptions, t.KernelOptions) } if bpKernel := c.GetKernel(); bpKernel.Append != "" { kernelOptions = append(kernelOptions, bpKernel.Append) @@ -59,7 +59,7 @@ func osCustomizations( osc.ExcludeDocs = *imageConfig.ExcludeDocs } - if !t.bootISO { + if !t.BootISO { // don't put users and groups in the payload of an installer // add them via kickstart instead osc.Groups = users.GroupsFromBP(c.GetGroups()) @@ -134,7 +134,7 @@ func osCustomizations( osc.SElinux = "targeted" } - if t.arch.distro.isRHEL() && options.Facts != nil { + if t.IsRHEL() && options.Facts != nil { osc.FactAPIType = &options.Facts.APIType } @@ -157,7 +157,7 @@ func osCustomizations( // deployment, rather than the commit. Therefore the containers need to be // stored in a different location, like `/usr/share`, and the container // storage engine configured accordingly. - if t.rpmOstree && len(containers) > 0 { + if t.RPMOSTree && len(containers) > 0 { storagePath := "/usr/share/containers/storage" osc.ContainersStorage = &storagePath } @@ -196,7 +196,7 @@ func osCustomizations( } if oscapConfig := c.GetOpenSCAP(); oscapConfig != nil { - if t.rpmOstree { + if t.RPMOSTree { panic("unexpected oscap options for ostree image type") } @@ -211,7 +211,8 @@ func osCustomizations( var datastream = oscapConfig.DataStream if datastream == "" { - datastream = oscap.DefaultRHEL9Datastream(t.arch.distro.isRHEL()) + // TODO: make this RHEL-9 specific + datastream = oscap.DefaultRHEL9Datastream(t.IsRHEL()) } oscapStageOptions := osbuild.OscapConfig{ @@ -283,8 +284,8 @@ func osCustomizations( return osc } -func diskImage(workload workload.Workload, - t *imageType, +func DiskImage(workload workload.Workload, + t *ImageType, customizations *blueprint.Customizations, options distro.ImageOptions, packageSets map[string]rpmmd.PackageSet, @@ -293,12 +294,12 @@ func diskImage(workload workload.Workload, img := image.NewDiskImage() img.Platform = t.platform - img.OSCustomizations = osCustomizations(t, packageSets[osPkgsKey], options, containers, customizations) - img.Environment = t.environment + img.OSCustomizations = osCustomizations(t, packageSets[OSPkgsKey], options, containers, customizations) + img.Environment = t.Environment img.Workload = workload - img.Compression = t.compression + img.Compression = t.Compression // TODO: move generation into LiveImage - pt, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng) + pt, err := t.GetPartitionTable(customizations.GetFilesystems(), options, rng) if err != nil { return nil, err } @@ -309,8 +310,8 @@ func diskImage(workload workload.Workload, return img, nil } -func edgeCommitImage(workload workload.Workload, - t *imageType, +func EdgeCommitImage(workload workload.Workload, + t *ImageType, customizations *blueprint.Customizations, options distro.ImageOptions, packageSets map[string]rpmmd.PackageSet, @@ -321,28 +322,27 @@ func edgeCommitImage(workload workload.Workload, img := image.NewOSTreeArchive(commitRef) img.Platform = t.platform - img.OSCustomizations = osCustomizations(t, packageSets[osPkgsKey], options, containers, customizations) - img.Environment = t.environment + img.OSCustomizations = osCustomizations(t, packageSets[OSPkgsKey], options, containers, customizations) + img.Environment = t.Environment img.Workload = workload img.OSTreeParent = parentCommit - img.OSVersion = t.arch.distro.osVersion + img.OSVersion = t.Arch().Distro().OsVersion() img.Filename = t.Filename() - if common.VersionGreaterThanOrEqual(t.arch.distro.osVersion, "9.2") || !t.arch.distro.isRHEL() { + if common.VersionGreaterThanOrEqual(t.Arch().Distro().OsVersion(), "9.2") || !t.IsRHEL() { img.OSCustomizations.EnabledServices = append(img.OSCustomizations.EnabledServices, "ignition-firstboot-complete.service", "coreos-ignition-write-issues.service") } - img.Environment = t.environment img.Workload = workload - img.OSVersion = t.arch.distro.osVersion + img.OSVersion = t.Arch().Distro().OsVersion() img.Filename = t.Filename() return img, nil } -func edgeContainerImage(workload workload.Workload, - t *imageType, +func EdgeContainerImage(workload workload.Workload, + t *ImageType, customizations *blueprint.Customizations, options distro.ImageOptions, packageSets map[string]rpmmd.PackageSet, @@ -353,32 +353,30 @@ func edgeContainerImage(workload workload.Workload, img := image.NewOSTreeContainer(commitRef) img.Platform = t.platform - img.OSCustomizations = osCustomizations(t, packageSets[osPkgsKey], options, containers, customizations) + img.OSCustomizations = osCustomizations(t, packageSets[OSPkgsKey], options, containers, customizations) img.ContainerLanguage = img.OSCustomizations.Language - img.Environment = t.environment + img.Environment = t.Environment img.Workload = workload img.OSTreeParent = parentCommit - img.OSVersion = t.arch.distro.osVersion - img.ExtraContainerPackages = packageSets[containerPkgsKey] + img.OSVersion = t.Arch().Distro().OsVersion() + img.ExtraContainerPackages = packageSets[ContainerPkgsKey] img.Filename = t.Filename() - if common.VersionGreaterThanOrEqual(t.arch.distro.osVersion, "9.2") || !t.arch.distro.isRHEL() { + if common.VersionGreaterThanOrEqual(t.Arch().Distro().OsVersion(), "9.2") || !t.IsRHEL() { img.OSCustomizations.EnabledServices = append(img.OSCustomizations.EnabledServices, "ignition-firstboot-complete.service", "coreos-ignition-write-issues.service") } return img, nil } -func edgeInstallerImage(workload workload.Workload, - t *imageType, +func EdgeInstallerImage(workload workload.Workload, + t *ImageType, customizations *blueprint.Customizations, options distro.ImageOptions, packageSets map[string]rpmmd.PackageSet, containers []container.SourceSpec, rng *rand.Rand) (image.ImageKind, error) { - d := t.arch.distro - commit, err := makeOSTreePayloadCommit(options.OSTree, t.OSTreeRef()) if err != nil { return nil, fmt.Errorf("%s: %s", t.Name(), err.Error()) @@ -387,7 +385,7 @@ func edgeInstallerImage(workload workload.Workload, img := image.NewAnacondaOSTreeInstaller(commit) img.Platform = t.platform - img.ExtraBasePackages = packageSets[installerPkgsKey] + img.ExtraBasePackages = packageSets[InstallerPkgsKey] img.Users = users.UsersFromBP(customizations.GetUsers()) img.Groups = users.GroupsFromBP(customizations.GetGroups()) @@ -419,11 +417,11 @@ func edgeInstallerImage(workload workload.Workload, return nil, err } - img.Product = d.product + img.Product = t.Arch().Distro().Product() img.Variant = "edge" img.OSName = "rhel" - img.OSVersion = d.osVersion - img.Release = fmt.Sprintf("%s %s", d.product, d.osVersion) + img.OSVersion = t.Arch().Distro().OsVersion() + img.Release = fmt.Sprintf("%s %s", t.Arch().Distro().Product(), t.Arch().Distro().OsVersion()) img.FIPS = customizations.GetFIPS() img.Filename = t.Filename() @@ -431,8 +429,8 @@ func edgeInstallerImage(workload workload.Workload, return img, nil } -func edgeRawImage(workload workload.Workload, - t *imageType, +func EdgeRawImage(workload workload.Workload, + t *ImageType, customizations *blueprint.Customizations, options distro.ImageOptions, packageSets map[string]rpmmd.PackageSet, @@ -452,17 +450,17 @@ func edgeRawImage(workload workload.Workload, // The kernel options defined on the image type are usually handled in // osCustomiztions() but ostree images don't use OSCustomizations, so we // handle them here separately. - if t.kernelOptions != "" { - img.KernelOptionsAppend = append(img.KernelOptionsAppend, t.kernelOptions) + if t.KernelOptions != "" { + img.KernelOptionsAppend = append(img.KernelOptionsAppend, t.KernelOptions) } img.Keyboard = "us" img.Locale = "C.UTF-8" - if common.VersionGreaterThanOrEqual(t.arch.distro.osVersion, "9.2") || !t.arch.distro.isRHEL() { + if common.VersionGreaterThanOrEqual(t.Arch().Distro().OsVersion(), "9.2") || !t.IsRHEL() { img.SysrootReadOnly = true img.KernelOptionsAppend = append(img.KernelOptionsAppend, "rw") } - if common.VersionGreaterThanOrEqual(t.arch.distro.osVersion, "9.2") || !t.arch.distro.isRHEL() { + if common.VersionGreaterThanOrEqual(t.Arch().Distro().OsVersion(), "9.2") || !t.IsRHEL() { img.IgnitionPlatform = "metal" img.KernelOptionsAppend = append(img.KernelOptionsAppend, "coreos.no_persist_ip") if bpIgnition := customizations.GetIgnition(); bpIgnition != nil && bpIgnition.FirstBoot != nil && bpIgnition.FirstBoot.ProvisioningURL != "" { @@ -485,14 +483,14 @@ func edgeRawImage(workload workload.Workload, } // TODO: move generation into LiveImage - pt, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng) + pt, err := t.GetPartitionTable(customizations.GetFilesystems(), options, rng) if err != nil { return nil, err } img.PartitionTable = pt img.Filename = t.Filename() - img.Compression = t.compression + img.Compression = t.Compression for _, fs := range customizations.GetFilesystems() { img.CustomFilesystems = append(img.CustomFilesystems, fs.Mountpoint) @@ -501,8 +499,8 @@ func edgeRawImage(workload workload.Workload, return img, nil } -func edgeSimplifiedInstallerImage(workload workload.Workload, - t *imageType, +func EdgeSimplifiedInstallerImage(workload workload.Workload, + t *ImageType, customizations *blueprint.Customizations, options distro.ImageOptions, packageSets map[string]rpmmd.PackageSet, @@ -522,7 +520,7 @@ func edgeSimplifiedInstallerImage(workload workload.Workload, rawImg.KernelOptionsAppend = []string{"modprobe.blacklist=vc4"} rawImg.Keyboard = "us" rawImg.Locale = "C.UTF-8" - if common.VersionGreaterThanOrEqual(t.arch.distro.osVersion, "9.2") || !t.arch.distro.isRHEL() { + if common.VersionGreaterThanOrEqual(t.Arch().Distro().OsVersion(), "9.2") || !t.IsRHEL() { rawImg.SysrootReadOnly = true rawImg.KernelOptionsAppend = append(rawImg.KernelOptionsAppend, "rw") } @@ -537,7 +535,7 @@ func edgeSimplifiedInstallerImage(workload workload.Workload, rawImg.OSName = "redhat" rawImg.LockRoot = true - if common.VersionGreaterThanOrEqual(t.arch.distro.osVersion, "9.2") || !t.arch.distro.isRHEL() { + if common.VersionGreaterThanOrEqual(t.Arch().Distro().OsVersion(), "9.2") || !t.IsRHEL() { rawImg.IgnitionPlatform = "metal" rawImg.KernelOptionsAppend = append(rawImg.KernelOptionsAppend, "coreos.no_persist_ip") if bpIgnition := customizations.GetIgnition(); bpIgnition != nil && bpIgnition.FirstBoot != nil && bpIgnition.FirstBoot.ProvisioningURL != "" { @@ -546,7 +544,7 @@ func edgeSimplifiedInstallerImage(workload workload.Workload, } // TODO: move generation into LiveImage - pt, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng) + pt, err := t.GetPartitionTable(customizations.GetFilesystems(), options, rng) if err != nil { return nil, err } @@ -564,7 +562,7 @@ func edgeSimplifiedInstallerImage(workload workload.Workload, } img := image.NewOSTreeSimplifiedInstaller(rawImg, customizations.InstallationDevice) - img.ExtraBasePackages = packageSets[installerPkgsKey] + img.ExtraBasePackages = packageSets[InstallerPkgsKey] // img.Workload = workload img.Platform = t.platform img.Filename = t.Filename() @@ -597,8 +595,8 @@ func edgeSimplifiedInstallerImage(workload workload.Workload, return img, nil } -func imageInstallerImage(workload workload.Workload, - t *imageType, +func ImageInstallerImage(workload workload.Workload, + t *ImageType, customizations *blueprint.Customizations, options distro.ImageOptions, packageSets map[string]rpmmd.PackageSet, @@ -609,8 +607,8 @@ func imageInstallerImage(workload workload.Workload, img.Platform = t.platform img.Workload = workload - img.OSCustomizations = osCustomizations(t, packageSets[osPkgsKey], options, containers, customizations) - img.ExtraBasePackages = packageSets[installerPkgsKey] + img.OSCustomizations = osCustomizations(t, packageSets[OSPkgsKey], options, containers, customizations) + img.ExtraBasePackages = packageSets[InstallerPkgsKey] img.Users = users.UsersFromBP(customizations.GetUsers()) img.Groups = users.GroupsFromBP(customizations.GetGroups()) @@ -649,8 +647,8 @@ func imageInstallerImage(workload workload.Workload, return img, nil } -func tarImage(workload workload.Workload, - t *imageType, +func TarImage(workload workload.Workload, + t *ImageType, customizations *blueprint.Customizations, options distro.ImageOptions, packageSets map[string]rpmmd.PackageSet, @@ -659,8 +657,8 @@ func tarImage(workload workload.Workload, img := image.NewArchive() img.Platform = t.platform - img.OSCustomizations = osCustomizations(t, packageSets[osPkgsKey], options, containers, customizations) - img.Environment = t.environment + img.OSCustomizations = osCustomizations(t, packageSets[OSPkgsKey], options, containers, customizations) + img.Environment = t.Environment img.Workload = workload img.Filename = t.Filename() @@ -724,13 +722,3 @@ func makeOSTreePayloadCommit(options *ostree.ImageOptions, defaultRef string) (o RHSM: options.RHSM, }, nil } - -// initialSetupKickstart returns the File configuration for a kickstart file -// that's required to enable initial-setup to run on first boot. -func initialSetupKickstart() *fsnode.File { - file, err := fsnode.NewFile("/root/anaconda-ks.cfg", nil, "root", "root", []byte("# Run initial-setup on first boot\n# Created by osbuild\nfirstboot --reconfig\nlang en_US.UTF-8\n")) - if err != nil { - panic(err) - } - return file -} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/imagetype.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/imagetype.go new file mode 100644 index 00000000000..51ac7baa02d --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/imagetype.go @@ -0,0 +1,346 @@ +package rhel + +import ( + "fmt" + "math/rand" + + "golang.org/x/exp/slices" + + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/image" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" +) + +const ( + // package set names + + // build package set name + BuildPkgsKey = "build" + + // main/common os image package set name + OSPkgsKey = "os" + + // container package set name + ContainerPkgsKey = "container" + + // installer package set name + InstallerPkgsKey = "installer" + + // blueprint package set name + BlueprintPkgsKey = "blueprint" +) + +type ImageFunc func(workload workload.Workload, t *ImageType, customizations *blueprint.Customizations, options distro.ImageOptions, packageSets map[string]rpmmd.PackageSet, containers []container.SourceSpec, rng *rand.Rand) (image.ImageKind, error) + +type PackageSetFunc func(t *ImageType) rpmmd.PackageSet + +type BasePartitionTableFunc func(t *ImageType) (disk.PartitionTable, bool) + +type ISOLabelFunc func(t *ImageType) string + +type CheckOptionsFunc func(t *ImageType, bp *blueprint.Blueprint, options distro.ImageOptions) ([]string, error) + +type ImageType struct { + // properties, which are part of the distro.ImageType interface or are used by all images + name string + filename string + mimeType string + packageSets map[string]PackageSetFunc + buildPipelines []string + payloadPipelines []string + exports []string + image ImageFunc + + // properties which can't be set when defining the image type + arch *Architecture + platform platform.Platform + workload workload.Workload + + Environment environment.Environment + NameAliases []string + Compression string // TODO: remove from image definition and make it a transport option + DefaultImageConfig *distro.ImageConfig + KernelOptions string + DefaultSize uint64 + + // bootISO: installable ISO + BootISO bool + // rpmOstree: edge/ostree + RPMOSTree bool + // bootable image + Bootable bool + // List of valid arches for the image type + BasePartitionTables BasePartitionTableFunc + ISOLabelFn ISOLabelFunc +} + +func (t *ImageType) Name() string { + return t.name +} + +func (t *ImageType) Arch() distro.Arch { + return t.arch +} + +func (t *ImageType) Filename() string { + return t.filename +} + +func (t *ImageType) MIMEType() string { + return t.mimeType +} + +func (t *ImageType) OSTreeRef() string { + d := t.arch.distro + if t.RPMOSTree { + return fmt.Sprintf(d.ostreeRefTmpl, t.Arch().Name()) + } + return "" +} + +// IsRHEL returns true if the image type is part of a RHEL distribution +// +// This is a convenience method, because external packages can't get the +// information from t.Arch().Distro(), since the distro.Distro interface +// does not have this method. And since the distro.Distro interface is +// distro-agnostic, it does not make much sense to have a method like this +// in the interface. +func (t *ImageType) IsRHEL() bool { + return t.arch.distro.IsRHEL() +} + +func (t *ImageType) ISOLabel() (string, error) { + if !t.BootISO { + return "", fmt.Errorf("image type %q is not an ISO", t.name) + } + + if t.ISOLabelFn != nil { + return t.ISOLabelFn(t), nil + } + + return "", nil +} + +func (t *ImageType) Size(size uint64) uint64 { + // Microsoft Azure requires vhd images to be rounded up to the nearest MB + if t.name == "vhd" && size%common.MebiByte != 0 { + size = (size/common.MebiByte + 1) * common.MebiByte + } + if size == 0 { + size = t.DefaultSize + } + return size +} + +func (t *ImageType) BuildPipelines() []string { + return t.buildPipelines +} + +func (t *ImageType) PayloadPipelines() []string { + return t.payloadPipelines +} + +func (t *ImageType) PayloadPackageSets() []string { + return []string{BlueprintPkgsKey} +} + +func (t *ImageType) PackageSetsChains() map[string][]string { + return nil +} + +func (t *ImageType) Exports() []string { + if len(t.exports) > 0 { + return t.exports + } + return []string{"assembler"} +} + +func (t *ImageType) BootMode() distro.BootMode { + if t.platform.GetUEFIVendor() != "" && t.platform.GetBIOSPlatform() != "" { + return distro.BOOT_HYBRID + } else if t.platform.GetUEFIVendor() != "" { + return distro.BOOT_UEFI + } else if t.platform.GetBIOSPlatform() != "" || t.platform.GetZiplSupport() { + return distro.BOOT_LEGACY + } + return distro.BOOT_NONE +} + +func (t *ImageType) GetPartitionTable( + mountpoints []blueprint.FilesystemCustomization, + options distro.ImageOptions, + rng *rand.Rand, +) (*disk.PartitionTable, error) { + archName := t.arch.Name() + + basePartitionTable, exists := t.BasePartitionTables(t) + + if !exists { + return nil, fmt.Errorf("no partition table defined for architecture %q for image type %q", archName, t.Name()) + } + + imageSize := t.Size(options.Size) + + partitioningMode := options.PartitioningMode + if t.RPMOSTree { + // Edge supports only LVM, force it. + // TODO Need a central location for logic like this + + partitioningMode = disk.LVMPartitioningMode + } + + return disk.NewPartitionTable(&basePartitionTable, mountpoints, imageSize, partitioningMode, nil, rng) +} + +func (t *ImageType) getDefaultImageConfig() *distro.ImageConfig { + // ensure that image always returns non-nil default config + imageConfig := t.DefaultImageConfig + if imageConfig == nil { + imageConfig = &distro.ImageConfig{} + } + return imageConfig.InheritFrom(t.arch.distro.GetDefaultImageConfig()) + +} + +func (t *ImageType) PartitionType() string { + basePartitionTable, exists := t.BasePartitionTables(t) + if !exists { + return "" + } + + return basePartitionTable.Type +} + +func (t *ImageType) Manifest(bp *blueprint.Blueprint, + options distro.ImageOptions, + repos []rpmmd.RepoConfig, + seed int64) (*manifest.Manifest, []string, error) { + + if t.workload != nil { + // For now, if an image type defines its own workload, don't allow any + // user customizations. + // Soon we will have more workflows and each will define its allowed + // set of customizations. The current set of customizations defined in + // the blueprint spec corresponds to the Custom workflow. + if bp.Customizations != nil { + return nil, nil, fmt.Errorf(distro.NoCustomizationsAllowedError, t.Name()) + } + } + + warnings, err := t.checkOptions(bp, options) + if err != nil { + return nil, nil, err + } + + // merge package sets that appear in the image type with the package sets + // of the same name from the distro and arch + staticPackageSets := make(map[string]rpmmd.PackageSet) + + for name, getter := range t.packageSets { + staticPackageSets[name] = getter(t) + } + + // amend with repository information and collect payload repos + payloadRepos := make([]rpmmd.RepoConfig, 0) + for _, repo := range repos { + if len(repo.PackageSets) > 0 { + // only apply the repo to the listed package sets + for _, psName := range repo.PackageSets { + if slices.Contains(t.PayloadPackageSets(), psName) { + payloadRepos = append(payloadRepos, repo) + } + ps := staticPackageSets[psName] + ps.Repositories = append(ps.Repositories, repo) + staticPackageSets[psName] = ps + } + } + } + + w := t.workload + if w == nil { + cw := &workload.Custom{ + BaseWorkload: workload.BaseWorkload{ + Repos: payloadRepos, + }, + Packages: bp.GetPackagesEx(false), + } + if services := bp.Customizations.GetServices(); services != nil { + cw.Services = services.Enabled + cw.DisabledServices = services.Disabled + } + w = cw + } + + containerSources := make([]container.SourceSpec, len(bp.Containers)) + for idx, cont := range bp.Containers { + containerSources[idx] = container.SourceSpec{ + Source: cont.Source, + Name: cont.Name, + TLSVerify: cont.TLSVerify, + Local: cont.LocalStorage, + } + } + + source := rand.NewSource(seed) + // math/rand is good enough in this case + /* #nosec G404 */ + rng := rand.New(source) + + img, err := t.image(w, t, bp.Customizations, options, staticPackageSets, containerSources, rng) + if err != nil { + return nil, nil, err + } + mf := manifest.New() + + switch t.Arch().Distro().Releasever() { + case "9": + mf.Distro = manifest.DISTRO_EL9 + case "10": + mf.Distro = manifest.DISTRO_EL10 + default: + return nil, nil, fmt.Errorf("unsupported distro release version: %s", t.Arch().Distro().Releasever()) + } + + _, err = img.InstantiateManifest(&mf, repos, t.arch.distro.runner, rng) + if err != nil { + return nil, nil, err + } + + return &mf, warnings, err +} + +// checkOptions checks the validity and compatibility of options and customizations for the image type. +// Returns ([]string, error) where []string, if non-nil, will hold any generated warnings (e.g. deprecation notices). +func (t *ImageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOptions) ([]string, error) { + if t.arch.distro.CheckOptions != nil { + return t.arch.distro.CheckOptions(t, bp, options) + } + + return nil, nil +} + +func NewImageType( + name, filename, mimeType string, + pkgSets map[string]PackageSetFunc, + imgFunc ImageFunc, + buildPipelines, payloadPipelines, exports []string, +) *ImageType { + return &ImageType{ + name: name, + filename: filename, + mimeType: mimeType, + packageSets: pkgSets, + image: imgFunc, + buildPipelines: buildPipelines, + payloadPipelines: payloadPipelines, + exports: exports, + } +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/ami.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/ami.go new file mode 100644 index 00000000000..e61d9853485 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/ami.go @@ -0,0 +1,286 @@ +package rhel10 + +import ( + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" +) + +// TODO: move these to the EC2 environment +const amiKernelOptions = "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295" + +// default EC2 images config (common for all architectures) +func baseEc2ImageConfig() *distro.ImageConfig { + return &distro.ImageConfig{ + Locale: common.ToPtr("en_US.UTF-8"), + Timezone: common.ToPtr("UTC"), + TimeSynchronization: &osbuild.ChronyStageOptions{ + Servers: []osbuild.ChronyConfigServer{ + { + Hostname: "169.254.169.123", + Prefer: common.ToPtr(true), + Iburst: common.ToPtr(true), + Minpoll: common.ToPtr(4), + Maxpoll: common.ToPtr(4), + }, + }, + // empty string will remove any occurrences of the option from the configuration + LeapsecTz: common.ToPtr(""), + }, + Keyboard: &osbuild.KeymapStageOptions{ + Keymap: "us", + X11Keymap: &osbuild.X11KeymapOptions{ + Layouts: []string{"us"}, + }, + }, + EnabledServices: []string{ + "sshd", + "NetworkManager", + "nm-cloud-setup.service", + "nm-cloud-setup.timer", + "cloud-init", + "cloud-init-local", + "cloud-config", + "cloud-final", + "reboot.target", + "tuned", + }, + DefaultTarget: common.ToPtr("multi-user.target"), + Sysconfig: []*osbuild.SysconfigStageOptions{ + { + Kernel: &osbuild.SysconfigKernelOptions{ + UpdateDefault: true, + DefaultKernel: "kernel", + }, + Network: &osbuild.SysconfigNetworkOptions{ + Networking: true, + NoZeroConf: true, + }, + NetworkScripts: &osbuild.NetworkScriptsOptions{ + IfcfgFiles: map[string]osbuild.IfcfgFile{ + "eth0": { + Device: "eth0", + Bootproto: osbuild.IfcfgBootprotoDHCP, + OnBoot: common.ToPtr(true), + Type: osbuild.IfcfgTypeEthernet, + UserCtl: common.ToPtr(true), + PeerDNS: common.ToPtr(true), + IPv6Init: common.ToPtr(false), + }, + }, + }, + }, + }, + SystemdLogind: []*osbuild.SystemdLogindStageOptions{ + { + Filename: "00-getty-fixes.conf", + Config: osbuild.SystemdLogindConfigDropin{ + Login: osbuild.SystemdLogindConfigLoginSection{ + NAutoVTs: common.ToPtr(0), + }, + }, + }, + }, + CloudInit: []*osbuild.CloudInitStageOptions{ + { + Filename: "00-rhel-default-user.cfg", + Config: osbuild.CloudInitConfigFile{ + SystemInfo: &osbuild.CloudInitConfigSystemInfo{ + DefaultUser: &osbuild.CloudInitConfigDefaultUser{ + Name: "ec2-user", + }, + }, + }, + }, + }, + Modprobe: []*osbuild.ModprobeStageOptions{ + { + Filename: "blacklist-nouveau.conf", + Commands: osbuild.ModprobeConfigCmdList{ + osbuild.NewModprobeConfigCmdBlacklist("nouveau"), + }, + }, + { + Filename: "blacklist-amdgpu.conf", + Commands: osbuild.ModprobeConfigCmdList{ + osbuild.NewModprobeConfigCmdBlacklist("amdgpu"), + }, + }, + }, + // COMPOSER-1807 + DracutConf: []*osbuild.DracutConfStageOptions{ + { + Filename: "sgdisk.conf", + Config: osbuild.DracutConfigFile{ + Install: []string{"sgdisk"}, + }, + }, + }, + SystemdUnit: []*osbuild.SystemdUnitStageOptions{ + // RHBZ#1822863 + { + Unit: "nm-cloud-setup.service", + Dropin: "10-rh-enable-for-ec2.conf", + Config: osbuild.SystemdServiceUnitDropin{ + Service: &osbuild.SystemdUnitServiceSection{ + Environment: "NM_CLOUD_SETUP_EC2=yes", + }, + }, + }, + }, + Authselect: &osbuild.AuthselectStageOptions{ + Profile: "sssd", + }, + SshdConfig: &osbuild.SshdConfigStageOptions{ + Config: osbuild.SshdConfigConfig{ + PasswordAuthentication: common.ToPtr(false), + }, + }, + } +} + +// Default AMI (custom image built by users) images config. +// The configuration does not touch the RHSM configuration at all. +// https://issues.redhat.com/browse/COMPOSER-2157 +func defaultAMIImageConfig() *distro.ImageConfig { + return baseEc2ImageConfig() +} + +// Default AMI x86_64 (custom image built by users) images config. +// The configuration does not touch the RHSM configuration at all. +// https://issues.redhat.com/browse/COMPOSER-2157 +func defaultAMIImageConfigX86_64() *distro.ImageConfig { + ic := defaultAMIImageConfig() + return appendEC2DracutX86_64(ic) +} + +// common ec2 image build package set +func ec2BuildPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + return distroBuildPackageSet(t).Append( + rpmmd.PackageSet{ + Include: []string{ + "python3-pyyaml", + }, + }) +} + +func ec2CommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + ps := rpmmd.PackageSet{ + Include: []string{ + "@core", + "chrony", + "cloud-init", + "cloud-utils-growpart", + "dhcp-client", + "yum-utils", + "dracut-config-generic", + "gdisk", + "grub2", + "langpacks-en", + "NetworkManager-cloud-setup", + "redhat-release", + "redhat-release-eula", + "rsync", + "tuned", + "tar", + }, + Exclude: []string{ + "aic94xx-firmware", + "alsa-firmware", + "alsa-tools-firmware", + "biosdevname", + "firewalld", + "iprutils", + "ivtv-firmware", + "iwl1000-firmware", + "iwl100-firmware", + "iwl105-firmware", + "iwl135-firmware", + "iwl2000-firmware", + "iwl2030-firmware", + "iwl3160-firmware", + "iwl3945-firmware", + "iwl4965-firmware", + "iwl5000-firmware", + "iwl5150-firmware", + "iwl6000-firmware", + "iwl6000g2a-firmware", + "iwl6000g2b-firmware", + "iwl6050-firmware", + "iwl7260-firmware", + "libertas-sd8686-firmware", + "libertas-sd8787-firmware", + "libertas-usb8388-firmware", + "plymouth", + // RHBZ#2064087 + "dracut-config-rescue", + // RHBZ#2075815 + "qemu-guest-agent", + }, + }.Append(distroSpecificPackageSet(t)) + + return ps +} + +func mkAMIImgTypeX86_64() *rhel.ImageType { + it := rhel.NewImageType( + "ami", + "image.raw", + "application/octet-stream", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: ec2CommonPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image"}, + []string{"image"}, + ) + + it.KernelOptions = amiKernelOptions + it.Bootable = true + it.DefaultSize = 10 * common.GibiByte + it.DefaultImageConfig = defaultAMIImageConfigX86_64() + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +func mkAMIImgTypeAarch64() *rhel.ImageType { + it := rhel.NewImageType( + "ami", + "image.raw", + "application/octet-stream", + map[string]rhel.PackageSetFunc{ + rhel.BuildPkgsKey: ec2BuildPackageSet, + rhel.OSPkgsKey: ec2CommonPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image"}, + []string{"image"}, + ) + + it.KernelOptions = "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0" + it.Bootable = true + it.DefaultSize = 10 * common.GibiByte + it.DefaultImageConfig = defaultAMIImageConfig() + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +func appendEC2DracutX86_64(ic *distro.ImageConfig) *distro.ImageConfig { + ic.DracutConf = append(ic.DracutConf, + &osbuild.DracutConfStageOptions{ + Filename: "ec2.conf", + Config: osbuild.DracutConfigFile{ + AddDrivers: []string{ + "nvme", + "xen-blkfront", + }, + }, + }) + return ic +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/azure.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/azure.go new file mode 100644 index 00000000000..28f3b362ef9 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/azure.go @@ -0,0 +1,303 @@ +package rhel10 + +import ( + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" +) + +// Azure non-RHEL image type +func mkAzureImgType() *rhel.ImageType { + it := rhel.NewImageType( + "vhd", + "disk.vhd", + "application/x-vhd", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: azurePackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "vpc"}, + []string{"vpc"}, + ) + + it.KernelOptions = defaultAzureKernelOptions + it.Bootable = true + it.DefaultSize = 4 * common.GibiByte + it.DefaultImageConfig = defaultAzureImageConfig + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +// Azure BYOS image type +func mkAzureByosImgType(rd distro.Distro) *rhel.ImageType { + it := rhel.NewImageType( + "vhd", + "disk.vhd", + "application/x-vhd", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: azurePackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "vpc"}, + []string{"vpc"}, + ) + + it.KernelOptions = defaultAzureKernelOptions + it.Bootable = true + it.DefaultSize = 4 * common.GibiByte + it.DefaultImageConfig = defaultAzureImageConfig + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +// PACKAGE SETS + +// Common Azure image package set +func azureCommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + ps := rpmmd.PackageSet{ + Include: []string{ + "@Server", + "bzip2", + "cloud-init", + "cloud-utils-growpart", + "dracut-config-generic", + "efibootmgr", + "gdisk", + "hyperv-daemons", + "kernel-core", + "kernel-modules", + "kernel", + "langpacks-en", + "lvm2", + "NetworkManager", + "NetworkManager-cloud-setup", + "nvme-cli", + "patch", + "rng-tools", + "selinux-policy-targeted", + "uuid", + "WALinuxAgent", + "yum-utils", + }, + Exclude: []string{ + "aic94xx-firmware", + "alsa-firmware", + "alsa-lib", + "alsa-sof-firmware", + "alsa-tools-firmware", + "biosdevname", + "bolt", + "buildah", + "cockpit-podman", + "containernetworking-plugins", + "dnf-plugin-spacewalk", + "dracut-config-rescue", + "glibc-all-langpacks", + "iprutils", + "ivtv-firmware", + "iwl100-firmware", + "iwl1000-firmware", + "iwl105-firmware", + "iwl135-firmware", + "iwl2000-firmware", + "iwl2030-firmware", + "iwl3160-firmware", + "iwl3945-firmware", + "iwl4965-firmware", + "iwl5000-firmware", + "iwl5150-firmware", + "iwl6000-firmware", + "iwl6000g2a-firmware", + "iwl6000g2b-firmware", + "iwl6050-firmware", + "iwl7260-firmware", + "libertas-sd8686-firmware", + "libertas-sd8787-firmware", + "libertas-usb8388-firmware", + "NetworkManager-config-server", + "plymouth", + "podman", + "python3-dnf-plugin-spacewalk", + "python3-hwdata", + "python3-rhnlib", + "rhn-check", + "rhn-client-tools", + "rhn-setup", + "rhnlib", + "rhnsd", + "usb_modeswitch", + }, + }.Append(distroSpecificPackageSet(t)) + + return ps +} + +// Azure BYOS image package set +func azurePackageSet(t *rhel.ImageType) rpmmd.PackageSet { + return azureCommonPackageSet(t) +} + +// IMAGE CONFIG + +// use loglevel=3 as described in the RHEL documentation and used in existing RHEL images built by MSFT +const defaultAzureKernelOptions = "ro loglevel=3 console=tty1 console=ttyS0 earlyprintk=ttyS0 rootdelay=300" + +// based on https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/deploying_rhel_9_on_microsoft_azure/assembly_deploying-a-rhel-image-as-a-virtual-machine-on-microsoft-azure_cloud-content-azure#making-configuration-changes_configure-the-image-azure +var defaultAzureImageConfig = &distro.ImageConfig{ + Timezone: common.ToPtr("Etc/UTC"), + Locale: common.ToPtr("en_US.UTF-8"), + Keyboard: &osbuild.KeymapStageOptions{ + Keymap: "us", + X11Keymap: &osbuild.X11KeymapOptions{ + Layouts: []string{"us"}, + }, + }, + Sysconfig: []*osbuild.SysconfigStageOptions{ + { + Kernel: &osbuild.SysconfigKernelOptions{ + UpdateDefault: true, + DefaultKernel: "kernel-core", + }, + Network: &osbuild.SysconfigNetworkOptions{ + Networking: true, + NoZeroConf: true, + }, + }, + }, + EnabledServices: []string{ + "firewalld", + "nm-cloud-setup.service", + "nm-cloud-setup.timer", + "sshd", + "waagent", + }, + SshdConfig: &osbuild.SshdConfigStageOptions{ + Config: osbuild.SshdConfigConfig{ + ClientAliveInterval: common.ToPtr(180), + }, + }, + Modprobe: []*osbuild.ModprobeStageOptions{ + { + Filename: "blacklist-amdgpu.conf", + Commands: osbuild.ModprobeConfigCmdList{ + osbuild.NewModprobeConfigCmdBlacklist("amdgpu"), + }, + }, + { + Filename: "blacklist-intel-cstate.conf", + Commands: osbuild.ModprobeConfigCmdList{ + osbuild.NewModprobeConfigCmdBlacklist("intel_cstate"), + }, + }, + { + Filename: "blacklist-floppy.conf", + Commands: osbuild.ModprobeConfigCmdList{ + osbuild.NewModprobeConfigCmdBlacklist("floppy"), + }, + }, + { + Filename: "blacklist-nouveau.conf", + Commands: osbuild.ModprobeConfigCmdList{ + osbuild.NewModprobeConfigCmdBlacklist("nouveau"), + osbuild.NewModprobeConfigCmdBlacklist("lbm-nouveau"), + }, + }, + { + Filename: "blacklist-skylake-edac.conf", + Commands: osbuild.ModprobeConfigCmdList{ + osbuild.NewModprobeConfigCmdBlacklist("skx_edac"), + }, + }, + }, + CloudInit: []*osbuild.CloudInitStageOptions{ + { + Filename: "10-azure-kvp.cfg", + Config: osbuild.CloudInitConfigFile{ + Reporting: &osbuild.CloudInitConfigReporting{ + Logging: &osbuild.CloudInitConfigReportingHandlers{ + Type: "log", + }, + Telemetry: &osbuild.CloudInitConfigReportingHandlers{ + Type: "hyperv", + }, + }, + }, + }, + { + Filename: "91-azure_datasource.cfg", + Config: osbuild.CloudInitConfigFile{ + Datasource: &osbuild.CloudInitConfigDatasource{ + Azure: &osbuild.CloudInitConfigDatasourceAzure{ + ApplyNetworkConfig: false, + }, + }, + DatasourceList: []string{ + "Azure", + }, + }, + }, + }, + PwQuality: &osbuild.PwqualityConfStageOptions{ + Config: osbuild.PwqualityConfConfig{ + Minlen: common.ToPtr(6), + Minclass: common.ToPtr(3), + Dcredit: common.ToPtr(0), + Ucredit: common.ToPtr(0), + Lcredit: common.ToPtr(0), + Ocredit: common.ToPtr(0), + }, + }, + WAAgentConfig: &osbuild.WAAgentConfStageOptions{ + Config: osbuild.WAAgentConfig{ + RDFormat: common.ToPtr(false), + RDEnableSwap: common.ToPtr(false), + }, + }, + Grub2Config: &osbuild.GRUB2Config{ + DisableRecovery: common.ToPtr(true), + DisableSubmenu: common.ToPtr(true), + Distributor: "$(sed 's, release .*$,,g' /etc/system-release)", + Terminal: []string{"serial", "console"}, + Serial: "serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1", + Timeout: 10, + TimeoutStyle: osbuild.GRUB2ConfigTimeoutStyleCountdown, + }, + UdevRules: &osbuild.UdevRulesStageOptions{ + Filename: "/etc/udev/rules.d/68-azure-sriov-nm-unmanaged.rules", + Rules: osbuild.UdevRules{ + osbuild.UdevRuleComment{ + Comment: []string{ + "Accelerated Networking on Azure exposes a new SRIOV interface to the VM.", + "This interface is transparently bonded to the synthetic interface,", + "so NetworkManager should just ignore any SRIOV interfaces.", + }, + }, + osbuild.NewUdevRule( + []osbuild.UdevKV{ + {K: "SUBSYSTEM", O: "==", V: "net"}, + {K: "DRIVERS", O: "==", V: "hv_pci"}, + {K: "ACTION", O: "==", V: "add"}, + {K: "ENV", A: "NM_UNMANAGED", O: "=", V: "1"}, + }, + ), + }, + }, + SystemdUnit: []*osbuild.SystemdUnitStageOptions{ + { + Unit: "nm-cloud-setup.service", + Dropin: "10-rh-enable-for-azure.conf", + Config: osbuild.SystemdServiceUnitDropin{ + Service: &osbuild.SystemdUnitServiceSection{ + Environment: "NM_CLOUD_SETUP_AZURE=yes", + }, + }, + }, + }, + DefaultTarget: common.ToPtr("multi-user.target"), +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/bare_metal.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/bare_metal.go new file mode 100644 index 00000000000..3a32281e6f8 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/bare_metal.go @@ -0,0 +1,26 @@ +package rhel10 + +import ( + "github.com/osbuild/images/pkg/distro/rhel" + "github.com/osbuild/images/pkg/rpmmd" +) + +func mkTarImgType() *rhel.ImageType { + return rhel.NewImageType( + "tar", + "root.tar.xz", + "application/x-tar", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: func(t *rhel.ImageType) rpmmd.PackageSet { + return rpmmd.PackageSet{ + Include: []string{"policycoreutils", "selinux-policy-targeted"}, + Exclude: []string{"rng-tools"}, + } + }, + }, + rhel.TarImage, + []string{"build"}, + []string{"os", "archive"}, + []string{"archive"}, + ) +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/distro.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/distro.go new file mode 100644 index 00000000000..ebf25719f04 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/distro.go @@ -0,0 +1,242 @@ +package rhel10 + +import ( + "fmt" + + "github.com/osbuild/images/pkg/arch" + "github.com/osbuild/images/pkg/customizations/oscap" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" + "github.com/osbuild/images/pkg/platform" +) + +var ( + // rhel9 & cs9 share the same list + // of allowed profiles so a single + // allow list can be used + oscapProfileAllowList = []oscap.Profile{ + oscap.AnssiBp28Enhanced, + oscap.AnssiBp28High, + oscap.AnssiBp28Intermediary, + oscap.AnssiBp28Minimal, + oscap.Cis, + oscap.CisServerL1, + oscap.CisWorkstationL1, + oscap.CisWorkstationL2, + oscap.Cui, + oscap.E8, + oscap.Hippa, + oscap.IsmO, + oscap.Ospp, + oscap.PciDss, + oscap.Stig, + oscap.StigGui, + } +) + +func newDistro(name string, major, minor int) *rhel.Distribution { + rd, err := rhel.NewDistribution(name, major, minor) + if err != nil { + panic(err) + } + rd.CheckOptions = checkOptions + + // Architecture definitions + x86_64 := rhel.NewArchitecture(rd, arch.ARCH_X86_64) + aarch64 := rhel.NewArchitecture(rd, arch.ARCH_AARCH64) + ppc64le := rhel.NewArchitecture(rd, arch.ARCH_PPC64LE) + s390x := rhel.NewArchitecture(rd, arch.ARCH_S390X) + + x86_64.AddImageTypes( + &platform.X86{ + BIOS: true, + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_QCOW2, + QCOW2Compat: "1.1", + }, + }, + mkQcow2ImgType(rd), + mkOCIImgType(rd), + ) + + x86_64.AddImageTypes( + &platform.X86{ + BIOS: true, + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_QCOW2, + }, + }, + mkOpenstackImgType(), + ) + + x86_64.AddImageTypes( + &platform.X86{ + BIOS: true, + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_VMDK, + }, + }, + mkVMDKImgType(), + ) + + x86_64.AddImageTypes( + &platform.X86{ + BIOS: true, + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_OVA, + }, + }, + mkOVAImgType(), + ) + + x86_64.AddImageTypes( + &platform.X86{}, + mkTarImgType(), + mkWSLImgType(), + ) + + aarch64.AddImageTypes( + &platform.Aarch64{ + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_QCOW2, + }, + }, + mkOpenstackImgType(), + ) + + aarch64.AddImageTypes( + &platform.Aarch64{}, + mkTarImgType(), + mkWSLImgType(), + ) + + aarch64.AddImageTypes( + &platform.Aarch64{ + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_QCOW2, + QCOW2Compat: "1.1", + }, + }, + mkQcow2ImgType(rd), + ) + + ppc64le.AddImageTypes( + &platform.PPC64LE{ + BIOS: true, + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_QCOW2, + QCOW2Compat: "1.1", + }, + }, + mkQcow2ImgType(rd), + ) + ppc64le.AddImageTypes( + &platform.PPC64LE{}, + mkTarImgType(), + ) + + s390x.AddImageTypes( + &platform.S390X{ + Zipl: true, + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_QCOW2, + QCOW2Compat: "1.1", + }, + }, + mkQcow2ImgType(rd), + ) + s390x.AddImageTypes( + &platform.S390X{}, + mkTarImgType(), + ) + + ec2X86Platform := &platform.X86{ + BIOS: true, + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_RAW, + }, + } + x86_64.AddImageTypes( + ec2X86Platform, + mkAMIImgTypeX86_64(), + ) + + aarch64.AddImageTypes( + &platform.Aarch64{ + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_RAW, + }, + }, + mkAMIImgTypeAarch64(), + ) + + azureX64Platform := &platform.X86{ + BIOS: true, + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_VHD, + }, + } + + azureAarch64Platform := &platform.Aarch64{ + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_VHD, + }, + } + + if rd.IsRHEL() { // RHEL-only (non-CentOS) image types + x86_64.AddImageTypes(azureX64Platform, mkAzureByosImgType(rd)) + aarch64.AddImageTypes(azureAarch64Platform, mkAzureByosImgType(rd)) + } else { + x86_64.AddImageTypes(azureX64Platform, mkAzureImgType()) + aarch64.AddImageTypes(azureAarch64Platform, mkAzureImgType()) + } + + rd.AddArches(x86_64, aarch64, ppc64le, s390x) + return rd +} + +func ParseID(idStr string) (*distro.ID, error) { + id, err := distro.ParseID(idStr) + if err != nil { + return nil, err + } + + if id.Name != "rhel" && id.Name != "centos" { + return nil, fmt.Errorf("invalid distro name: %s", id.Name) + } + + if id.MajorVersion != 10 { + return nil, fmt.Errorf("invalid distro major version: %d", id.MajorVersion) + } + + // CentOS does not use minor version + if id.Name == "centos" && id.MinorVersion != -1 { + return nil, fmt.Errorf("centos does not use minor version, but got: %d", id.MinorVersion) + } + + // RHEL uses minor version + if id.Name == "rhel" && id.MinorVersion == -1 { + return nil, fmt.Errorf("rhel requires minor version, but got: %d", id.MinorVersion) + } + + return id, nil +} + +func DistroFactory(idStr string) distro.Distro { + id, err := ParseID(idStr) + if err != nil { + return nil + } + + return newDistro(id.Name, 10, id.MinorVersion) +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/options.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/options.go new file mode 100644 index 00000000000..8be91a8b11d --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/options.go @@ -0,0 +1,79 @@ +package rhel10 + +import ( + "fmt" + "log" + + "golang.org/x/exp/slices" + + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/customizations/oscap" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" + "github.com/osbuild/images/pkg/policies" +) + +// checkOptions checks the validity and compatibility of options and customizations for the image type. +// Returns ([]string, error) where []string, if non-nil, will hold any generated warnings (e.g. deprecation notices). +func checkOptions(t *rhel.ImageType, bp *blueprint.Blueprint, options distro.ImageOptions) ([]string, error) { + customizations := bp.Customizations + + // holds warnings (e.g. deprecation notices) + var warnings []string + + mountpoints := customizations.GetFilesystems() + + err := blueprint.CheckMountpointsPolicy(mountpoints, policies.MountpointPolicies) + if err != nil { + return warnings, err + } + + if osc := customizations.GetOpenSCAP(); osc != nil { + if !oscap.IsProfileAllowed(osc.ProfileID, oscapProfileAllowList) { + return warnings, fmt.Errorf(fmt.Sprintf("OpenSCAP unsupported profile: %s", osc.ProfileID)) + } + if osc.ProfileID == "" { + return warnings, fmt.Errorf("OpenSCAP profile cannot be empty") + } + } + + // Check Directory/File Customizations are valid + dc := customizations.GetDirectories() + fc := customizations.GetFiles() + + err = blueprint.ValidateDirFileCustomizations(dc, fc) + if err != nil { + return warnings, err + } + err = blueprint.CheckDirectoryCustomizationsPolicy(dc, policies.CustomDirectoriesPolicies) + if err != nil { + return warnings, err + } + + err = blueprint.CheckFileCustomizationsPolicy(fc, policies.CustomFilesPolicies) + if err != nil { + return warnings, err + } + + // check if repository customizations are valid + _, err = customizations.GetRepositories() + if err != nil { + return warnings, err + } + + if customizations.GetFIPS() && !common.IsBuildHostFIPSEnabled() { + w := fmt.Sprintln(common.FIPSEnabledImageWarning) + log.Print(w) + warnings = append(warnings, w) + } + + if customizations.GetInstaller() != nil { + // only supported by the Anaconda installer + if slices.Index([]string{"image-installer", "edge-installer", "live-installer"}, t.Name()) == -1 { + return warnings, fmt.Errorf("installer customizations are not supported for %q", t.Name()) + } + } + + return warnings, nil +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/package_sets.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/package_sets.go new file mode 100644 index 00000000000..c0c9994b481 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/package_sets.go @@ -0,0 +1,78 @@ +package rhel10 + +// This file defines package sets that are used by more than one image type. + +import ( + "github.com/osbuild/images/pkg/arch" + "github.com/osbuild/images/pkg/distro/rhel" + "github.com/osbuild/images/pkg/rpmmd" +) + +// BUILD PACKAGE SETS + +// distro-wide build package set +func distroBuildPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + ps := rpmmd.PackageSet{ + Include: []string{ + "dnf", + "dosfstools", + "e2fsprogs", + "glibc", + "lorax-templates-generic", + "lorax-templates-rhel", + "lvm2", + "policycoreutils", + "python3-iniparse", + "qemu-img", + "selinux-policy-targeted", + "systemd", + "tar", + "xfsprogs", + "xz", + }, + } + + switch t.Arch().Name() { + + case arch.ARCH_X86_64.String(): + ps = ps.Append(x8664BuildPackageSet(t)) + + case arch.ARCH_PPC64LE.String(): + ps = ps.Append(ppc64leBuildPackageSet(t)) + } + + return ps +} + +// x86_64 build package set +func x8664BuildPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + return rpmmd.PackageSet{ + Include: []string{ + "grub2-pc", + }, + } +} + +// ppc64le build package set +func ppc64leBuildPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + return rpmmd.PackageSet{ + Include: []string{ + "grub2-ppc64le", + "grub2-ppc64le-modules", + }, + } +} + +// OS package sets + +// packages that are only in some (sub)-distributions +func distroSpecificPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + if t.IsRHEL() { + return rpmmd.PackageSet{ + Include: []string{ + "insights-client", + }, + } + } + return rpmmd.PackageSet{} +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/partition_tables.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/partition_tables.go new file mode 100644 index 00000000000..93a36f15d05 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/partition_tables.go @@ -0,0 +1,179 @@ +package rhel10 + +import ( + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/arch" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/distro/rhel" +) + +func defaultBasePartitionTables(t *rhel.ImageType) (disk.PartitionTable, bool) { + switch t.Arch().Name() { + case arch.ARCH_X86_64.String(): + return disk.PartitionTable{ + UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", + Type: "gpt", + Partitions: []disk.Partition{ + { + Size: 1 * common.MebiByte, + Bootable: true, + Type: disk.BIOSBootPartitionGUID, + UUID: disk.BIOSBootPartitionUUID, + }, + { + Size: 200 * common.MebiByte, + Type: disk.EFISystemPartitionGUID, + UUID: disk.EFISystemPartitionUUID, + Payload: &disk.Filesystem{ + Type: "vfat", + UUID: disk.EFIFilesystemUUID, + Mountpoint: "/boot/efi", + Label: "EFI-SYSTEM", + FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt", + FSTabFreq: 0, + FSTabPassNo: 2, + }, + }, + { + Size: 1 * common.GibiByte, + Type: disk.XBootLDRPartitionGUID, + UUID: disk.FilesystemDataUUID, + Payload: &disk.Filesystem{ + Type: "xfs", + Mountpoint: "/boot", + Label: "boot", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + { + Size: 2 * common.GibiByte, + Type: disk.FilesystemDataGUID, + UUID: disk.RootPartitionUUID, + Payload: &disk.Filesystem{ + Type: "xfs", + Label: "root", + Mountpoint: "/", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + }, + }, true + case arch.ARCH_AARCH64.String(): + return disk.PartitionTable{ + UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", + Type: "gpt", + Partitions: []disk.Partition{ + { + Size: 200 * common.MebiByte, + Type: disk.EFISystemPartitionGUID, + UUID: disk.EFISystemPartitionUUID, + Payload: &disk.Filesystem{ + Type: "vfat", + UUID: disk.EFIFilesystemUUID, + Mountpoint: "/boot/efi", + Label: "EFI-SYSTEM", + FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt", + FSTabFreq: 0, + FSTabPassNo: 2, + }, + }, + { + Size: 1 * common.GibiByte, + Type: disk.XBootLDRPartitionGUID, + UUID: disk.FilesystemDataUUID, + Payload: &disk.Filesystem{ + Type: "xfs", + Mountpoint: "/boot", + Label: "boot", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + { + Size: 2 * common.GibiByte, + Type: disk.FilesystemDataGUID, + UUID: disk.RootPartitionUUID, + Payload: &disk.Filesystem{ + Type: "xfs", + Label: "root", + Mountpoint: "/", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + }, + }, true + case arch.ARCH_PPC64LE.String(): + return disk.PartitionTable{ + UUID: "0x14fc63d2", + Type: "dos", + Partitions: []disk.Partition{ + { + Size: 4 * common.MebiByte, + Type: "41", + Bootable: true, + }, + { + Size: 1 * common.GibiByte, + Payload: &disk.Filesystem{ + Type: "xfs", + Mountpoint: "/boot", + Label: "boot", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + { + Size: 2 * common.GibiByte, + Payload: &disk.Filesystem{ + Type: "xfs", + Mountpoint: "/", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + }, + }, true + + case arch.ARCH_S390X.String(): + return disk.PartitionTable{ + UUID: "0x14fc63d2", + Type: "dos", + Partitions: []disk.Partition{ + { + Size: 1 * common.GibiByte, + Payload: &disk.Filesystem{ + Type: "xfs", + Mountpoint: "/boot", + Label: "boot", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + { + Size: 2 * common.GibiByte, + Bootable: true, + Payload: &disk.Filesystem{ + Type: "xfs", + Mountpoint: "/", + FSTabOptions: "defaults", + FSTabFreq: 0, + FSTabPassNo: 0, + }, + }, + }, + }, true + + default: + return disk.PartitionTable{}, false + } +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/qcow2.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/qcow2.go new file mode 100644 index 00000000000..cdcecc3c1bd --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/qcow2.go @@ -0,0 +1,200 @@ +package rhel10 + +import ( + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/subscription" +) + +func mkQcow2ImgType(d *rhel.Distribution) *rhel.ImageType { + it := rhel.NewImageType( + "qcow2", + "disk.qcow2", + "application/x-qemu-disk", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: qcow2CommonPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "qcow2"}, + []string{"qcow2"}, + ) + + it.DefaultImageConfig = qcowImageConfig(d) + it.KernelOptions = "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0" + it.DefaultSize = 10 * common.GibiByte + it.Bootable = true + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +func mkOCIImgType(d *rhel.Distribution) *rhel.ImageType { + it := rhel.NewImageType( + "oci", + "disk.qcow2", + "application/x-qemu-disk", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: qcow2CommonPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "qcow2"}, + []string{"qcow2"}, + ) + + it.DefaultImageConfig = qcowImageConfig(d) + it.KernelOptions = "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0" + it.DefaultSize = 10 * common.GibiByte + it.Bootable = true + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +func mkOpenstackImgType() *rhel.ImageType { + it := rhel.NewImageType( + "openstack", + "disk.qcow2", + "application/x-qemu-disk", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: openstackCommonPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "qcow2"}, + []string{"qcow2"}, + ) + + it.DefaultImageConfig = &distro.ImageConfig{ + Locale: common.ToPtr("en_US.UTF-8"), + } + it.KernelOptions = "ro net.ifnames=0" + it.DefaultSize = 4 * common.GibiByte + it.Bootable = true + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +func qcow2CommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + ps := rpmmd.PackageSet{ + Include: []string{ + "@core", + "chrony", + "cloud-init", + "cloud-utils-growpart", + "cockpit-system", + "cockpit-ws", + "dnf-utils", + "dosfstools", + "nfs-utils", + "oddjob", + "oddjob-mkhomedir", + "psmisc", + "python3-jsonschema", + "qemu-guest-agent", + "redhat-release", + "redhat-release-eula", + "rsync", + "tar", + "tuned", + "tcpdump", + }, + Exclude: []string{ + "aic94xx-firmware", + "alsa-firmware", + "alsa-lib", + "alsa-tools-firmware", + "biosdevname", + "dnf-plugin-spacewalk", + "dracut-config-rescue", + "fedora-release", + "fedora-repos", + "firewalld", + "iprutils", + "ivtv-firmware", + "iwl1000-firmware", + "iwl100-firmware", + "iwl105-firmware", + "iwl135-firmware", + "iwl2000-firmware", + "iwl2030-firmware", + "iwl3160-firmware", + "iwl3945-firmware", + "iwl4965-firmware", + "iwl5000-firmware", + "iwl5150-firmware", + "iwl6000-firmware", + "iwl6000g2a-firmware", + "iwl6000g2b-firmware", + "iwl6050-firmware", + "iwl7260-firmware", + "langpacks-*", + "langpacks-en", + "libertas-sd8787-firmware", + "nss", + "plymouth", + "rng-tools", + "udisks2", + }, + }.Append(distroSpecificPackageSet(t)) + + // Ensure to not pull in subscription-manager on non-RHEL distro + if t.IsRHEL() { + ps = ps.Append(rpmmd.PackageSet{ + Include: []string{ + "subscription-manager-cockpit", + }, + }) + } + + return ps +} + +func openstackCommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + ps := rpmmd.PackageSet{ + Include: []string{ + // Defaults + "@core", + "langpacks-en", + "tuned", + + // From the lorax kickstart + "cloud-init", + "qemu-guest-agent", + "spice-vdagent", + }, + Exclude: []string{ + "dracut-config-rescue", + "rng-tools", + }, + } + + return ps +} + +func qcowImageConfig(d *rhel.Distribution) *distro.ImageConfig { + ic := &distro.ImageConfig{ + DefaultTarget: common.ToPtr("multi-user.target"), + } + if d.IsRHEL() { + ic.RHSMConfig = map[subscription.RHSMStatus]*osbuild.RHSMStageOptions{ + subscription.RHSMConfigNoSubscription: { + DnfPlugins: &osbuild.RHSMStageOptionsDnfPlugins{ + ProductID: &osbuild.RHSMStageOptionsDnfPlugin{ + Enabled: false, + }, + SubscriptionManager: &osbuild.RHSMStageOptionsDnfPlugin{ + Enabled: false, + }, + }, + }, + } + + } + return ic +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/ubi.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/ubi.go new file mode 100644 index 00000000000..603fd75f26b --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/ubi.go @@ -0,0 +1,96 @@ +package rhel10 + +import ( + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" +) + +func mkWSLImgType() *rhel.ImageType { + it := rhel.NewImageType( + "wsl", + "disk.tar.gz", + "application/x-tar", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: ubiCommonPackageSet, + }, + rhel.TarImage, + []string{"build"}, + []string{"os", "archive"}, + []string{"archive"}, + ) + + it.DefaultImageConfig = &distro.ImageConfig{ + Locale: common.ToPtr("en_US.UTF-8"), + NoSElinux: common.ToPtr(true), + WSLConfig: &osbuild.WSLConfStageOptions{ + Boot: osbuild.WSLConfBootOptions{ + Systemd: true, + }, + }, + } + + return it +} + +func ubiCommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + ps := rpmmd.PackageSet{ + Include: []string{ + "alternatives", + "audit-libs", + "basesystem", + "bash", + "ca-certificates", + "coreutils-single", + "crypto-policies-scripts", + "curl-minimal", + "dejavu-sans-fonts", + "dnf", + "filesystem", + "findutils", + "gdb-gdbserver", + // Differs from official UBI, as we don't include CRB repos + // "gdbm", + "glibc-minimal-langpack", + "gmp", + "gnupg2", + "gobject-introspection", + "hostname", + "langpacks-en", + "libcurl-minimal", + "openssl", + "pam", + "passwd", + "procps-ng", + "python3", + "python3-inotify", + "redhat-release", + "rootfiles", + "rpm", + "sed", + "setup", + "shadow-utils", + "subscription-manager", + "systemd", + "tar", + "tpm2-tss", + "tzdata", + "util-linux", + "vim-minimal", + "yum", + }, + Exclude: []string{ + "gawk-all-langpacks", + "glibc-gconv-extra", + "glibc-langpack-en", + "openssl-pkcs11", + "python-unversioned-command", + "redhat-release-eula", + "rpm-plugin-systemd-inhibit", + }, + } + + return ps +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/vmdk.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/vmdk.go new file mode 100644 index 00000000000..cb3da7dcfd8 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel10/vmdk.go @@ -0,0 +1,80 @@ +package rhel10 + +import ( + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" + "github.com/osbuild/images/pkg/rpmmd" +) + +const vmdkKernelOptions = "ro net.ifnames=0" + +func mkVMDKImgType() *rhel.ImageType { + it := rhel.NewImageType( + "vmdk", + "disk.vmdk", + "application/x-vmdk", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: vmdkCommonPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "vmdk"}, + []string{"vmdk"}, + ) + + it.DefaultImageConfig = &distro.ImageConfig{ + Locale: common.ToPtr("en_US.UTF-8"), + } + it.KernelOptions = vmdkKernelOptions + it.Bootable = true + it.DefaultSize = 4 * common.GibiByte + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +func mkOVAImgType() *rhel.ImageType { + it := rhel.NewImageType( + "ova", + "image.ova", + "application/ovf", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: vmdkCommonPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "vmdk", "ovf", "archive"}, + []string{"archive"}, + ) + + it.DefaultImageConfig = &distro.ImageConfig{ + Locale: common.ToPtr("en_US.UTF-8"), + } + it.KernelOptions = vmdkKernelOptions + it.Bootable = true + it.DefaultSize = 4 * common.GibiByte + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +func vmdkCommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + ps := rpmmd.PackageSet{ + Include: []string{ + "@core", + "chrony", + "cloud-init", + "firewalld", + "langpacks-en", + "open-vm-tools", + "tuned", + }, + Exclude: []string{ + "dracut-config-rescue", + "rng-tools", + }, + } + + return ps +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel9/ami.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/ami.go similarity index 63% rename from vendor/github.com/osbuild/images/pkg/distro/rhel9/ami.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/ami.go index 11452045029..53025e07c38 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/rhel9/ami.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/ami.go @@ -3,6 +3,7 @@ package rhel9 import ( "github.com/osbuild/images/internal/common" "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" "github.com/osbuild/images/pkg/osbuild" "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/images/pkg/subscription" @@ -11,118 +12,6 @@ import ( // TODO: move these to the EC2 environment const amiKernelOptions = "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295" -var ( - amiImgTypeX86_64 = imageType{ - name: "ami", - filename: "image.raw", - mimeType: "application/octet-stream", - packageSets: map[string]packageSetFunc{ - osPkgsKey: ec2CommonPackageSet, - }, - kernelOptions: amiKernelOptions, - bootable: true, - defaultSize: 10 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image"}, - exports: []string{"image"}, - basePartitionTables: defaultBasePartitionTables, - } - - ec2ImgTypeX86_64 = imageType{ - name: "ec2", - filename: "image.raw.xz", - mimeType: "application/xz", - compression: "xz", - packageSets: map[string]packageSetFunc{ - osPkgsKey: rhelEc2PackageSet, - }, - kernelOptions: amiKernelOptions, - bootable: true, - defaultSize: 10 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "xz"}, - exports: []string{"xz"}, - basePartitionTables: defaultBasePartitionTables, - } - - ec2HaImgTypeX86_64 = imageType{ - name: "ec2-ha", - filename: "image.raw.xz", - mimeType: "application/xz", - compression: "xz", - packageSets: map[string]packageSetFunc{ - buildPkgsKey: ec2BuildPackageSet, - osPkgsKey: rhelEc2HaPackageSet, - }, - kernelOptions: amiKernelOptions, - bootable: true, - defaultSize: 10 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "xz"}, - exports: []string{"xz"}, - basePartitionTables: defaultBasePartitionTables, - } - - amiImgTypeAarch64 = imageType{ - name: "ami", - filename: "image.raw", - mimeType: "application/octet-stream", - packageSets: map[string]packageSetFunc{ - buildPkgsKey: ec2BuildPackageSet, - osPkgsKey: ec2CommonPackageSet, - }, - kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0", - bootable: true, - defaultSize: 10 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image"}, - exports: []string{"image"}, - basePartitionTables: defaultBasePartitionTables, - } - - ec2ImgTypeAarch64 = imageType{ - name: "ec2", - filename: "image.raw.xz", - mimeType: "application/xz", - compression: "xz", - packageSets: map[string]packageSetFunc{ - buildPkgsKey: ec2BuildPackageSet, - osPkgsKey: rhelEc2PackageSet, - }, - kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0", - bootable: true, - defaultSize: 10 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "xz"}, - exports: []string{"xz"}, - basePartitionTables: defaultBasePartitionTables, - } - - ec2SapImgTypeX86_64 = imageType{ - name: "ec2-sap", - filename: "image.raw.xz", - mimeType: "application/xz", - compression: "xz", - packageSets: map[string]packageSetFunc{ - buildPkgsKey: ec2BuildPackageSet, - osPkgsKey: rhelEc2SapPackageSet, - }, - kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 processor.max_cstate=1 intel_idle.max_cstate=1", - bootable: true, - defaultSize: 10 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "xz"}, - exports: []string{"xz"}, - basePartitionTables: defaultBasePartitionTables, - } -) - // default EC2 images config (common for all architectures) func baseEc2ImageConfig() *distro.ImageConfig { return &distro.ImageConfig{ @@ -286,7 +175,7 @@ func defaultAMIImageConfigX86_64() *distro.ImageConfig { } // common ec2 image build package set -func ec2BuildPackageSet(t *imageType) rpmmd.PackageSet { +func ec2BuildPackageSet(t *rhel.ImageType) rpmmd.PackageSet { return distroBuildPackageSet(t).Append( rpmmd.PackageSet{ Include: []string{ @@ -295,10 +184,11 @@ func ec2BuildPackageSet(t *imageType) rpmmd.PackageSet { }) } -func ec2CommonPackageSet(t *imageType) rpmmd.PackageSet { +func ec2CommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { ps := rpmmd.PackageSet{ Include: []string{ "@core", + "authselect-compat", "chrony", "cloud-init", "cloud-utils-growpart", @@ -350,25 +240,21 @@ func ec2CommonPackageSet(t *imageType) rpmmd.PackageSet { }, }.Append(distroSpecificPackageSet(t)) - if t.arch.distro.releaseVersion == "9" { - ps.Include = append(ps.Include, "authselect-compat") - } - return ps } // common rhel ec2 RHUI image package set -func rhelEc2CommonPackageSet(t *imageType) rpmmd.PackageSet { +func rhelEc2CommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { ps := ec2CommonPackageSet(t) // Include "redhat-cloud-client-configuration" on 9.1+ (COMPOSER-1805) - if common.VersionGreaterThanOrEqual(t.arch.distro.osVersion, "9.1") { + if common.VersionGreaterThanOrEqual(t.Arch().Distro().OsVersion(), "9.1") { ps.Include = append(ps.Include, "redhat-cloud-client-configuration") } return ps } // rhel-ec2 image package set -func rhelEc2PackageSet(t *imageType) rpmmd.PackageSet { +func rhelEc2PackageSet(t *rhel.ImageType) rpmmd.PackageSet { ec2PackageSet := rhelEc2CommonPackageSet(t) ec2PackageSet = ec2PackageSet.Append(rpmmd.PackageSet{ Include: []string{ @@ -382,7 +268,7 @@ func rhelEc2PackageSet(t *imageType) rpmmd.PackageSet { } // rhel-ha-ec2 image package set -func rhelEc2HaPackageSet(t *imageType) rpmmd.PackageSet { +func rhelEc2HaPackageSet(t *rhel.ImageType) rpmmd.PackageSet { ec2HaPackageSet := rhelEc2CommonPackageSet(t) ec2HaPackageSet = ec2HaPackageSet.Append(rpmmd.PackageSet{ Include: []string{ @@ -401,7 +287,7 @@ func rhelEc2HaPackageSet(t *imageType) rpmmd.PackageSet { // rhel-sap-ec2 image package set // Includes the common ec2 package set, the common SAP packages, and // the amazon rhui sap package -func rhelEc2SapPackageSet(t *imageType) rpmmd.PackageSet { +func rhelEc2SapPackageSet(t *rhel.ImageType) rpmmd.PackageSet { return rpmmd.PackageSet{ Include: []string{ "rh-amazon-rhui-client-sap-bundle-e4s", @@ -414,44 +300,149 @@ func rhelEc2SapPackageSet(t *imageType) rpmmd.PackageSet { }.Append(rhelEc2CommonPackageSet(t)).Append(SapPackageSet(t)) } -func mkEc2ImgTypeX86_64(osVersion string, rhsm bool) imageType { - it := ec2ImgTypeX86_64 - ic := defaultEc2ImageConfigX86_64(osVersion, rhsm) - it.defaultImageConfig = ic +func mkEc2ImgTypeX86_64(osVersion string, rhsm bool) *rhel.ImageType { + it := rhel.NewImageType( + "ec2", + "image.raw.xz", + "application/xz", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: rhelEc2PackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "xz"}, + []string{"xz"}, + ) + + it.Compression = "xz" + it.KernelOptions = amiKernelOptions + it.Bootable = true + it.DefaultSize = 10 * common.GibiByte + it.DefaultImageConfig = defaultEc2ImageConfigX86_64(osVersion, rhsm) + it.BasePartitionTables = defaultBasePartitionTables + return it } -func mkAMIImgTypeX86_64() imageType { - it := amiImgTypeX86_64 - ic := defaultAMIImageConfigX86_64() - it.defaultImageConfig = ic +func mkAMIImgTypeX86_64() *rhel.ImageType { + it := rhel.NewImageType( + "ami", + "image.raw", + "application/octet-stream", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: ec2CommonPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image"}, + []string{"image"}, + ) + + it.KernelOptions = amiKernelOptions + it.Bootable = true + it.DefaultSize = 10 * common.GibiByte + it.DefaultImageConfig = defaultAMIImageConfigX86_64() + it.BasePartitionTables = defaultBasePartitionTables + return it } -func mkEC2SapImgTypeX86_64(osVersion string, rhsm bool) imageType { - it := ec2SapImgTypeX86_64 - it.defaultImageConfig = sapImageConfig(osVersion).InheritFrom(defaultEc2ImageConfigX86_64(osVersion, rhsm)) +func mkEC2SapImgTypeX86_64(osVersion string, rhsm bool) *rhel.ImageType { + it := rhel.NewImageType( + "ec2-sap", + "image.raw.xz", + "application/xz", + map[string]rhel.PackageSetFunc{ + rhel.BuildPkgsKey: ec2BuildPackageSet, + rhel.OSPkgsKey: rhelEc2SapPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "xz"}, + []string{"xz"}, + ) + + it.Compression = "xz" + it.KernelOptions = "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 processor.max_cstate=1 intel_idle.max_cstate=1" + it.Bootable = true + it.DefaultSize = 10 * common.GibiByte + it.DefaultImageConfig = sapImageConfig(osVersion).InheritFrom(defaultEc2ImageConfigX86_64(osVersion, rhsm)) + it.BasePartitionTables = defaultBasePartitionTables + return it } -func mkEc2HaImgTypeX86_64(osVersion string, rhsm bool) imageType { - it := ec2HaImgTypeX86_64 - ic := defaultEc2ImageConfigX86_64(osVersion, rhsm) - it.defaultImageConfig = ic +func mkEc2HaImgTypeX86_64(osVersion string, rhsm bool) *rhel.ImageType { + it := rhel.NewImageType( + "ec2-ha", + "image.raw.xz", + "application/xz", + map[string]rhel.PackageSetFunc{ + rhel.BuildPkgsKey: ec2BuildPackageSet, + rhel.OSPkgsKey: rhelEc2HaPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "xz"}, + []string{"xz"}, + ) + + it.Compression = "xz" + it.KernelOptions = amiKernelOptions + it.Bootable = true + it.DefaultSize = 10 * common.GibiByte + it.DefaultImageConfig = defaultEc2ImageConfigX86_64(osVersion, rhsm) + it.BasePartitionTables = defaultBasePartitionTables + return it } -func mkAMIImgTypeAarch64() imageType { - it := amiImgTypeAarch64 - ic := defaultAMIImageConfig() - it.defaultImageConfig = ic +func mkAMIImgTypeAarch64() *rhel.ImageType { + it := rhel.NewImageType( + "ami", + "image.raw", + "application/octet-stream", + map[string]rhel.PackageSetFunc{ + rhel.BuildPkgsKey: ec2BuildPackageSet, + rhel.OSPkgsKey: ec2CommonPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image"}, + []string{"image"}, + ) + + it.KernelOptions = "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0" + it.Bootable = true + it.DefaultSize = 10 * common.GibiByte + it.DefaultImageConfig = defaultAMIImageConfig() + it.BasePartitionTables = defaultBasePartitionTables + return it } -func mkEC2ImgTypeAarch64(osVersion string, rhsm bool) imageType { - it := ec2ImgTypeAarch64 - ic := defaultEc2ImageConfig(osVersion, rhsm) - it.defaultImageConfig = ic +func mkEC2ImgTypeAarch64(osVersion string, rhsm bool) *rhel.ImageType { + it := rhel.NewImageType( + "ec2", + "image.raw.xz", + "application/xz", + map[string]rhel.PackageSetFunc{ + rhel.BuildPkgsKey: ec2BuildPackageSet, + rhel.OSPkgsKey: rhelEc2PackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "xz"}, + []string{"xz"}, + ) + + it.Compression = "xz" + it.KernelOptions = "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0" + it.Bootable = true + it.DefaultSize = 10 * common.GibiByte + it.DefaultImageConfig = defaultEc2ImageConfig(osVersion, rhsm) + it.BasePartitionTables = defaultBasePartitionTables + return it } diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel9/azure.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/azure.go similarity index 78% rename from vendor/github.com/osbuild/images/pkg/distro/rhel9/azure.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/azure.go index 769c3b21e75..fafbc5277b8 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/rhel9/azure.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/azure.go @@ -5,98 +5,113 @@ import ( "github.com/osbuild/images/pkg/arch" "github.com/osbuild/images/pkg/disk" "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" "github.com/osbuild/images/pkg/osbuild" "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/images/pkg/subscription" ) -var ( - // Azure non-RHEL image type - azureImgType = imageType{ - name: "vhd", - filename: "disk.vhd", - mimeType: "application/x-vhd", - packageSets: map[string]packageSetFunc{ - osPkgsKey: azurePackageSet, +// Azure non-RHEL image type +func mkAzureImgType() *rhel.ImageType { + it := rhel.NewImageType( + "vhd", + "disk.vhd", + "application/x-vhd", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: azurePackageSet, }, - defaultImageConfig: defaultAzureImageConfig, - kernelOptions: defaultAzureKernelOptions, - bootable: true, - defaultSize: 4 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "vpc"}, - exports: []string{"vpc"}, - basePartitionTables: defaultBasePartitionTables, - } + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "vpc"}, + []string{"vpc"}, + ) - // Azure RHUI image type - azureRhuiImgType = imageType{ - name: "azure-rhui", - filename: "disk.vhd.xz", - mimeType: "application/xz", - compression: "xz", - packageSets: map[string]packageSetFunc{ - osPkgsKey: azureRhuiPackageSet, - }, - defaultImageConfig: defaultAzureRhuiImageConfig.InheritFrom(defaultAzureImageConfig), - kernelOptions: defaultAzureKernelOptions, - bootable: true, - defaultSize: 64 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "vpc", "xz"}, - exports: []string{"xz"}, - basePartitionTables: azureRhuiBasePartitionTables, - } -) + it.KernelOptions = defaultAzureKernelOptions + it.Bootable = true + it.DefaultSize = 4 * common.GibiByte + it.DefaultImageConfig = defaultAzureImageConfig + it.BasePartitionTables = defaultBasePartitionTables + + return it +} // Azure BYOS image type -func azureByosImgType(rd distribution) imageType { - return imageType{ - name: "vhd", - filename: "disk.vhd", - mimeType: "application/x-vhd", - packageSets: map[string]packageSetFunc{ - osPkgsKey: azurePackageSet, +func mkAzureByosImgType(rd distro.Distro) *rhel.ImageType { + it := rhel.NewImageType( + "vhd", + "disk.vhd", + "application/x-vhd", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: azurePackageSet, }, - defaultImageConfig: defaultAzureByosImageConfig(rd).InheritFrom(defaultAzureImageConfig), - kernelOptions: defaultAzureKernelOptions, - bootable: true, - defaultSize: 4 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "vpc"}, - exports: []string{"vpc"}, - basePartitionTables: defaultBasePartitionTables, - } + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "vpc"}, + []string{"vpc"}, + ) + + it.KernelOptions = defaultAzureKernelOptions + it.Bootable = true + it.DefaultSize = 4 * common.GibiByte + it.DefaultImageConfig = defaultAzureByosImageConfig.InheritFrom(defaultAzureImageConfig) + it.BasePartitionTables = defaultBasePartitionTables + + return it } -func azureSapRhuiImgType(rd distribution) imageType { - return imageType{ - name: "azure-sap-rhui", - filename: "disk.vhd.xz", - mimeType: "application/xz", - compression: "xz", - packageSets: map[string]packageSetFunc{ - osPkgsKey: azureSapPackageSet, +// Azure RHUI image type +func mkAzureRhuiImgType() *rhel.ImageType { + it := rhel.NewImageType( + "azure-rhui", + "disk.vhd.xz", + "application/xz", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: azureRhuiPackageSet, }, - defaultImageConfig: defaultAzureRhuiImageConfig.InheritFrom(sapAzureImageConfig(rd)), - kernelOptions: defaultAzureKernelOptions, - bootable: true, - defaultSize: 64 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "vpc", "xz"}, - exports: []string{"xz"}, - basePartitionTables: azureRhuiBasePartitionTables, - } + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "vpc", "xz"}, + []string{"xz"}, + ) + + it.Compression = "xz" + it.KernelOptions = defaultAzureKernelOptions + it.Bootable = true + it.DefaultSize = 64 * common.GibiByte + it.DefaultImageConfig = defaultAzureRhuiImageConfig.InheritFrom(defaultAzureImageConfig) + it.BasePartitionTables = azureRhuiBasePartitionTables + + return it +} + +func mkAzureSapRhuiImgType(rd distro.Distro) *rhel.ImageType { + it := rhel.NewImageType( + "azure-sap-rhui", + "disk.vhd.xz", + "application/xz", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: azureSapPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "vpc", "xz"}, + []string{"xz"}, + ) + + it.Compression = "xz" + it.KernelOptions = defaultAzureKernelOptions + it.Bootable = true + it.DefaultSize = 64 * common.GibiByte + it.DefaultImageConfig = defaultAzureRhuiImageConfig.InheritFrom(sapAzureImageConfig(rd)) + it.BasePartitionTables = azureRhuiBasePartitionTables + + return it } // PACKAGE SETS // Common Azure image package set -func azureCommonPackageSet(t *imageType) rpmmd.PackageSet { +func azureCommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { ps := rpmmd.PackageSet{ Include: []string{ "@Server", @@ -176,12 +191,12 @@ func azureCommonPackageSet(t *imageType) rpmmd.PackageSet { } // Azure BYOS image package set -func azurePackageSet(t *imageType) rpmmd.PackageSet { +func azurePackageSet(t *rhel.ImageType) rpmmd.PackageSet { return azureCommonPackageSet(t) } // Azure RHUI image package set -func azureRhuiPackageSet(t *imageType) rpmmd.PackageSet { +func azureRhuiPackageSet(t *rhel.ImageType) rpmmd.PackageSet { return rpmmd.PackageSet{ Include: []string{ "rhui-azure-rhel9", @@ -189,17 +204,28 @@ func azureRhuiPackageSet(t *imageType) rpmmd.PackageSet { }.Append(azureCommonPackageSet(t)) } +// Azure SAP image package set +// Includes the common azure package set, the common SAP packages, and +// the azure rhui sap package. +func azureSapPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + return rpmmd.PackageSet{ + Include: []string{ + "rhui-azure-rhel9-sap-ha", + }, + }.Append(azureCommonPackageSet(t)).Append(SapPackageSet(t)) +} + // PARTITION TABLES -func azureRhuiBasePartitionTables(t *imageType) (disk.PartitionTable, bool) { +func azureRhuiBasePartitionTables(t *rhel.ImageType) (disk.PartitionTable, bool) { // RHEL >= 9.3 needs to have a bigger /boot, see RHEL-7999 bootSize := uint64(600) * common.MebiByte - if common.VersionLessThan(t.arch.distro.osVersion, "9.3") && t.arch.distro.isRHEL() { + if common.VersionLessThan(t.Arch().Distro().OsVersion(), "9.3") && t.IsRHEL() { bootSize = 500 * common.MebiByte } - switch t.platform.GetArch() { - case arch.ARCH_X86_64: + switch t.Arch().Name() { + case arch.ARCH_X86_64.String(): return disk.PartitionTable{ UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", Type: "gpt", @@ -308,7 +334,7 @@ func azureRhuiBasePartitionTables(t *imageType) (disk.PartitionTable, bool) { }, }, }, true - case arch.ARCH_AARCH64: + case arch.ARCH_AARCH64.String(): return disk.PartitionTable{ UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", Type: "gpt", @@ -416,8 +442,10 @@ func azureRhuiBasePartitionTables(t *imageType) (disk.PartitionTable, bool) { } } +// IMAGE CONFIG + // use loglevel=3 as described in the RHEL documentation and used in existing RHEL images built by MSFT -var defaultAzureKernelOptions = "ro loglevel=3 console=tty1 console=ttyS0 earlyprintk=ttyS0 rootdelay=300" +const defaultAzureKernelOptions = "ro loglevel=3 console=tty1 console=ttyS0 earlyprintk=ttyS0 rootdelay=300" // based on https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/deploying_rhel_9_on_microsoft_azure/assembly_deploying-a-rhel-image-as-a-virtual-machine-on-microsoft-azure_cloud-content-azure#making-configuration-changes_configure-the-image-azure var defaultAzureImageConfig = &distro.ImageConfig{ @@ -576,18 +604,10 @@ var defaultAzureImageConfig = &distro.ImageConfig{ // Diff of the default Image Config compare to the `defaultAzureImageConfig` // The configuration for non-RHUI images does not touch the RHSM configuration at all. // https://issues.redhat.com/browse/COMPOSER-2157 -func defaultAzureByosImageConfig(rd distribution) *distro.ImageConfig { - ic := &distro.ImageConfig{} - // NOTE RHEL 10 content is currently unsigned - remove this when GPG keys get added to the repos - if rd.Releasever() == "9" { - ic = &distro.ImageConfig{ - GPGKeyFiles: []string{ - "/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release", - }, - } - } - return ic - +var defaultAzureByosImageConfig = &distro.ImageConfig{ + GPGKeyFiles: []string{ + "/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release", + }, } // Diff of the default Image Config compare to the `defaultAzureImageConfig` @@ -624,17 +644,6 @@ var defaultAzureRhuiImageConfig = &distro.ImageConfig{ }, } -// Azure SAP image package set -// Includes the common azure package set, the common SAP packages, and -// the azure rhui sap package. -func azureSapPackageSet(t *imageType) rpmmd.PackageSet { - return rpmmd.PackageSet{ - Include: []string{ - "rhui-azure-rhel9-sap-ha", - }, - }.Append(azureCommonPackageSet(t)).Append(SapPackageSet(t)) -} - -func sapAzureImageConfig(rd distribution) *distro.ImageConfig { - return sapImageConfig(rd.osVersion).InheritFrom(defaultAzureRhuiImageConfig.InheritFrom(defaultAzureImageConfig)) +func sapAzureImageConfig(rd distro.Distro) *distro.ImageConfig { + return sapImageConfig(rd.OsVersion()).InheritFrom(defaultAzureRhuiImageConfig.InheritFrom(defaultAzureImageConfig)) } diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel9/bare_metal.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/bare_metal.go similarity index 81% rename from vendor/github.com/osbuild/images/pkg/distro/rhel9/bare_metal.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/bare_metal.go index 1d25990b4c9..a95578ba33b 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/rhel9/bare_metal.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/bare_metal.go @@ -5,48 +5,55 @@ import ( "github.com/osbuild/images/internal/common" "github.com/osbuild/images/pkg/arch" + "github.com/osbuild/images/pkg/distro/rhel" "github.com/osbuild/images/pkg/rpmmd" ) -var ( - tarImgType = imageType{ - name: "tar", - filename: "root.tar.xz", - mimeType: "application/x-tar", - packageSets: map[string]packageSetFunc{ - osPkgsKey: func(t *imageType) rpmmd.PackageSet { +func mkTarImgType() *rhel.ImageType { + return rhel.NewImageType( + "tar", + "root.tar.xz", + "application/x-tar", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: func(t *rhel.ImageType) rpmmd.PackageSet { return rpmmd.PackageSet{ Include: []string{"policycoreutils", "selinux-policy-targeted"}, Exclude: []string{"rng-tools"}, } }, }, - image: tarImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "archive"}, - exports: []string{"archive"}, - } + rhel.TarImage, + []string{"build"}, + []string{"os", "archive"}, + []string{"archive"}, + ) +} - imageInstaller = imageType{ - name: "image-installer", - filename: "installer.iso", - mimeType: "application/x-iso9660-image", - packageSets: map[string]packageSetFunc{ - osPkgsKey: bareMetalPackageSet, - installerPkgsKey: anacondaPackageSet, +func mkImageInstallerImgType() *rhel.ImageType { + it := rhel.NewImageType( + "image-installer", + "installer.iso", + "application/x-iso9660-image", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: bareMetalPackageSet, + rhel.InstallerPkgsKey: anacondaPackageSet, }, - rpmOstree: false, - bootISO: true, - bootable: true, - image: imageInstallerImage, - isoLabel: distroISOLabelFunc, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"anaconda-tree", "rootfs-image", "efiboot-tree", "os", "bootiso-tree", "bootiso"}, - exports: []string{"bootiso"}, - } -) + rhel.ImageInstallerImage, + []string{"build"}, + []string{"anaconda-tree", "rootfs-image", "efiboot-tree", "os", "bootiso-tree", "bootiso"}, + []string{"bootiso"}, + ) + + it.BootISO = true + it.Bootable = true + it.ISOLabelFn = distroISOLabelFunc + + return it +} + +// PACKAGE SETS -func bareMetalPackageSet(t *imageType) rpmmd.PackageSet { +func bareMetalPackageSet(t *rhel.ImageType) rpmmd.PackageSet { ps := rpmmd.PackageSet{ Include: []string{ "@core", @@ -91,12 +98,12 @@ func bareMetalPackageSet(t *imageType) rpmmd.PackageSet { }, }.Append(distroBuildPackageSet(t)) - if common.VersionLessThan(t.arch.distro.osVersion, "10.0") { + if common.VersionLessThan(t.Arch().Distro().OsVersion(), "10.0") { ps.Include = append(ps.Include, "authselect-compat") } // Ensure to not pull in subscription-manager on non-RHEL distro - if t.arch.distro.isRHEL() { + if t.IsRHEL() { ps = ps.Append(rpmmd.PackageSet{ Include: []string{ "subscription-manager-cockpit", @@ -107,7 +114,7 @@ func bareMetalPackageSet(t *imageType) rpmmd.PackageSet { return ps } -func installerPackageSet(t *imageType) rpmmd.PackageSet { +func installerPackageSet(t *rhel.ImageType) rpmmd.PackageSet { ps := rpmmd.PackageSet{ Include: []string{ "anaconda-dracut", @@ -157,7 +164,7 @@ func installerPackageSet(t *imageType) rpmmd.PackageSet { }, }) - switch t.arch.Name() { + switch t.Arch().Name() { case arch.ARCH_X86_64.String(): ps = ps.Append(rpmmd.PackageSet{ Include: []string{ @@ -169,7 +176,7 @@ func installerPackageSet(t *imageType) rpmmd.PackageSet { return ps } -func anacondaPackageSet(t *imageType) rpmmd.PackageSet { +func anacondaPackageSet(t *rhel.ImageType) rpmmd.PackageSet { // common installer packages ps := installerPackageSet(t) @@ -315,7 +322,7 @@ func anacondaPackageSet(t *imageType) rpmmd.PackageSet { ps = ps.Append(anacondaBootPackageSet(t)) - switch t.arch.Name() { + switch t.Arch().Name() { case arch.ARCH_X86_64.String(): ps = ps.Append(rpmmd.PackageSet{ Include: []string{ @@ -334,7 +341,7 @@ func anacondaPackageSet(t *imageType) rpmmd.PackageSet { }) default: - panic(fmt.Sprintf("unsupported arch: %s", t.arch.Name())) + panic(fmt.Sprintf("unsupported arch: %s", t.Arch().Name())) } return ps diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/distro.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/distro.go new file mode 100644 index 00000000000..35467cb57d6 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/distro.go @@ -0,0 +1,401 @@ +package rhel9 + +import ( + "fmt" + "strings" + + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/arch" + "github.com/osbuild/images/pkg/customizations/oscap" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" + "github.com/osbuild/images/pkg/platform" +) + +var ( + // rhel9 & cs9 share the same list + // of allowed profiles so a single + // allow list can be used + oscapProfileAllowList = []oscap.Profile{ + oscap.AnssiBp28Enhanced, + oscap.AnssiBp28High, + oscap.AnssiBp28Intermediary, + oscap.AnssiBp28Minimal, + oscap.CcnAdvanced, + oscap.CcnBasic, + oscap.CcnIntermediate, + oscap.Cis, + oscap.CisServerL1, + oscap.CisWorkstationL1, + oscap.CisWorkstationL2, + oscap.Cui, + oscap.E8, + oscap.Hippa, + oscap.IsmO, + oscap.Ospp, + oscap.PciDss, + oscap.Stig, + oscap.StigGui, + } +) + +func distroISOLabelFunc(t *rhel.ImageType) string { + const RHEL_ISO_LABEL = "RHEL-%s-%s-0-BaseOS-%s" + const CS_ISO_LABEL = "CentOS-Stream-%s-BaseOS-%s" + + if t.IsRHEL() { + osVer := strings.Split(t.Arch().Distro().OsVersion(), ".") + return fmt.Sprintf(RHEL_ISO_LABEL, osVer[0], osVer[1], t.Arch().Name()) + } else { + return fmt.Sprintf(CS_ISO_LABEL, t.Arch().Distro().Releasever(), t.Arch().Name()) + } +} + +func newDistro(name string, major, minor int) *rhel.Distribution { + rd, err := rhel.NewDistribution(name, major, minor) + if err != nil { + panic(err) + } + rd.CheckOptions = checkOptions + + // Architecture definitions + x86_64 := rhel.NewArchitecture(rd, arch.ARCH_X86_64) + aarch64 := rhel.NewArchitecture(rd, arch.ARCH_AARCH64) + ppc64le := rhel.NewArchitecture(rd, arch.ARCH_PPC64LE) + s390x := rhel.NewArchitecture(rd, arch.ARCH_S390X) + + x86_64.AddImageTypes( + &platform.X86{ + BIOS: true, + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_QCOW2, + QCOW2Compat: "1.1", + }, + }, + mkQcow2ImgType(rd), + mkOCIImgType(rd), + ) + + x86_64.AddImageTypes( + &platform.X86{ + BIOS: true, + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_QCOW2, + }, + }, + mkOpenstackImgType(), + ) + + x86_64.AddImageTypes( + &platform.X86{ + BIOS: true, + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_VMDK, + }, + }, + mkVMDKImgType(), + ) + + x86_64.AddImageTypes( + &platform.X86{ + BIOS: true, + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_OVA, + }, + }, + mkOVAImgType(), + ) + + x86_64.AddImageTypes( + &platform.X86{}, + mkTarImgType(), + mkWSLImgType(), + ) + + aarch64.AddImageTypes( + &platform.Aarch64{ + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_QCOW2, + }, + }, + mkOpenstackImgType(), + ) + + aarch64.AddImageTypes( + &platform.Aarch64{}, + mkTarImgType(), + mkWSLImgType(), + ) + + aarch64.AddImageTypes( + &platform.Aarch64{ + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_QCOW2, + QCOW2Compat: "1.1", + }, + }, + mkQcow2ImgType(rd), + ) + + ppc64le.AddImageTypes( + &platform.PPC64LE{ + BIOS: true, + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_QCOW2, + QCOW2Compat: "1.1", + }, + }, + mkQcow2ImgType(rd), + ) + ppc64le.AddImageTypes( + &platform.PPC64LE{}, + mkTarImgType(), + ) + + s390x.AddImageTypes( + &platform.S390X{ + Zipl: true, + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_QCOW2, + QCOW2Compat: "1.1", + }, + }, + mkQcow2ImgType(rd), + ) + s390x.AddImageTypes( + &platform.S390X{}, + mkTarImgType(), + ) + + ec2X86Platform := &platform.X86{ + BIOS: true, + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_RAW, + }, + } + x86_64.AddImageTypes( + ec2X86Platform, + mkAMIImgTypeX86_64(), + ) + + aarch64.AddImageTypes( + &platform.Aarch64{ + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_RAW, + }, + }, + mkAMIImgTypeAarch64(), + ) + + azureX64Platform := &platform.X86{ + BIOS: true, + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_VHD, + }, + } + + azureAarch64Platform := &platform.Aarch64{ + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_VHD, + }, + } + + if rd.IsRHEL() { // RHEL-only (non-CentOS) image types + x86_64.AddImageTypes(azureX64Platform, mkAzureByosImgType(rd)) + aarch64.AddImageTypes(azureAarch64Platform, mkAzureByosImgType(rd)) + } else { + x86_64.AddImageTypes(azureX64Platform, mkAzureImgType()) + aarch64.AddImageTypes(azureAarch64Platform, mkAzureImgType()) + } + + gceX86Platform := &platform.X86{ + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_GCE, + }, + } + x86_64.AddImageTypes( + gceX86Platform, + mkGCEImageType(), + ) + + x86_64.AddImageTypes( + &platform.X86{ + BasePlatform: platform.BasePlatform{ + FirmwarePackages: []string{ + "microcode_ctl", // ?? + "iwl1000-firmware", + "iwl100-firmware", + "iwl105-firmware", + "iwl135-firmware", + "iwl2000-firmware", + "iwl2030-firmware", + "iwl3160-firmware", + "iwl5000-firmware", + "iwl5150-firmware", + "iwl6050-firmware", + }, + }, + BIOS: true, + UEFIVendor: rd.Vendor(), + }, + mkEdgeOCIImgType(), + mkEdgeCommitImgType(), + mkEdgeInstallerImgType(), + mkEdgeRawImgType(), + mkImageInstallerImgType(), + mkEdgeAMIImgType(), + ) + + x86_64.AddImageTypes( + &platform.X86{ + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_VMDK, + }, + BIOS: true, + UEFIVendor: rd.Vendor(), + }, + mkEdgeVsphereImgType(), + ) + + x86_64.AddImageTypes( + &platform.X86{ + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_RAW, + }, + BIOS: false, + UEFIVendor: rd.Vendor(), + }, + mkEdgeSimplifiedInstallerImgType(), + mkMinimalrawImgType(), + ) + + aarch64.AddImageTypes( + &platform.Aarch64{ + BasePlatform: platform.BasePlatform{}, + UEFIVendor: rd.Vendor(), + }, + mkEdgeOCIImgType(), + mkEdgeCommitImgType(), + mkEdgeInstallerImgType(), + mkEdgeSimplifiedInstallerImgType(), + mkImageInstallerImgType(), + mkEdgeAMIImgType(), + ) + + aarch64.AddImageTypes( + &platform.Aarch64{ + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_VMDK, + }, + UEFIVendor: rd.Vendor(), + }, + mkEdgeVsphereImgType(), + ) + + aarch64.AddImageTypes( + &platform.Aarch64{ + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_RAW, + }, + UEFIVendor: rd.Vendor(), + }, + mkEdgeRawImgType(), + mkMinimalrawImgType(), + ) + + if rd.IsRHEL() { // RHEL-only (non-CentOS) image types + x86_64.AddImageTypes(azureX64Platform, mkAzureRhuiImgType(), mkAzureByosImgType(rd)) + aarch64.AddImageTypes(azureAarch64Platform, mkAzureRhuiImgType(), mkAzureByosImgType(rd)) + + x86_64.AddImageTypes(azureX64Platform, mkAzureSapRhuiImgType(rd)) + + // keep the RHEL EC2 x86_64 images before 9.3 BIOS-only for backward compatibility + if common.VersionLessThan(rd.OsVersion(), "9.3") { + ec2X86Platform = &platform.X86{ + BIOS: true, + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_RAW, + }, + } + } + + // add ec2 image types to RHEL distro only + x86_64.AddImageTypes(ec2X86Platform, mkEc2ImgTypeX86_64(rd.OsVersion(), rd.IsRHEL()), mkEc2HaImgTypeX86_64(rd.OsVersion(), rd.IsRHEL()), mkEC2SapImgTypeX86_64(rd.OsVersion(), rd.IsRHEL())) + + aarch64.AddImageTypes( + &platform.Aarch64{ + UEFIVendor: rd.Vendor(), + BasePlatform: platform.BasePlatform{ + ImageFormat: platform.FORMAT_RAW, + }, + }, + mkEC2ImgTypeAarch64(rd.OsVersion(), rd.IsRHEL()), + ) + + // add GCE RHUI image to RHEL only + x86_64.AddImageTypes(gceX86Platform, mkGCERHUIImageType()) + } + + rd.AddArches(x86_64, aarch64, ppc64le, s390x) + return rd +} + +func ParseID(idStr string) (*distro.ID, error) { + id, err := distro.ParseID(idStr) + if err != nil { + return nil, err + } + + if id.Name != "rhel" && id.Name != "centos" { + return nil, fmt.Errorf("invalid distro name: %s", id.Name) + } + + // Backward compatibility layer for "rhel-93" or "rhel-910" + if id.Name == "rhel" && id.MinorVersion == -1 { + if id.MajorVersion/10 == 9 { + // handle single digit minor version + id.MinorVersion = id.MajorVersion % 10 + id.MajorVersion = 9 + } else if id.MajorVersion/100 == 9 { + // handle two digit minor version + id.MinorVersion = id.MajorVersion % 100 + id.MajorVersion = 9 + } + } + + if id.MajorVersion != 9 { + return nil, fmt.Errorf("invalid distro major version: %d", id.MajorVersion) + } + + // CentOS does not use minor version + if id.Name == "centos" && id.MinorVersion != -1 { + return nil, fmt.Errorf("centos does not use minor version, but got: %d", id.MinorVersion) + } + + // RHEL uses minor version + if id.Name == "rhel" && id.MinorVersion == -1 { + return nil, fmt.Errorf("rhel requires minor version, but got: %d", id.MinorVersion) + } + + return id, nil +} + +func DistroFactory(idStr string) distro.Distro { + id, err := ParseID(idStr) + if err != nil { + return nil + } + + return newDistro(id.Name, 9, id.MinorVersion) +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel9/edge.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/edge.go similarity index 61% rename from vendor/github.com/osbuild/images/pkg/distro/rhel9/edge.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/edge.go index 40fd8248bf6..acb087dc456 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/rhel9/edge.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/edge.go @@ -9,112 +9,122 @@ import ( "github.com/osbuild/images/pkg/customizations/fsnode" "github.com/osbuild/images/pkg/disk" "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" "github.com/osbuild/images/pkg/osbuild" "github.com/osbuild/images/pkg/rpmmd" ) -var ( - // Image Definitions - edgeCommitImgType = imageType{ - name: "edge-commit", - nameAliases: []string{"rhel-edge-commit"}, - filename: "commit.tar", - mimeType: "application/x-tar", - packageSets: map[string]packageSetFunc{ - osPkgsKey: edgeCommitPackageSet, - }, - defaultImageConfig: &distro.ImageConfig{ - EnabledServices: edgeServices, - SystemdUnit: systemdUnits, +func mkEdgeCommitImgType() *rhel.ImageType { + it := rhel.NewImageType( + "edge-commit", + "commit.tar", + "application/x-tar", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: edgeCommitPackageSet, }, - rpmOstree: true, - image: edgeCommitImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "ostree-commit", "commit-archive"}, - exports: []string{"commit-archive"}, + rhel.EdgeCommitImage, + []string{"build"}, + []string{"os", "ostree-commit", "commit-archive"}, + []string{"commit-archive"}, + ) + + it.NameAliases = []string{"rhel-edge-commit"} + it.DefaultImageConfig = &distro.ImageConfig{ + EnabledServices: edgeServices, + SystemdUnit: systemdUnits, } + it.RPMOSTree = true - edgeOCIImgType = imageType{ - name: "edge-container", - nameAliases: []string{"rhel-edge-container"}, - filename: "container.tar", - mimeType: "application/x-tar", - packageSets: map[string]packageSetFunc{ - osPkgsKey: edgeCommitPackageSet, - containerPkgsKey: func(t *imageType) rpmmd.PackageSet { + return it +} + +func mkEdgeOCIImgType() *rhel.ImageType { + it := rhel.NewImageType( + "edge-container", + "container.tar", + "application/x-tar", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: edgeCommitPackageSet, + rhel.ContainerPkgsKey: func(t *rhel.ImageType) rpmmd.PackageSet { return rpmmd.PackageSet{ Include: []string{"nginx"}, // FIXME: this has no effect } }, }, - defaultImageConfig: &distro.ImageConfig{ - EnabledServices: edgeServices, - SystemdUnit: systemdUnits, - }, - rpmOstree: true, - bootISO: false, - image: edgeContainerImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "ostree-commit", "container-tree", "container"}, - exports: []string{"container"}, + rhel.EdgeContainerImage, + []string{"build"}, + []string{"os", "ostree-commit", "container-tree", "container"}, + []string{"container"}, + ) + + it.NameAliases = []string{"rhel-edge-container"} + it.DefaultImageConfig = &distro.ImageConfig{ + EnabledServices: edgeServices, + SystemdUnit: systemdUnits, } + it.RPMOSTree = true - edgeRawImgType = imageType{ - name: "edge-raw-image", - nameAliases: []string{"rhel-edge-raw-image"}, - filename: "image.raw.xz", - compression: "xz", - mimeType: "application/xz", - packageSets: nil, - defaultImageConfig: &distro.ImageConfig{ - Locale: common.ToPtr("en_US.UTF-8"), - }, - kernelOptions: "modprobe.blacklist=vc4", - defaultSize: 10 * common.GibiByte, - rpmOstree: true, - bootable: true, - bootISO: false, - image: edgeRawImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"ostree-deployment", "image", "xz"}, - exports: []string{"xz"}, - basePartitionTables: edgeBasePartitionTables, + return it +} + +func mkEdgeRawImgType() *rhel.ImageType { + it := rhel.NewImageType( + "edge-raw-image", + "image.raw.xz", + "application/xz", + nil, + rhel.EdgeRawImage, + []string{"build"}, + []string{"ostree-deployment", "image", "xz"}, + []string{"xz"}, + ) + + it.NameAliases = []string{"rhel-edge-raw-image"} + it.Compression = "xz" + it.DefaultImageConfig = &distro.ImageConfig{ + Locale: common.ToPtr("en_US.UTF-8"), } + it.KernelOptions = "modprobe.blacklist=vc4" + it.DefaultSize = 10 * common.GibiByte + it.RPMOSTree = true + it.Bootable = true + it.BasePartitionTables = edgeBasePartitionTables - edgeInstallerImgType = imageType{ - name: "edge-installer", - nameAliases: []string{"rhel-edge-installer"}, - filename: "installer.iso", - mimeType: "application/x-iso9660-image", - packageSets: map[string]packageSetFunc{ - // TODO: non-arch-specific package set handling for installers - // This image type requires build packages for installers and - // ostree/edge. For now we only have x86-64 installer build - // package sets defined. When we add installer build package sets - // for other architectures, this will need to be moved to the - // architecture and the merging will happen in the PackageSets() - // method like the other sets. - installerPkgsKey: edgeInstallerPackageSet, - }, - defaultImageConfig: &distro.ImageConfig{ - Locale: common.ToPtr("en_US.UTF-8"), - EnabledServices: edgeServices, + return it +} + +func mkEdgeInstallerImgType() *rhel.ImageType { + it := rhel.NewImageType( + "edge-installer", + "installer.iso", + "application/x-iso9660-image", + map[string]rhel.PackageSetFunc{ + rhel.InstallerPkgsKey: edgeInstallerPackageSet, }, - rpmOstree: true, - bootISO: true, - image: edgeInstallerImage, - isoLabel: distroISOLabelFunc, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"anaconda-tree", "rootfs-image", "efiboot-tree", "bootiso-tree", "bootiso"}, - exports: []string{"bootiso"}, + rhel.EdgeInstallerImage, + []string{"build"}, + []string{"anaconda-tree", "rootfs-image", "efiboot-tree", "bootiso-tree", "bootiso"}, + []string{"bootiso"}, + ) + + it.NameAliases = []string{"rhel-edge-installer"} + it.DefaultImageConfig = &distro.ImageConfig{ + Locale: common.ToPtr("en_US.UTF-8"), + EnabledServices: edgeServices, } + it.RPMOSTree = true + it.BootISO = true + it.ISOLabelFn = distroISOLabelFunc + + return it +} - edgeSimplifiedInstallerImgType = imageType{ - name: "edge-simplified-installer", - nameAliases: []string{"rhel-edge-simplified-installer"}, - filename: "simplified-installer.iso", - mimeType: "application/x-iso9660-image", - packageSets: map[string]packageSetFunc{ +func mkEdgeSimplifiedInstallerImgType() *rhel.ImageType { + it := rhel.NewImageType( + "edge-simplified-installer", + "simplified-installer.iso", + "application/x-iso9660-image", + map[string]rhel.PackageSetFunc{ // TODO: non-arch-specific package set handling for installers // This image type requires build packages for installers and // ostree/edge. For now we only have x86-64 installer build @@ -122,91 +132,108 @@ var ( // for other architectures, this will need to be moved to the // architecture and the merging will happen in the PackageSets() // method like the other sets. - installerPkgsKey: edgeSimplifiedInstallerPackageSet, + rhel.InstallerPkgsKey: edgeSimplifiedInstallerPackageSet, }, - defaultImageConfig: &distro.ImageConfig{ - EnabledServices: edgeServices, - }, - defaultSize: 10 * common.GibiByte, - rpmOstree: true, - bootable: true, - bootISO: true, - image: edgeSimplifiedInstallerImage, - isoLabel: distroISOLabelFunc, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"ostree-deployment", "image", "xz", "coi-tree", "efiboot-tree", "bootiso-tree", "bootiso"}, - exports: []string{"bootiso"}, - basePartitionTables: edgeBasePartitionTables, + rhel.EdgeSimplifiedInstallerImage, + []string{"build"}, + []string{"ostree-deployment", "image", "xz", "coi-tree", "efiboot-tree", "bootiso-tree", "bootiso"}, + []string{"bootiso"}, + ) + + it.NameAliases = []string{"rhel-edge-simplified-installer"} + it.DefaultImageConfig = &distro.ImageConfig{ + EnabledServices: edgeServices, } + it.DefaultSize = 10 * common.GibiByte + it.RPMOSTree = true + it.BootISO = true + it.BootISO = true + it.ISOLabelFn = distroISOLabelFunc + it.BasePartitionTables = edgeBasePartitionTables + + return it +} - edgeAMIImgType = imageType{ - name: "edge-ami", - filename: "image.raw", - mimeType: "application/octet-stream", - packageSets: nil, - - defaultImageConfig: &distro.ImageConfig{ - Locale: common.ToPtr("en_US.UTF-8"), - }, - kernelOptions: amiKernelOptions + " modprobe.blacklist=vc4", - defaultSize: 10 * common.GibiByte, - rpmOstree: true, - bootable: true, - bootISO: false, - image: edgeRawImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"ostree-deployment", "image"}, - exports: []string{"image"}, - basePartitionTables: edgeBasePartitionTables, - environment: &environment.EC2{}, +func mkEdgeAMIImgType() *rhel.ImageType { + it := rhel.NewImageType( + "edge-ami", + "image.raw", + "application/octet-stream", + nil, + rhel.EdgeRawImage, + []string{"build"}, + []string{"ostree-deployment", "image"}, + []string{"image"}, + ) + + it.DefaultImageConfig = &distro.ImageConfig{ + Locale: common.ToPtr("en_US.UTF-8"), } + it.KernelOptions = amiKernelOptions + " modprobe.blacklist=vc4" + it.DefaultSize = 10 * common.GibiByte + it.RPMOSTree = true + it.Bootable = true + it.BasePartitionTables = edgeBasePartitionTables + it.Environment = &environment.EC2{} + + return it +} - edgeVsphereImgType = imageType{ - name: "edge-vsphere", - filename: "image.vmdk", - mimeType: "application/x-vmdk", - packageSets: nil, - defaultImageConfig: &distro.ImageConfig{ - Locale: common.ToPtr("en_US.UTF-8"), - }, - kernelOptions: "modprobe.blacklist=vc4", - defaultSize: 10 * common.GibiByte, - rpmOstree: true, - bootable: true, - bootISO: false, - image: edgeRawImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"ostree-deployment", "image", "vmdk"}, - exports: []string{"vmdk"}, - basePartitionTables: edgeBasePartitionTables, +func mkEdgeVsphereImgType() *rhel.ImageType { + it := rhel.NewImageType( + "edge-vsphere", + "image.vmdk", + "application/x-vmdk", + nil, + rhel.EdgeRawImage, + []string{"build"}, + []string{"ostree-deployment", "image", "vmdk"}, + []string{"vmdk"}, + ) + + it.DefaultImageConfig = &distro.ImageConfig{ + Locale: common.ToPtr("en_US.UTF-8"), } + it.KernelOptions = "modprobe.blacklist=vc4" + it.DefaultSize = 10 * common.GibiByte + it.RPMOSTree = true + it.Bootable = true + it.BasePartitionTables = edgeBasePartitionTables - minimalrawImgType = imageType{ - name: "minimal-raw", - filename: "disk.raw.xz", - compression: "xz", - mimeType: "application/xz", - packageSets: map[string]packageSetFunc{ - osPkgsKey: minimalrpmPackageSet, - }, - defaultImageConfig: &distro.ImageConfig{ - EnabledServices: minimalrawServices, - SystemdUnit: systemdUnits, - // NOTE: temporary workaround for a bug in initial-setup that - // requires a kickstart file in the root directory. - Files: []*fsnode.File{initialSetupKickstart()}, + return it +} + +func mkMinimalrawImgType() *rhel.ImageType { + it := rhel.NewImageType( + "minimal-raw", + "disk.raw.xz", + "application/xz", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: minimalrpmPackageSet, }, - rpmOstree: false, - kernelOptions: "ro", - bootable: true, - defaultSize: 2 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "xz"}, - exports: []string{"xz"}, - basePartitionTables: minimalrawPartitionTables, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "xz"}, + []string{"xz"}, + ) + + it.Compression = "xz" + it.DefaultImageConfig = &distro.ImageConfig{ + EnabledServices: minimalrawServices, + SystemdUnit: systemdUnits, + // NOTE: temporary workaround for a bug in initial-setup that + // requires a kickstart file in the root directory. + Files: []*fsnode.File{initialSetupKickstart()}, } + it.KernelOptions = "ro" + it.DefaultSize = 2 * common.GibiByte + it.Bootable = true + it.BasePartitionTables = minimalrawPartitionTables + return it +} + +var ( // Shared Services edgeServices = []string{ // TODO(runcom): move fdo-client-linuxapp.service to presets? @@ -230,16 +257,26 @@ var ( } ) +// initialSetupKickstart returns the File configuration for a kickstart file +// that's required to enable initial-setup to run on first boot. +func initialSetupKickstart() *fsnode.File { + file, err := fsnode.NewFile("/root/anaconda-ks.cfg", nil, "root", "root", []byte("# Run initial-setup on first boot\n# Created by osbuild\nfirstboot --reconfig\nlang en_US.UTF-8\n")) + if err != nil { + panic(err) + } + return file +} + // Partition tables -func minimalrawPartitionTables(t *imageType) (disk.PartitionTable, bool) { +func minimalrawPartitionTables(t *rhel.ImageType) (disk.PartitionTable, bool) { // RHEL >= 9.3 needs to have a bigger /boot, see RHEL-7999 bootSize := uint64(600) * common.MebiByte - if common.VersionLessThan(t.arch.distro.osVersion, "9.3") && t.arch.distro.isRHEL() { + if common.VersionLessThan(t.Arch().Distro().OsVersion(), "9.3") && t.IsRHEL() { bootSize = 500 * common.MebiByte } - switch t.platform.GetArch() { - case arch.ARCH_X86_64: + switch t.Arch().Name() { + case arch.ARCH_X86_64.String(): return disk.PartitionTable{ UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", Type: "gpt", @@ -287,7 +324,7 @@ func minimalrawPartitionTables(t *imageType) (disk.PartitionTable, bool) { }, }, }, true - case arch.ARCH_AARCH64: + case arch.ARCH_AARCH64.String(): return disk.PartitionTable{ UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", Type: "gpt", @@ -340,9 +377,9 @@ func minimalrawPartitionTables(t *imageType) (disk.PartitionTable, bool) { } } -func edgeBasePartitionTables(t *imageType) (disk.PartitionTable, bool) { - switch t.platform.GetArch() { - case arch.ARCH_X86_64: +func edgeBasePartitionTables(t *rhel.ImageType) (disk.PartitionTable, bool) { + switch t.Arch().Name() { + case arch.ARCH_X86_64.String(): return disk.PartitionTable{ UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", Type: "gpt", @@ -419,7 +456,7 @@ func edgeBasePartitionTables(t *imageType) (disk.PartitionTable, bool) { }, }, }, true - case arch.ARCH_AARCH64: + case arch.ARCH_AARCH64.String(): return disk.PartitionTable{ UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", Type: "gpt", @@ -499,7 +536,7 @@ func edgeBasePartitionTables(t *imageType) (disk.PartitionTable, bool) { // Package Sets // edge commit OS package set -func edgeCommitPackageSet(t *imageType) rpmmd.PackageSet { +func edgeCommitPackageSet(t *rhel.ImageType) rpmmd.PackageSet { ps := rpmmd.PackageSet{ Include: []string{ "redhat-release", @@ -583,7 +620,7 @@ func edgeCommitPackageSet(t *imageType) rpmmd.PackageSet { }, } - switch t.arch.Name() { + switch t.Arch().Name() { case arch.ARCH_X86_64.String(): ps = ps.Append(x8664EdgeCommitPackageSet(t)) @@ -591,7 +628,7 @@ func edgeCommitPackageSet(t *imageType) rpmmd.PackageSet { ps = ps.Append(aarch64EdgeCommitPackageSet(t)) } - if common.VersionGreaterThanOrEqual(t.arch.distro.osVersion, "9.2") || !t.arch.distro.isRHEL() { + if common.VersionGreaterThanOrEqual(t.Arch().Distro().OsVersion(), "9.2") || !t.IsRHEL() { ps.Include = append(ps.Include, "ignition", "ignition-edge", "ssh-key-dir") } @@ -599,7 +636,7 @@ func edgeCommitPackageSet(t *imageType) rpmmd.PackageSet { } -func x8664EdgeCommitPackageSet(t *imageType) rpmmd.PackageSet { +func x8664EdgeCommitPackageSet(t *rhel.ImageType) rpmmd.PackageSet { return rpmmd.PackageSet{ Include: []string{ "grub2", @@ -622,7 +659,7 @@ func x8664EdgeCommitPackageSet(t *imageType) rpmmd.PackageSet { } } -func aarch64EdgeCommitPackageSet(t *imageType) rpmmd.PackageSet { +func aarch64EdgeCommitPackageSet(t *rhel.ImageType) rpmmd.PackageSet { return rpmmd.PackageSet{ Include: []string{ "grub2-efi-aa64", @@ -633,11 +670,11 @@ func aarch64EdgeCommitPackageSet(t *imageType) rpmmd.PackageSet { } } -func edgeInstallerPackageSet(t *imageType) rpmmd.PackageSet { +func edgeInstallerPackageSet(t *rhel.ImageType) rpmmd.PackageSet { return anacondaPackageSet(t) } -func edgeSimplifiedInstallerPackageSet(t *imageType) rpmmd.PackageSet { +func edgeSimplifiedInstallerPackageSet(t *rhel.ImageType) rpmmd.PackageSet { // common installer packages ps := installerPackageSet(t) @@ -682,7 +719,7 @@ func edgeSimplifiedInstallerPackageSet(t *imageType) rpmmd.PackageSet { }, }) - switch t.arch.Name() { + switch t.Arch().Name() { case arch.ARCH_X86_64.String(): ps = ps.Append(x8664EdgeCommitPackageSet(t)) @@ -690,7 +727,7 @@ func edgeSimplifiedInstallerPackageSet(t *imageType) rpmmd.PackageSet { ps = ps.Append(aarch64EdgeCommitPackageSet(t)) default: - panic(fmt.Sprintf("unsupported arch: %s", t.arch.Name())) + panic(fmt.Sprintf("unsupported arch: %s", t.Arch().Name())) } return ps diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel9/gce.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/gce.go similarity index 78% rename from vendor/github.com/osbuild/images/pkg/distro/rhel9/gce.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/gce.go index 324d3df7477..6a8ad82a0bf 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/rhel9/gce.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/gce.go @@ -3,6 +3,7 @@ package rhel9 import ( "github.com/osbuild/images/internal/common" "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" "github.com/osbuild/images/pkg/osbuild" "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/images/pkg/subscription" @@ -10,55 +11,53 @@ import ( const gceKernelOptions = "net.ifnames=0 biosdevname=0 scsi_mod.use_blk_mq=Y console=ttyS0,38400n8d" -var ( - gceImgType = imageType{ - name: "gce", - filename: "image.tar.gz", - mimeType: "application/gzip", - packageSets: map[string]packageSetFunc{ - osPkgsKey: gcePackageSet, +func mkGCEImageType() *rhel.ImageType { + it := rhel.NewImageType( + "gce", + "image.tar.gz", + "application/gzip", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: gcePackageSet, }, - kernelOptions: gceKernelOptions, - bootable: true, - defaultSize: 20 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "archive"}, - exports: []string{"archive"}, - // TODO: the base partition table still contains the BIOS boot partition, but the image is UEFI-only - basePartitionTables: defaultBasePartitionTables, - } - - gceRhuiImgType = imageType{ - name: "gce-rhui", - filename: "image.tar.gz", - mimeType: "application/gzip", - packageSets: map[string]packageSetFunc{ - osPkgsKey: gceRhuiPackageSet, - }, - kernelOptions: gceKernelOptions, - bootable: true, - defaultSize: 20 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "archive"}, - exports: []string{"archive"}, - // TODO: the base partition table still contains the BIOS boot partition, but the image is UEFI-only - basePartitionTables: defaultBasePartitionTables, - } -) + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "archive"}, + []string{"archive"}, + ) -func mkGCEImageType() imageType { - it := gceImgType // The configuration for non-RHUI images does not touch the RHSM configuration at all. // https://issues.redhat.com/browse/COMPOSER-2157 - it.defaultImageConfig = baseGCEImageConfig() + it.DefaultImageConfig = baseGCEImageConfig() + it.KernelOptions = gceKernelOptions + it.DefaultSize = 20 * common.GibiByte + it.Bootable = true + // TODO: the base partition table still contains the BIOS boot partition, but the image is UEFI-only + it.BasePartitionTables = defaultBasePartitionTables + return it } -func mkGCERHUIImageType() imageType { - it := gceRhuiImgType - it.defaultImageConfig = defaultGceRhuiImageConfig() +func mkGCERHUIImageType() *rhel.ImageType { + it := rhel.NewImageType( + "gce-rhui", + "image.tar.gz", + "application/gzip", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: gceRhuiPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "archive"}, + []string{"archive"}, + ) + + it.DefaultImageConfig = defaultGceRhuiImageConfig() + it.KernelOptions = gceKernelOptions + it.DefaultSize = 20 * common.GibiByte + it.Bootable = true + // TODO: the base partition table still contains the BIOS boot partition, but the image is UEFI-only + it.BasePartitionTables = defaultBasePartitionTables + return it } @@ -186,7 +185,7 @@ func defaultGceRhuiImageConfig() *distro.ImageConfig { return ic.InheritFrom(baseGCEImageConfig()) } -func gceCommonPackageSet(t *imageType) rpmmd.PackageSet { +func gceCommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { ps := rpmmd.PackageSet{ Include: []string{ "@core", @@ -268,12 +267,12 @@ func gceCommonPackageSet(t *imageType) rpmmd.PackageSet { } // GCE BYOS image -func gcePackageSet(t *imageType) rpmmd.PackageSet { +func gcePackageSet(t *rhel.ImageType) rpmmd.PackageSet { return gceCommonPackageSet(t) } // GCE RHUI image -func gceRhuiPackageSet(t *imageType) rpmmd.PackageSet { +func gceRhuiPackageSet(t *rhel.ImageType) rpmmd.PackageSet { return rpmmd.PackageSet{ Include: []string{ "google-rhui-client-rhel9", diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/options.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/options.go new file mode 100644 index 00000000000..029edb34989 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/options.go @@ -0,0 +1,192 @@ +package rhel9 + +import ( + "fmt" + "log" + "strings" + + "golang.org/x/exp/slices" + + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/customizations/oscap" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" + "github.com/osbuild/images/pkg/policies" +) + +// checkOptions checks the validity and compatibility of options and customizations for the image type. +// Returns ([]string, error) where []string, if non-nil, will hold any generated warnings (e.g. deprecation notices). +func checkOptions(t *rhel.ImageType, bp *blueprint.Blueprint, options distro.ImageOptions) ([]string, error) { + + customizations := bp.Customizations + + // holds warnings (e.g. deprecation notices) + var warnings []string + + // we do not support embedding containers on ostree-derived images, only on commits themselves + if len(bp.Containers) > 0 && t.RPMOSTree && (t.Name() != "edge-commit" && t.Name() != "edge-container") { + return warnings, fmt.Errorf("embedding containers is not supported for %s on %s", t.Name(), t.Arch().Distro().Name()) + } + + if options.OSTree != nil { + if err := options.OSTree.Validate(); err != nil { + return nil, err + } + } + + if t.BootISO && t.RPMOSTree { + // ostree-based ISOs require a URL from which to pull a payload commit + if options.OSTree == nil || options.OSTree.URL == "" { + return nil, fmt.Errorf("boot ISO image type %q requires specifying a URL from which to retrieve the OSTree commit", t.Name()) + } + + if t.Name() == "edge-simplified-installer" { + allowed := []string{"InstallationDevice", "FDO", "Ignition", "Kernel", "User", "Group", "FIPS", "Filesystem"} + if err := customizations.CheckAllowed(allowed...); err != nil { + return warnings, fmt.Errorf(distro.UnsupportedCustomizationError, t.Name(), strings.Join(allowed, ", ")) + } + if customizations.GetInstallationDevice() == "" { + return warnings, fmt.Errorf("boot ISO image type %q requires specifying an installation device to install to", t.Name()) + } + + // FDO is optional, but when specified has some restrictions + if customizations.GetFDO() != nil { + if customizations.GetFDO().ManufacturingServerURL == "" { + return warnings, fmt.Errorf("boot ISO image type %q requires specifying FDO.ManufacturingServerURL configuration to install to when using FDO", t.Name()) + } + var diunSet int + if customizations.GetFDO().DiunPubKeyHash != "" { + diunSet++ + } + if customizations.GetFDO().DiunPubKeyInsecure != "" { + diunSet++ + } + if customizations.GetFDO().DiunPubKeyRootCerts != "" { + diunSet++ + } + if diunSet != 1 { + return warnings, fmt.Errorf("boot ISO image type %q requires specifying one of [FDO.DiunPubKeyHash,FDO.DiunPubKeyInsecure,FDO.DiunPubKeyRootCerts] configuration to install to when using FDO", t.Name()) + } + } + + // ignition is optional, we might be using FDO + if customizations.GetIgnition() != nil { + if customizations.GetIgnition().Embedded != nil && customizations.GetIgnition().FirstBoot != nil { + return warnings, fmt.Errorf("both ignition embedded and firstboot configurations found") + } + if customizations.GetIgnition().FirstBoot != nil && customizations.GetIgnition().FirstBoot.ProvisioningURL == "" { + return warnings, fmt.Errorf("ignition.firstboot requires a provisioning url") + } + } + } else if t.Name() == "edge-installer" { + allowed := []string{"User", "Group", "FIPS", "Installer", "Timezone", "Locale"} + if err := customizations.CheckAllowed(allowed...); err != nil { + return warnings, fmt.Errorf(distro.UnsupportedCustomizationError, t.Name(), strings.Join(allowed, ", ")) + } + } + } + + if t.Name() == "edge-raw-image" || t.Name() == "edge-ami" || t.Name() == "edge-vsphere" { + // ostree-based bootable images require a URL from which to pull a payload commit + if options.OSTree == nil || options.OSTree.URL == "" { + return warnings, fmt.Errorf("%q images require specifying a URL from which to retrieve the OSTree commit", t.Name()) + } + + allowed := []string{"Ignition", "Kernel", "User", "Group", "FIPS", "Filesystem"} + if err := customizations.CheckAllowed(allowed...); err != nil { + return warnings, fmt.Errorf(distro.UnsupportedCustomizationError, t.Name(), strings.Join(allowed, ", ")) + } + // TODO: consider additional checks, such as those in "edge-simplified-installer" + } + + // warn that user & group customizations on edge-commit, edge-container are deprecated + // TODO(edge): directly error if these options are provided when rhel-9.5's time arrives + if t.Name() == "edge-commit" || t.Name() == "edge-container" { + if customizations.GetUsers() != nil { + w := fmt.Sprintf("Please note that user customizations on %q image type are deprecated and will be removed in the near future\n", t.Name()) + log.Print(w) + warnings = append(warnings, w) + } + if customizations.GetGroups() != nil { + w := fmt.Sprintf("Please note that group customizations on %q image type are deprecated and will be removed in the near future\n", t.Name()) + log.Print(w) + warnings = append(warnings, w) + } + } + + if kernelOpts := customizations.GetKernel(); kernelOpts.Append != "" && t.RPMOSTree && t.Name() != "edge-raw-image" && t.Name() != "edge-simplified-installer" { + return warnings, fmt.Errorf("kernel boot parameter customizations are not supported for ostree types") + } + + mountpoints := customizations.GetFilesystems() + + if mountpoints != nil && t.RPMOSTree && (t.Name() == "edge-container" || t.Name() == "edge-commit") { + return warnings, fmt.Errorf("Custom mountpoints are not supported for ostree types") + } else if mountpoints != nil && t.RPMOSTree && !(t.Name() == "edge-container" || t.Name() == "edge-commit") { + //customization allowed for edge-raw-image,edge-ami,edge-vsphere,edge-simplified-installer + err := blueprint.CheckMountpointsPolicy(mountpoints, policies.OstreeMountpointPolicies) + if err != nil { + return warnings, err + } + } + + err := blueprint.CheckMountpointsPolicy(mountpoints, policies.MountpointPolicies) + if err != nil { + return warnings, err + } + + if osc := customizations.GetOpenSCAP(); osc != nil { + if t.Arch().Distro().OsVersion() == "9.0" { + return warnings, fmt.Errorf(fmt.Sprintf("OpenSCAP unsupported os version: %s", t.Arch().Distro().OsVersion())) + } + if !oscap.IsProfileAllowed(osc.ProfileID, oscapProfileAllowList) { + return warnings, fmt.Errorf(fmt.Sprintf("OpenSCAP unsupported profile: %s", osc.ProfileID)) + } + if t.RPMOSTree { + return warnings, fmt.Errorf("OpenSCAP customizations are not supported for ostree types") + } + if osc.ProfileID == "" { + return warnings, fmt.Errorf("OpenSCAP profile cannot be empty") + } + } + + // Check Directory/File Customizations are valid + dc := customizations.GetDirectories() + fc := customizations.GetFiles() + + err = blueprint.ValidateDirFileCustomizations(dc, fc) + if err != nil { + return warnings, err + } + err = blueprint.CheckDirectoryCustomizationsPolicy(dc, policies.CustomDirectoriesPolicies) + if err != nil { + return warnings, err + } + + err = blueprint.CheckFileCustomizationsPolicy(fc, policies.CustomFilesPolicies) + if err != nil { + return warnings, err + } + + // check if repository customizations are valid + _, err = customizations.GetRepositories() + if err != nil { + return warnings, err + } + + if customizations.GetFIPS() && !common.IsBuildHostFIPSEnabled() { + w := fmt.Sprintln(common.FIPSEnabledImageWarning) + log.Print(w) + warnings = append(warnings, w) + } + + if customizations.GetInstaller() != nil { + // only supported by the Anaconda installer + if slices.Index([]string{"image-installer", "edge-installer", "live-installer"}, t.Name()) == -1 { + return warnings, fmt.Errorf("installer customizations are not supported for %q", t.Name()) + } + } + + return warnings, nil +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel9/package_sets.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/package_sets.go similarity index 79% rename from vendor/github.com/osbuild/images/pkg/distro/rhel9/package_sets.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/package_sets.go index e7ad37a385a..0faed584d48 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/rhel9/package_sets.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/package_sets.go @@ -6,13 +6,14 @@ import ( "fmt" "github.com/osbuild/images/pkg/arch" + "github.com/osbuild/images/pkg/distro/rhel" "github.com/osbuild/images/pkg/rpmmd" ) // BUILD PACKAGE SETS // distro-wide build package set -func distroBuildPackageSet(t *imageType) rpmmd.PackageSet { +func distroBuildPackageSet(t *rhel.ImageType) rpmmd.PackageSet { ps := rpmmd.PackageSet{ Include: []string{ "dnf", @@ -33,7 +34,7 @@ func distroBuildPackageSet(t *imageType) rpmmd.PackageSet { }, } - switch t.arch.Name() { + switch t.Arch().Name() { case arch.ARCH_X86_64.String(): ps = ps.Append(x8664BuildPackageSet(t)) @@ -46,7 +47,7 @@ func distroBuildPackageSet(t *imageType) rpmmd.PackageSet { } // x86_64 build package set -func x8664BuildPackageSet(t *imageType) rpmmd.PackageSet { +func x8664BuildPackageSet(t *rhel.ImageType) rpmmd.PackageSet { return rpmmd.PackageSet{ Include: []string{ "grub2-pc", @@ -55,7 +56,7 @@ func x8664BuildPackageSet(t *imageType) rpmmd.PackageSet { } // ppc64le build package set -func ppc64leBuildPackageSet(t *imageType) rpmmd.PackageSet { +func ppc64leBuildPackageSet(t *rhel.ImageType) rpmmd.PackageSet { return rpmmd.PackageSet{ Include: []string{ "grub2-ppc64le", @@ -66,7 +67,7 @@ func ppc64leBuildPackageSet(t *imageType) rpmmd.PackageSet { // installer boot package sets, needed for booting and // also in the build host -func anacondaBootPackageSet(t *imageType) rpmmd.PackageSet { +func anacondaBootPackageSet(t *rhel.ImageType) rpmmd.PackageSet { ps := rpmmd.PackageSet{} grubCommon := rpmmd.PackageSet{ @@ -83,7 +84,7 @@ func anacondaBootPackageSet(t *imageType) rpmmd.PackageSet { }, } - switch t.arch.Name() { + switch t.Arch().Name() { case arch.ARCH_X86_64.String(): ps = ps.Append(grubCommon) ps = ps.Append(efiCommon) @@ -110,7 +111,7 @@ func anacondaBootPackageSet(t *imageType) rpmmd.PackageSet { }) default: - panic(fmt.Sprintf("unsupported arch: %s", t.arch.Name())) + panic(fmt.Sprintf("unsupported arch: %s", t.Arch().Name())) } return ps @@ -119,8 +120,8 @@ func anacondaBootPackageSet(t *imageType) rpmmd.PackageSet { // OS package sets // packages that are only in some (sub)-distributions -func distroSpecificPackageSet(t *imageType) rpmmd.PackageSet { - if t.arch.distro.isRHEL() { +func distroSpecificPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + if t.IsRHEL() { return rpmmd.PackageSet{ Include: []string{ "insights-client", @@ -130,7 +131,7 @@ func distroSpecificPackageSet(t *imageType) rpmmd.PackageSet { return rpmmd.PackageSet{} } -func minimalrpmPackageSet(t *imageType) rpmmd.PackageSet { +func minimalrpmPackageSet(t *rhel.ImageType) rpmmd.PackageSet { return rpmmd.PackageSet{ Include: []string{ "@core", diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel9/partition_tables.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/partition_tables.go similarity index 90% rename from vendor/github.com/osbuild/images/pkg/distro/rhel9/partition_tables.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/partition_tables.go index b0caa37a330..f327fcd16c2 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/rhel9/partition_tables.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/partition_tables.go @@ -4,15 +4,16 @@ import ( "github.com/osbuild/images/internal/common" "github.com/osbuild/images/pkg/arch" "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/distro/rhel" ) -func defaultBasePartitionTables(t *imageType) (disk.PartitionTable, bool) { +func defaultBasePartitionTables(t *rhel.ImageType) (disk.PartitionTable, bool) { var bootSize uint64 switch { - case common.VersionLessThan(t.arch.distro.osVersion, "9.3") && t.arch.distro.isRHEL(): + case common.VersionLessThan(t.Arch().Distro().OsVersion(), "9.3") && t.IsRHEL(): // RHEL <= 9.2 had only 500 MiB /boot bootSize = 500 * common.MebiByte - case common.VersionLessThan(t.arch.distro.osVersion, "9.4") && t.arch.distro.isRHEL(): + case common.VersionLessThan(t.Arch().Distro().OsVersion(), "9.4") && t.IsRHEL(): // RHEL 9.3 had 600 MiB /boot, see RHEL-7999 bootSize = 600 * common.MebiByte default: @@ -20,8 +21,8 @@ func defaultBasePartitionTables(t *imageType) (disk.PartitionTable, bool) { bootSize = 1 * common.GibiByte } - switch t.platform.GetArch() { - case arch.ARCH_X86_64: + switch t.Arch().Name() { + case arch.ARCH_X86_64.String(): return disk.PartitionTable{ UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", Type: "gpt", @@ -74,7 +75,7 @@ func defaultBasePartitionTables(t *imageType) (disk.PartitionTable, bool) { }, }, }, true - case arch.ARCH_AARCH64: + case arch.ARCH_AARCH64.String(): return disk.PartitionTable{ UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", Type: "gpt", @@ -121,7 +122,7 @@ func defaultBasePartitionTables(t *imageType) (disk.PartitionTable, bool) { }, }, }, true - case arch.ARCH_PPC64LE: + case arch.ARCH_PPC64LE.String(): return disk.PartitionTable{ UUID: "0x14fc63d2", Type: "dos", @@ -155,7 +156,7 @@ func defaultBasePartitionTables(t *imageType) (disk.PartitionTable, bool) { }, }, true - case arch.ARCH_S390X: + case arch.ARCH_S390X.String(): return disk.PartitionTable{ UUID: "0x14fc63d2", Type: "dos", diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel9/qcow2.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/qcow2.go similarity index 54% rename from vendor/github.com/osbuild/images/pkg/distro/rhel9/qcow2.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/qcow2.go index 7b7031e1419..a956538947b 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/rhel9/qcow2.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/qcow2.go @@ -3,37 +3,88 @@ package rhel9 import ( "github.com/osbuild/images/internal/common" "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" "github.com/osbuild/images/pkg/osbuild" "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/images/pkg/subscription" ) -var ( - openstackImgType = imageType{ - name: "openstack", - filename: "disk.qcow2", - mimeType: "application/x-qemu-disk", - packageSets: map[string]packageSetFunc{ - osPkgsKey: openstackCommonPackageSet, +func mkQcow2ImgType(d *rhel.Distribution) *rhel.ImageType { + it := rhel.NewImageType( + "qcow2", + "disk.qcow2", + "application/x-qemu-disk", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: qcow2CommonPackageSet, }, - defaultImageConfig: &distro.ImageConfig{ - Locale: common.ToPtr("en_US.UTF-8"), + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "qcow2"}, + []string{"qcow2"}, + ) + + it.DefaultImageConfig = qcowImageConfig(d) + it.KernelOptions = "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0" + it.DefaultSize = 10 * common.GibiByte + it.Bootable = true + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +func mkOCIImgType(d *rhel.Distribution) *rhel.ImageType { + it := rhel.NewImageType( + "oci", + "disk.qcow2", + "application/x-qemu-disk", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: qcow2CommonPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "qcow2"}, + []string{"qcow2"}, + ) + + it.DefaultImageConfig = qcowImageConfig(d) + it.KernelOptions = "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0" + it.DefaultSize = 10 * common.GibiByte + it.Bootable = true + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +func mkOpenstackImgType() *rhel.ImageType { + it := rhel.NewImageType( + "openstack", + "disk.qcow2", + "application/x-qemu-disk", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: openstackCommonPackageSet, }, - kernelOptions: "ro net.ifnames=0", - bootable: true, - defaultSize: 4 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "qcow2"}, - exports: []string{"qcow2"}, - basePartitionTables: defaultBasePartitionTables, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "qcow2"}, + []string{"qcow2"}, + ) + + it.DefaultImageConfig = &distro.ImageConfig{ + Locale: common.ToPtr("en_US.UTF-8"), } -) + it.KernelOptions = "ro net.ifnames=0" + it.DefaultSize = 4 * common.GibiByte + it.Bootable = true + it.BasePartitionTables = defaultBasePartitionTables + + return it +} -func qcow2CommonPackageSet(t *imageType) rpmmd.PackageSet { +func qcow2CommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { ps := rpmmd.PackageSet{ Include: []string{ "@core", + "authselect-compat", "chrony", "cloud-init", "cloud-utils-growpart", @@ -93,12 +144,8 @@ func qcow2CommonPackageSet(t *imageType) rpmmd.PackageSet { }, }.Append(distroSpecificPackageSet(t)) - if t.arch.distro.releaseVersion == "9" { - ps.Include = append(ps.Include, "authselect-compat") - } - // Ensure to not pull in subscription-manager on non-RHEL distro - if t.arch.distro.isRHEL() { + if t.IsRHEL() { ps = ps.Append(rpmmd.PackageSet{ Include: []string{ "subscription-manager-cockpit", @@ -109,7 +156,7 @@ func qcow2CommonPackageSet(t *imageType) rpmmd.PackageSet { return ps } -func openstackCommonPackageSet(t *imageType) rpmmd.PackageSet { +func openstackCommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { ps := rpmmd.PackageSet{ Include: []string{ // Defaults @@ -131,11 +178,11 @@ func openstackCommonPackageSet(t *imageType) rpmmd.PackageSet { return ps } -func qcowImageConfig(d distribution) *distro.ImageConfig { +func qcowImageConfig(d *rhel.Distribution) *distro.ImageConfig { ic := &distro.ImageConfig{ DefaultTarget: common.ToPtr("multi-user.target"), } - if d.isRHEL() { + if d.IsRHEL() { ic.RHSMConfig = map[subscription.RHSMStatus]*osbuild.RHSMStageOptions{ subscription.RHSMConfigNoSubscription: { DnfPlugins: &osbuild.RHSMStageOptionsDnfPlugins{ @@ -152,24 +199,3 @@ func qcowImageConfig(d distribution) *distro.ImageConfig { } return ic } - -func mkQcow2ImgType(d distribution) imageType { - it := imageType{ - name: "qcow2", - filename: "disk.qcow2", - mimeType: "application/x-qemu-disk", - kernelOptions: "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0", - packageSets: map[string]packageSetFunc{ - osPkgsKey: qcow2CommonPackageSet, - }, - bootable: true, - defaultSize: 10 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "qcow2"}, - exports: []string{"qcow2"}, - basePartitionTables: defaultBasePartitionTables, - } - it.defaultImageConfig = qcowImageConfig(d) - return it -} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel9/sap.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/sap.go similarity index 97% rename from vendor/github.com/osbuild/images/pkg/distro/rhel9/sap.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/sap.go index d1f41713a50..14e25633d04 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/rhel9/sap.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/sap.go @@ -2,6 +2,7 @@ package rhel9 import ( "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" "github.com/osbuild/images/pkg/osbuild" "github.com/osbuild/images/pkg/rpmmd" ) @@ -118,7 +119,7 @@ func sapImageConfig(osVersion string) *distro.ImageConfig { } } -func SapPackageSet(t *imageType) rpmmd.PackageSet { +func SapPackageSet(t *rhel.ImageType) rpmmd.PackageSet { return rpmmd.PackageSet{ Include: []string{ // RHBZ#2076763 diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel9/ubi.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/ubi.go similarity index 75% rename from vendor/github.com/osbuild/images/pkg/distro/rhel9/ubi.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/ubi.go index d49e65334d8..f78721441d6 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/rhel9/ubi.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/ubi.go @@ -3,18 +3,26 @@ package rhel9 import ( "github.com/osbuild/images/internal/common" "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" "github.com/osbuild/images/pkg/osbuild" "github.com/osbuild/images/pkg/rpmmd" ) -var wslImgType = imageType{ - name: "wsl", - filename: "disk.tar.gz", - mimeType: "application/x-tar", - packageSets: map[string]packageSetFunc{ - osPkgsKey: ubiCommonPackageSet, - }, - defaultImageConfig: &distro.ImageConfig{ +func mkWSLImgType() *rhel.ImageType { + it := rhel.NewImageType( + "wsl", + "disk.tar.gz", + "application/x-tar", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: ubiCommonPackageSet, + }, + rhel.TarImage, + []string{"build"}, + []string{"os", "archive"}, + []string{"archive"}, + ) + + it.DefaultImageConfig = &distro.ImageConfig{ Locale: common.ToPtr("en_US.UTF-8"), NoSElinux: common.ToPtr(true), WSLConfig: &osbuild.WSLConfStageOptions{ @@ -22,15 +30,12 @@ var wslImgType = imageType{ Systemd: true, }, }, - }, - bootable: false, - image: tarImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "archive"}, - exports: []string{"archive"}, + } + + return it } -func ubiCommonPackageSet(t *imageType) rpmmd.PackageSet { +func ubiCommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { ps := rpmmd.PackageSet{ Include: []string{ "alternatives", diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/vmdk.go b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/vmdk.go new file mode 100644 index 00000000000..18cbb4ab278 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel/rhel9/vmdk.go @@ -0,0 +1,80 @@ +package rhel9 + +import ( + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/rhel" + "github.com/osbuild/images/pkg/rpmmd" +) + +const vmdkKernelOptions = "ro net.ifnames=0" + +func mkVMDKImgType() *rhel.ImageType { + it := rhel.NewImageType( + "vmdk", + "disk.vmdk", + "application/x-vmdk", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: vmdkCommonPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "vmdk"}, + []string{"vmdk"}, + ) + + it.DefaultImageConfig = &distro.ImageConfig{ + Locale: common.ToPtr("en_US.UTF-8"), + } + it.KernelOptions = vmdkKernelOptions + it.Bootable = true + it.DefaultSize = 4 * common.GibiByte + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +func mkOVAImgType() *rhel.ImageType { + it := rhel.NewImageType( + "ova", + "image.ova", + "application/ovf", + map[string]rhel.PackageSetFunc{ + rhel.OSPkgsKey: vmdkCommonPackageSet, + }, + rhel.DiskImage, + []string{"build"}, + []string{"os", "image", "vmdk", "ovf", "archive"}, + []string{"archive"}, + ) + + it.DefaultImageConfig = &distro.ImageConfig{ + Locale: common.ToPtr("en_US.UTF-8"), + } + it.KernelOptions = vmdkKernelOptions + it.Bootable = true + it.DefaultSize = 4 * common.GibiByte + it.BasePartitionTables = defaultBasePartitionTables + + return it +} + +func vmdkCommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet { + ps := rpmmd.PackageSet{ + Include: []string{ + "@core", + "chrony", + "cloud-init", + "firewalld", + "langpacks-en", + "open-vm-tools", + "tuned", + }, + Exclude: []string{ + "dracut-config-rescue", + "rng-tools", + }, + } + + return ps +} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel9/distro.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/distro.go deleted file mode 100644 index 9fef7342dd5..00000000000 --- a/vendor/github.com/osbuild/images/pkg/distro/rhel9/distro.go +++ /dev/null @@ -1,592 +0,0 @@ -package rhel9 - -import ( - "errors" - "fmt" - "sort" - "strings" - - "github.com/osbuild/images/internal/common" - "github.com/osbuild/images/pkg/arch" - "github.com/osbuild/images/pkg/customizations/oscap" - "github.com/osbuild/images/pkg/distro" - "github.com/osbuild/images/pkg/osbuild" - "github.com/osbuild/images/pkg/platform" - "github.com/osbuild/images/pkg/runner" -) - -var ( - // rhel9 & cs9 share the same list - // of allowed profiles so a single - // allow list can be used - oscapProfileAllowList = []oscap.Profile{ - oscap.AnssiBp28Enhanced, - oscap.AnssiBp28High, - oscap.AnssiBp28Intermediary, - oscap.AnssiBp28Minimal, - oscap.Cis, - oscap.CisServerL1, - oscap.CisWorkstationL1, - oscap.CisWorkstationL2, - oscap.Cui, - oscap.E8, - oscap.Hippa, - oscap.IsmO, - oscap.Ospp, - oscap.PciDss, - oscap.Stig, - oscap.StigGui, - } -) - -type distribution struct { - name string - product string - osVersion string - releaseVersion string - modulePlatformID string - vendor string - ostreeRefTmpl string - runner runner.Runner - arches map[string]distro.Arch - defaultImageConfig *distro.ImageConfig -} - -// CentOS- and RHEL-based OS image configuration defaults -var defaultDistroImageConfig = &distro.ImageConfig{ - Timezone: common.ToPtr("America/New_York"), - Locale: common.ToPtr("C.UTF-8"), - Sysconfig: []*osbuild.SysconfigStageOptions{ - { - Kernel: &osbuild.SysconfigKernelOptions{ - UpdateDefault: true, - DefaultKernel: "kernel", - }, - Network: &osbuild.SysconfigNetworkOptions{ - Networking: true, - NoZeroConf: true, - }, - }, - }, -} - -func (d *distribution) Name() string { - return d.name -} - -func (d *distribution) Releasever() string { - return d.releaseVersion -} - -func (d *distribution) OsVersion() string { - return d.osVersion -} - -func (d *distribution) Product() string { - return d.product -} - -func (d *distribution) ModulePlatformID() string { - return d.modulePlatformID -} - -func (d *distribution) OSTreeRef() string { - return d.ostreeRefTmpl -} - -func (d *distribution) ListArches() []string { - archNames := make([]string, 0, len(d.arches)) - for name := range d.arches { - archNames = append(archNames, name) - } - sort.Strings(archNames) - return archNames -} - -func (d *distribution) GetArch(name string) (distro.Arch, error) { - arch, exists := d.arches[name] - if !exists { - return nil, errors.New("invalid architecture: " + name) - } - return arch, nil -} - -func (d *distribution) addArches(arches ...architecture) { - if d.arches == nil { - d.arches = map[string]distro.Arch{} - } - - // Do not make copies of architectures, as opposed to image types, - // because architecture definitions are not used by more than a single - // distro definition. - for idx := range arches { - d.arches[arches[idx].name] = &arches[idx] - } -} - -func (d *distribution) isRHEL() bool { - return strings.HasPrefix(d.name, "rhel") -} - -func (d *distribution) getDefaultImageConfig() *distro.ImageConfig { - return d.defaultImageConfig -} - -func newDistro(name string, major, minor int) *distribution { - var rd distribution - switch fmt.Sprintf("%s-%d", name, major) { - case "rhel-9": - rd = distribution{ - name: fmt.Sprintf("rhel-9.%d", minor), - product: "Red Hat Enterprise Linux", - osVersion: fmt.Sprintf("9.%d", minor), - releaseVersion: "9", - modulePlatformID: "platform:el9", - vendor: "redhat", - ostreeRefTmpl: "rhel/9/%s/edge", - runner: &runner.RHEL{Major: uint64(9), Minor: uint64(minor)}, - defaultImageConfig: defaultDistroImageConfig, - } - case "rhel-10": - rd = distribution{ - name: fmt.Sprintf("rhel-10.%d", minor), - product: "Red Hat Enterprise Linux", - osVersion: fmt.Sprintf("10.%d", minor), - releaseVersion: "10", - modulePlatformID: "platform:el10", - vendor: "redhat", - ostreeRefTmpl: "rhel/10/%s/edge", - runner: &runner.RHEL{Major: uint64(10), Minor: uint64(minor)}, - defaultImageConfig: defaultDistroImageConfig, - } - case "centos-9": - rd = distribution{ - name: "centos-9", - product: "CentOS Stream", - osVersion: "9-stream", - releaseVersion: "9", - modulePlatformID: "platform:el9", - vendor: "centos", - ostreeRefTmpl: "centos/9/%s/edge", - runner: &runner.CentOS{Version: uint64(9)}, - defaultImageConfig: defaultDistroImageConfig, - } - case "centos-10": - rd = distribution{ - name: "centos-10", - product: "CentOS Stream", - osVersion: "10-stream", - releaseVersion: "10", - modulePlatformID: "platform:el10", - vendor: "centos", - ostreeRefTmpl: "centos/10/%s/edge", - runner: &runner.CentOS{Version: uint64(10)}, - defaultImageConfig: defaultDistroImageConfig, - } - default: - panic(fmt.Sprintf("unknown distro name: %s and major: %d", name, major)) - } - - // Architecture definitions - x86_64 := architecture{ - name: arch.ARCH_X86_64.String(), - distro: &rd, - } - - aarch64 := architecture{ - name: arch.ARCH_AARCH64.String(), - distro: &rd, - } - - ppc64le := architecture{ - distro: &rd, - name: arch.ARCH_PPC64LE.String(), - } - - s390x := architecture{ - distro: &rd, - name: arch.ARCH_S390X.String(), - } - - qcow2ImgType := mkQcow2ImgType(rd) - ociImgType := qcow2ImgType - ociImgType.name = "oci" - - x86_64.addImageTypes( - &platform.X86{ - BIOS: true, - UEFIVendor: rd.vendor, - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_QCOW2, - QCOW2Compat: "1.1", - }, - }, - qcow2ImgType, - ociImgType, - ) - - x86_64.addImageTypes( - &platform.X86{ - BIOS: true, - UEFIVendor: rd.vendor, - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_QCOW2, - }, - }, - openstackImgType, - ) - - x86_64.addImageTypes( - &platform.X86{ - BIOS: true, - UEFIVendor: rd.vendor, - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_VMDK, - }, - }, - vmdkImgType, - ) - - x86_64.addImageTypes( - &platform.X86{ - BIOS: true, - UEFIVendor: rd.vendor, - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_OVA, - }, - }, - ovaImgType, - ) - - x86_64.addImageTypes( - &platform.X86{}, - tarImgType, - wslImgType, - ) - - aarch64.addImageTypes( - &platform.Aarch64{ - UEFIVendor: rd.vendor, - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_QCOW2, - }, - }, - openstackImgType, - ) - - aarch64.addImageTypes( - &platform.Aarch64{}, - tarImgType, - wslImgType, - ) - - aarch64.addImageTypes( - &platform.Aarch64{ - UEFIVendor: rd.vendor, - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_QCOW2, - QCOW2Compat: "1.1", - }, - }, - qcow2ImgType, - ) - - ppc64le.addImageTypes( - &platform.PPC64LE{ - BIOS: true, - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_QCOW2, - QCOW2Compat: "1.1", - }, - }, - qcow2ImgType, - ) - ppc64le.addImageTypes( - &platform.PPC64LE{}, - tarImgType, - ) - - s390x.addImageTypes( - &platform.S390X{ - Zipl: true, - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_QCOW2, - QCOW2Compat: "1.1", - }, - }, - qcow2ImgType, - ) - s390x.addImageTypes( - &platform.S390X{}, - tarImgType, - ) - - ec2X86Platform := &platform.X86{ - BIOS: true, - UEFIVendor: rd.vendor, - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_RAW, - }, - } - x86_64.addImageTypes( - ec2X86Platform, - mkAMIImgTypeX86_64(), - ) - - aarch64.addImageTypes( - &platform.Aarch64{ - UEFIVendor: rd.vendor, - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_RAW, - }, - }, - mkAMIImgTypeAarch64(), - ) - - azureX64Platform := &platform.X86{ - BIOS: true, - UEFIVendor: rd.vendor, - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_VHD, - }, - } - - azureAarch64Platform := &platform.Aarch64{ - UEFIVendor: rd.vendor, - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_VHD, - }, - } - - if rd.isRHEL() { // RHEL-only (non-CentOS) image types - x86_64.addImageTypes(azureX64Platform, azureByosImgType(rd)) - aarch64.addImageTypes(azureAarch64Platform, azureByosImgType(rd)) - } else { - x86_64.addImageTypes(azureX64Platform, azureImgType) - aarch64.addImageTypes(azureAarch64Platform, azureImgType) - } - - // NOTE: This condition is a temporary separation of EL9 and EL10 while we - // add support for all image types on EL10. Currently only a small subset - // is supported on EL10 because of package availability. This big - // conditional separation should be removed when most image types become - // available in EL10. - if major == 9 { - gceX86Platform := &platform.X86{ - UEFIVendor: rd.vendor, - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_GCE, - }, - } - x86_64.addImageTypes( - gceX86Platform, - mkGCEImageType(), - ) - - x86_64.addImageTypes( - &platform.X86{ - BasePlatform: platform.BasePlatform{ - FirmwarePackages: []string{ - "microcode_ctl", // ?? - "iwl1000-firmware", - "iwl100-firmware", - "iwl105-firmware", - "iwl135-firmware", - "iwl2000-firmware", - "iwl2030-firmware", - "iwl3160-firmware", - "iwl5000-firmware", - "iwl5150-firmware", - "iwl6050-firmware", - }, - }, - BIOS: true, - UEFIVendor: rd.vendor, - }, - edgeOCIImgType, - edgeCommitImgType, - edgeInstallerImgType, - edgeRawImgType, - imageInstaller, - edgeAMIImgType, - ) - - x86_64.addImageTypes( - &platform.X86{ - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_VMDK, - }, - BIOS: true, - UEFIVendor: rd.vendor, - }, - edgeVsphereImgType, - ) - - x86_64.addImageTypes( - &platform.X86{ - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_RAW, - }, - BIOS: false, - UEFIVendor: rd.vendor, - }, - edgeSimplifiedInstallerImgType, - minimalrawImgType, - ) - - aarch64.addImageTypes( - &platform.Aarch64{ - BasePlatform: platform.BasePlatform{}, - UEFIVendor: rd.vendor, - }, - edgeCommitImgType, - edgeOCIImgType, - edgeInstallerImgType, - edgeSimplifiedInstallerImgType, - imageInstaller, - edgeAMIImgType, - ) - - aarch64.addImageTypes( - &platform.Aarch64{ - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_VMDK, - }, - UEFIVendor: rd.vendor, - }, - edgeVsphereImgType, - ) - - aarch64.addImageTypes( - &platform.Aarch64{ - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_RAW, - }, - UEFIVendor: rd.vendor, - }, - edgeRawImgType, - minimalrawImgType, - ) - - if rd.isRHEL() { // RHEL-only (non-CentOS) image types - x86_64.addImageTypes(azureX64Platform, azureRhuiImgType, azureByosImgType(rd)) - aarch64.addImageTypes(azureAarch64Platform, azureRhuiImgType, azureByosImgType(rd)) - - x86_64.addImageTypes(azureX64Platform, azureSapRhuiImgType(rd)) - - // keep the RHEL EC2 x86_64 images before 9.3 BIOS-only for backward compatibility - if common.VersionLessThan(rd.osVersion, "9.3") { - ec2X86Platform = &platform.X86{ - BIOS: true, - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_RAW, - }, - } - } - - // add ec2 image types to RHEL distro only - x86_64.addImageTypes(ec2X86Platform, mkEc2ImgTypeX86_64(rd.osVersion, rd.isRHEL()), mkEc2HaImgTypeX86_64(rd.osVersion, rd.isRHEL()), mkEC2SapImgTypeX86_64(rd.osVersion, rd.isRHEL())) - - aarch64.addImageTypes( - &platform.Aarch64{ - UEFIVendor: rd.vendor, - BasePlatform: platform.BasePlatform{ - ImageFormat: platform.FORMAT_RAW, - }, - }, - mkEC2ImgTypeAarch64(rd.osVersion, rd.isRHEL()), - ) - - // add GCE RHUI image to RHEL only - x86_64.addImageTypes(gceX86Platform, mkGCERHUIImageType()) - } - } - - rd.addArches(x86_64, aarch64, ppc64le, s390x) - return &rd -} - -func ParseID(idStr string) (*distro.ID, error) { - id, err := distro.ParseID(idStr) - if err != nil { - return nil, err - } - - if id.Name != "rhel" && id.Name != "centos" { - return nil, fmt.Errorf("invalid distro name: %s", id.Name) - } - - // Backward compatibility layer for "rhel-93" or "rhel-910" - if id.Name == "rhel" && id.MinorVersion == -1 { - if id.MajorVersion/10 == 9 { - // handle single digit minor version - id.MinorVersion = id.MajorVersion % 10 - id.MajorVersion = 9 - } else if id.MajorVersion/100 == 9 { - // handle two digit minor version - id.MinorVersion = id.MajorVersion % 100 - id.MajorVersion = 9 - } - } - - if id.MajorVersion != 9 { - return nil, fmt.Errorf("invalid distro major version: %d", id.MajorVersion) - } - - // CentOS does not use minor version - if id.Name == "centos" && id.MinorVersion != -1 { - return nil, fmt.Errorf("centos does not use minor version, but got: %d", id.MinorVersion) - } - - // RHEL uses minor version - if id.Name == "rhel" && id.MinorVersion == -1 { - return nil, fmt.Errorf("rhel requires minor version, but got: %d", id.MinorVersion) - } - - return id, nil -} - -func DistroFactory(idStr string) distro.Distro { - id, err := ParseID(idStr) - if err != nil { - return nil - } - - return newDistro(id.Name, 9, id.MinorVersion) -} - -func ParseIDEl10(idStr string) (*distro.ID, error) { - id, err := distro.ParseID(idStr) - if err != nil { - return nil, err - } - - if id.Name != "rhel" && id.Name != "centos" { - return nil, fmt.Errorf("invalid distro name: %s", id.Name) - } - - if id.MajorVersion != 10 { - return nil, fmt.Errorf("invalid distro major version: %d", id.MajorVersion) - } - - // CentOS does not use minor version - if id.Name == "centos" && id.MinorVersion != -1 { - return nil, fmt.Errorf("centos does not use minor version, but got: %d", id.MinorVersion) - } - - // RHEL uses minor version - if id.Name == "rhel" && id.MinorVersion == -1 { - return nil, fmt.Errorf("rhel requires minor version, but got: %d", id.MinorVersion) - } - - return id, nil -} - -func DistroFactoryEl10(idStr string) distro.Distro { - id, err := ParseIDEl10(idStr) - if err != nil { - return nil - } - - return newDistro(id.Name, 10, id.MinorVersion) -} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel9/imagetype.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/imagetype.go deleted file mode 100644 index 99c6da59504..00000000000 --- a/vendor/github.com/osbuild/images/pkg/distro/rhel9/imagetype.go +++ /dev/null @@ -1,490 +0,0 @@ -package rhel9 - -import ( - "fmt" - "log" - "math/rand" - "strings" - - "golang.org/x/exp/slices" - - "github.com/osbuild/images/internal/common" - "github.com/osbuild/images/internal/environment" - "github.com/osbuild/images/internal/workload" - "github.com/osbuild/images/pkg/blueprint" - "github.com/osbuild/images/pkg/container" - "github.com/osbuild/images/pkg/customizations/oscap" - "github.com/osbuild/images/pkg/disk" - "github.com/osbuild/images/pkg/distro" - "github.com/osbuild/images/pkg/image" - "github.com/osbuild/images/pkg/manifest" - "github.com/osbuild/images/pkg/platform" - "github.com/osbuild/images/pkg/policies" - "github.com/osbuild/images/pkg/rpmmd" -) - -const ( - // package set names - - // build package set name - buildPkgsKey = "build" - - // main/common os image package set name - osPkgsKey = "os" - - // container package set name - containerPkgsKey = "container" - - // installer package set name - installerPkgsKey = "installer" - - // blueprint package set name - blueprintPkgsKey = "blueprint" - - // location for saving openscap remediation data - oscapDataDir = "/oscap_data" -) - -type imageFunc func(workload workload.Workload, t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, packageSets map[string]rpmmd.PackageSet, containers []container.SourceSpec, rng *rand.Rand) (image.ImageKind, error) - -type packageSetFunc func(t *imageType) rpmmd.PackageSet - -type basePartitionTableFunc func(t *imageType) (disk.PartitionTable, bool) - -type isoLabelFunc func(t *imageType) string - -type imageType struct { - arch *architecture - platform platform.Platform - environment environment.Environment - workload workload.Workload - name string - nameAliases []string - filename string - compression string // TODO: remove from image definition and make it a transport option - mimeType string - packageSets map[string]packageSetFunc - defaultImageConfig *distro.ImageConfig - kernelOptions string - defaultSize uint64 - buildPipelines []string - payloadPipelines []string - exports []string - image imageFunc - isoLabel isoLabelFunc - - // bootISO: installable ISO - bootISO bool - // rpmOstree: edge/ostree - rpmOstree bool - // bootable image - bootable bool - // List of valid arches for the image type - basePartitionTables basePartitionTableFunc -} - -func (t *imageType) Name() string { - return t.name -} - -func (t *imageType) Arch() distro.Arch { - return t.arch -} - -func (t *imageType) Filename() string { - return t.filename -} - -func (t *imageType) MIMEType() string { - return t.mimeType -} - -func (t *imageType) OSTreeRef() string { - d := t.arch.distro - if t.rpmOstree { - return fmt.Sprintf(d.ostreeRefTmpl, t.Arch().Name()) - } - return "" -} - -func (t *imageType) ISOLabel() (string, error) { - if !t.bootISO { - return "", fmt.Errorf("image type %q is not an ISO", t.name) - } - - if t.isoLabel != nil { - return t.isoLabel(t), nil - } - - return "", nil -} - -func (t *imageType) Size(size uint64) uint64 { - // Microsoft Azure requires vhd images to be rounded up to the nearest MB - if t.name == "vhd" && size%common.MebiByte != 0 { - size = (size/common.MebiByte + 1) * common.MebiByte - } - if size == 0 { - size = t.defaultSize - } - return size -} - -func (t *imageType) BuildPipelines() []string { - return t.buildPipelines -} - -func (t *imageType) PayloadPipelines() []string { - return t.payloadPipelines -} - -func (t *imageType) PayloadPackageSets() []string { - return []string{blueprintPkgsKey} -} - -func (t *imageType) PackageSetsChains() map[string][]string { - return nil -} - -func (t *imageType) Exports() []string { - if len(t.exports) > 0 { - return t.exports - } - return []string{"assembler"} -} - -func (t *imageType) BootMode() distro.BootMode { - if t.platform.GetUEFIVendor() != "" && t.platform.GetBIOSPlatform() != "" { - return distro.BOOT_HYBRID - } else if t.platform.GetUEFIVendor() != "" { - return distro.BOOT_UEFI - } else if t.platform.GetBIOSPlatform() != "" || t.platform.GetZiplSupport() { - return distro.BOOT_LEGACY - } - return distro.BOOT_NONE -} - -func (t *imageType) getPartitionTable( - mountpoints []blueprint.FilesystemCustomization, - options distro.ImageOptions, - rng *rand.Rand, -) (*disk.PartitionTable, error) { - archName := t.arch.Name() - - basePartitionTable, exists := t.basePartitionTables(t) - - if !exists { - return nil, fmt.Errorf("no partition table defined for architecture %q for image type %q", archName, t.Name()) - } - - imageSize := t.Size(options.Size) - - partitioningMode := options.PartitioningMode - if t.rpmOstree { - // Edge supports only LVM, force it. - // TODO Need a central location for logic like this - partitioningMode = disk.LVMPartitioningMode - } - - return disk.NewPartitionTable(&basePartitionTable, mountpoints, imageSize, partitioningMode, nil, rng) -} - -func (t *imageType) getDefaultImageConfig() *distro.ImageConfig { - // ensure that image always returns non-nil default config - imageConfig := t.defaultImageConfig - if imageConfig == nil { - imageConfig = &distro.ImageConfig{} - } - return imageConfig.InheritFrom(t.arch.distro.getDefaultImageConfig()) - -} - -func (t *imageType) PartitionType() string { - basePartitionTable, exists := t.basePartitionTables(t) - if !exists { - return "" - } - - return basePartitionTable.Type -} - -func (t *imageType) Manifest(bp *blueprint.Blueprint, - options distro.ImageOptions, - repos []rpmmd.RepoConfig, - seed int64) (*manifest.Manifest, []string, error) { - - warnings, err := t.checkOptions(bp, options) - if err != nil { - return nil, nil, err - } - - // merge package sets that appear in the image type with the package sets - // of the same name from the distro and arch - staticPackageSets := make(map[string]rpmmd.PackageSet) - - for name, getter := range t.packageSets { - staticPackageSets[name] = getter(t) - } - - // amend with repository information and collect payload repos - payloadRepos := make([]rpmmd.RepoConfig, 0) - for _, repo := range repos { - if len(repo.PackageSets) > 0 { - // only apply the repo to the listed package sets - for _, psName := range repo.PackageSets { - if slices.Contains(t.PayloadPackageSets(), psName) { - payloadRepos = append(payloadRepos, repo) - } - ps := staticPackageSets[psName] - ps.Repositories = append(ps.Repositories, repo) - staticPackageSets[psName] = ps - } - } - } - - w := t.workload - if w == nil { - cw := &workload.Custom{ - BaseWorkload: workload.BaseWorkload{ - Repos: payloadRepos, - }, - Packages: bp.GetPackagesEx(false), - } - if services := bp.Customizations.GetServices(); services != nil { - cw.Services = services.Enabled - cw.DisabledServices = services.Disabled - } - w = cw - } - - containerSources := make([]container.SourceSpec, len(bp.Containers)) - for idx, cont := range bp.Containers { - containerSources[idx] = container.SourceSpec{ - Source: cont.Source, - Name: cont.Name, - TLSVerify: cont.TLSVerify, - Local: cont.LocalStorage, - } - } - - source := rand.NewSource(seed) - // math/rand is good enough in this case - /* #nosec G404 */ - rng := rand.New(source) - - img, err := t.image(w, t, bp.Customizations, options, staticPackageSets, containerSources, rng) - if err != nil { - return nil, nil, err - } - mf := manifest.New() - switch t.arch.distro.releaseVersion { - case "9": - mf.Distro = manifest.DISTRO_EL9 - case "10": - mf.Distro = manifest.DISTRO_EL10 - default: - return nil, nil, fmt.Errorf("unsupported distro release version %s", t.arch.distro.releaseVersion) - } - _, err = img.InstantiateManifest(&mf, repos, t.arch.distro.runner, rng) - if err != nil { - return nil, nil, err - } - - return &mf, warnings, err -} - -func distroISOLabelFunc(t *imageType) string { - const RHEL_ISO_LABEL = "RHEL-%s-%s-0-BaseOS-%s" - const CS_ISO_LABEL = "CentOS-Stream-%s-BaseOS-%s" - - if t.arch.distro.isRHEL() { - osVer := strings.Split(t.Arch().Distro().OsVersion(), ".") - return fmt.Sprintf(RHEL_ISO_LABEL, osVer[0], osVer[1], t.Arch().Name()) - } else { - return fmt.Sprintf(CS_ISO_LABEL, t.Arch().Distro().Releasever(), t.Arch().Name()) - } -} - -// checkOptions checks the validity and compatibility of options and customizations for the image type. -// Returns ([]string, error) where []string, if non-nil, will hold any generated warnings (e.g. deprecation notices). -func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOptions) ([]string, error) { - - customizations := bp.Customizations - - // holds warnings (e.g. deprecation notices) - var warnings []string - if t.workload != nil { - // For now, if an image type defines its own workload, don't allow any - // user customizations. - // Soon we will have more workflows and each will define its allowed - // set of customizations. The current set of customizations defined in - // the blueprint spec corresponds to the Custom workflow. - if customizations != nil { - return warnings, fmt.Errorf(distro.NoCustomizationsAllowedError, t.name) - } - } - - // we do not support embedding containers on ostree-derived images, only on commits themselves - if len(bp.Containers) > 0 && t.rpmOstree && (t.name != "edge-commit" && t.name != "edge-container") { - return warnings, fmt.Errorf("embedding containers is not supported for %s on %s", t.name, t.arch.distro.name) - } - - if options.OSTree != nil { - if err := options.OSTree.Validate(); err != nil { - return nil, err - } - } - - if t.bootISO && t.rpmOstree { - // ostree-based ISOs require a URL from which to pull a payload commit - if options.OSTree == nil || options.OSTree.URL == "" { - return nil, fmt.Errorf("boot ISO image type %q requires specifying a URL from which to retrieve the OSTree commit", t.name) - } - - if t.name == "edge-simplified-installer" { - allowed := []string{"InstallationDevice", "FDO", "Ignition", "Kernel", "User", "Group", "FIPS", "Filesystem"} - if err := customizations.CheckAllowed(allowed...); err != nil { - return warnings, fmt.Errorf(distro.UnsupportedCustomizationError, t.name, strings.Join(allowed, ", ")) - } - if customizations.GetInstallationDevice() == "" { - return warnings, fmt.Errorf("boot ISO image type %q requires specifying an installation device to install to", t.name) - } - - // FDO is optional, but when specified has some restrictions - if customizations.GetFDO() != nil { - if customizations.GetFDO().ManufacturingServerURL == "" { - return warnings, fmt.Errorf("boot ISO image type %q requires specifying FDO.ManufacturingServerURL configuration to install to when using FDO", t.name) - } - var diunSet int - if customizations.GetFDO().DiunPubKeyHash != "" { - diunSet++ - } - if customizations.GetFDO().DiunPubKeyInsecure != "" { - diunSet++ - } - if customizations.GetFDO().DiunPubKeyRootCerts != "" { - diunSet++ - } - if diunSet != 1 { - return warnings, fmt.Errorf("boot ISO image type %q requires specifying one of [FDO.DiunPubKeyHash,FDO.DiunPubKeyInsecure,FDO.DiunPubKeyRootCerts] configuration to install to when using FDO", t.name) - } - } - - // ignition is optional, we might be using FDO - if customizations.GetIgnition() != nil { - if customizations.GetIgnition().Embedded != nil && customizations.GetIgnition().FirstBoot != nil { - return warnings, fmt.Errorf("both ignition embedded and firstboot configurations found") - } - if customizations.GetIgnition().FirstBoot != nil && customizations.GetIgnition().FirstBoot.ProvisioningURL == "" { - return warnings, fmt.Errorf("ignition.firstboot requires a provisioning url") - } - } - } else if t.name == "edge-installer" { - allowed := []string{"User", "Group", "FIPS", "Installer", "Timezone", "Locale"} - if err := customizations.CheckAllowed(allowed...); err != nil { - return warnings, fmt.Errorf(distro.UnsupportedCustomizationError, t.name, strings.Join(allowed, ", ")) - } - } - } - - if t.name == "edge-raw-image" || t.name == "edge-ami" || t.name == "edge-vsphere" { - // ostree-based bootable images require a URL from which to pull a payload commit - if options.OSTree == nil || options.OSTree.URL == "" { - return warnings, fmt.Errorf("%q images require specifying a URL from which to retrieve the OSTree commit", t.name) - } - allowed := []string{"Ignition", "Kernel", "User", "Group", "FIPS", "Filesystem"} - if err := customizations.CheckAllowed(allowed...); err != nil { - return warnings, fmt.Errorf(distro.UnsupportedCustomizationError, t.name, strings.Join(allowed, ", ")) - } - // TODO: consider additional checks, such as those in "edge-simplified-installer" - } - - // warn that user & group customizations on edge-commit, edge-container are deprecated - // TODO(edge): directly error if these options are provided when rhel-9.5's time arrives - if t.name == "edge-commit" || t.name == "edge-container" { - if customizations.GetUsers() != nil { - w := fmt.Sprintf("Please note that user customizations on %q image type are deprecated and will be removed in the near future\n", t.name) - log.Print(w) - warnings = append(warnings, w) - } - if customizations.GetGroups() != nil { - w := fmt.Sprintf("Please note that group customizations on %q image type are deprecated and will be removed in the near future\n", t.name) - log.Print(w) - warnings = append(warnings, w) - } - } - - if kernelOpts := customizations.GetKernel(); kernelOpts.Append != "" && t.rpmOstree && t.name != "edge-raw-image" && t.name != "edge-simplified-installer" { - return warnings, fmt.Errorf("kernel boot parameter customizations are not supported for ostree types") - } - - mountpoints := customizations.GetFilesystems() - if mountpoints != nil && t.rpmOstree && (t.name == "edge-container" || t.name == "edge-commit") { - return warnings, fmt.Errorf("Custom mountpoints are not supported for edge-container and edge-commit") - } else if mountpoints != nil && t.rpmOstree && !(t.name == "edge-container" || t.name == "edge-commit") { - //customization allowed for edge-raw-image,edge-ami,edge-vsphere,edge-simplified-installer - err := blueprint.CheckMountpointsPolicy(mountpoints, policies.OstreeMountpointPolicies) - if err != nil { - return warnings, err - } - } - - err := blueprint.CheckMountpointsPolicy(mountpoints, policies.MountpointPolicies) - if err != nil { - return warnings, err - } - - if osc := customizations.GetOpenSCAP(); osc != nil { - if t.arch.distro.osVersion == "9.0" { - return warnings, fmt.Errorf(fmt.Sprintf("OpenSCAP unsupported os version: %s", t.arch.distro.osVersion)) - } - if !oscap.IsProfileAllowed(osc.ProfileID, oscapProfileAllowList) { - return warnings, fmt.Errorf(fmt.Sprintf("OpenSCAP unsupported profile: %s", osc.ProfileID)) - } - if t.rpmOstree { - return warnings, fmt.Errorf("OpenSCAP customizations are not supported for ostree types") - } - if osc.ProfileID == "" { - return warnings, fmt.Errorf("OpenSCAP profile cannot be empty") - } - } - - // Check Directory/File Customizations are valid - dc := customizations.GetDirectories() - fc := customizations.GetFiles() - - err = blueprint.ValidateDirFileCustomizations(dc, fc) - if err != nil { - return warnings, err - } - err = blueprint.CheckDirectoryCustomizationsPolicy(dc, policies.CustomDirectoriesPolicies) - if err != nil { - return warnings, err - } - - err = blueprint.CheckFileCustomizationsPolicy(fc, policies.CustomFilesPolicies) - if err != nil { - return warnings, err - } - - // check if repository customizations are valid - _, err = customizations.GetRepositories() - if err != nil { - return warnings, err - } - - if customizations.GetFIPS() && !common.IsBuildHostFIPSEnabled() { - w := fmt.Sprintln(common.FIPSEnabledImageWarning) - log.Print(w) - warnings = append(warnings, w) - } - - if customizations.GetInstaller() != nil { - // only supported by the Anaconda installer - if slices.Index([]string{"image-installer", "edge-installer", "live-installer"}, t.name) == -1 { - return warnings, fmt.Errorf("installer customizations are not supported for %q", t.name) - } - } - - return warnings, nil -} diff --git a/vendor/github.com/osbuild/images/pkg/distro/rhel9/vmdk.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/vmdk.go deleted file mode 100644 index 41ccf57b649..00000000000 --- a/vendor/github.com/osbuild/images/pkg/distro/rhel9/vmdk.go +++ /dev/null @@ -1,69 +0,0 @@ -package rhel9 - -import ( - "github.com/osbuild/images/internal/common" - "github.com/osbuild/images/pkg/distro" - "github.com/osbuild/images/pkg/rpmmd" -) - -const vmdkKernelOptions = "ro net.ifnames=0" - -var vmdkImgType = imageType{ - name: "vmdk", - filename: "disk.vmdk", - mimeType: "application/x-vmdk", - packageSets: map[string]packageSetFunc{ - osPkgsKey: vmdkCommonPackageSet, - }, - defaultImageConfig: &distro.ImageConfig{ - Locale: common.ToPtr("en_US.UTF-8"), - }, - kernelOptions: vmdkKernelOptions, - bootable: true, - defaultSize: 4 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "vmdk"}, - exports: []string{"vmdk"}, - basePartitionTables: defaultBasePartitionTables, -} - -var ovaImgType = imageType{ - name: "ova", - filename: "image.ova", - mimeType: "application/ovf", - packageSets: map[string]packageSetFunc{ - osPkgsKey: vmdkCommonPackageSet, - }, - defaultImageConfig: &distro.ImageConfig{ - Locale: common.ToPtr("en_US.UTF-8"), - }, - kernelOptions: vmdkKernelOptions, - bootable: true, - defaultSize: 4 * common.GibiByte, - image: diskImage, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "vmdk", "ovf", "archive"}, - exports: []string{"archive"}, - basePartitionTables: defaultBasePartitionTables, -} - -func vmdkCommonPackageSet(t *imageType) rpmmd.PackageSet { - ps := rpmmd.PackageSet{ - Include: []string{ - "@core", - "chrony", - "cloud-init", - "firewalld", - "langpacks-en", - "open-vm-tools", - "tuned", - }, - Exclude: []string{ - "dracut-config-rescue", - "rng-tools", - }, - } - - return ps -} diff --git a/vendor/github.com/osbuild/images/pkg/distrofactory/distrofactory.go b/vendor/github.com/osbuild/images/pkg/distrofactory/distrofactory.go index 8111ddb3f03..87a5f8b4863 100644 --- a/vendor/github.com/osbuild/images/pkg/distrofactory/distrofactory.go +++ b/vendor/github.com/osbuild/images/pkg/distrofactory/distrofactory.go @@ -6,9 +6,10 @@ import ( "github.com/osbuild/images/pkg/distro" "github.com/osbuild/images/pkg/distro/fedora" + "github.com/osbuild/images/pkg/distro/rhel/rhel10" + "github.com/osbuild/images/pkg/distro/rhel/rhel9" "github.com/osbuild/images/pkg/distro/rhel7" "github.com/osbuild/images/pkg/distro/rhel8" - "github.com/osbuild/images/pkg/distro/rhel9" "github.com/osbuild/images/pkg/distro/test_distro" ) @@ -112,7 +113,7 @@ func NewDefault() *Factory { rhel7.DistroFactory, rhel8.DistroFactory, rhel9.DistroFactory, - rhel9.DistroFactoryEl10, + rhel10.DistroFactory, ) } diff --git a/vendor/github.com/osbuild/images/pkg/distroidparser/idparser.go b/vendor/github.com/osbuild/images/pkg/distroidparser/idparser.go index 6bdb34bb5e0..a9831ec728a 100644 --- a/vendor/github.com/osbuild/images/pkg/distroidparser/idparser.go +++ b/vendor/github.com/osbuild/images/pkg/distroidparser/idparser.go @@ -3,9 +3,10 @@ package distroidparser import ( "github.com/osbuild/images/pkg/distro" "github.com/osbuild/images/pkg/distro/fedora" + "github.com/osbuild/images/pkg/distro/rhel/rhel10" + "github.com/osbuild/images/pkg/distro/rhel/rhel9" "github.com/osbuild/images/pkg/distro/rhel7" "github.com/osbuild/images/pkg/distro/rhel8" - "github.com/osbuild/images/pkg/distro/rhel9" ) var DefaultParser = NewDefaultParser() @@ -66,6 +67,6 @@ func NewDefaultParser() *Parser { rhel7.ParseID, rhel8.ParseID, rhel9.ParseID, - rhel9.ParseIDEl10, + rhel10.ParseID, ) } diff --git a/vendor/github.com/osbuild/images/pkg/dnfjson/dnfjson.go b/vendor/github.com/osbuild/images/pkg/dnfjson/dnfjson.go index 23b4c060f1f..b6a97b5dd2e 100644 --- a/vendor/github.com/osbuild/images/pkg/dnfjson/dnfjson.go +++ b/vendor/github.com/osbuild/images/pkg/dnfjson/dnfjson.go @@ -167,7 +167,7 @@ func (s *Solver) GetCacheDir() string { func (s *Solver) Depsolve(pkgSets []rpmmd.PackageSet) ([]rpmmd.PackageSpec, error) { req, repoMap, err := s.makeDepsolveRequest(pkgSets) if err != nil { - return nil, err + return nil, fmt.Errorf("makeDepsolveRequest failed: %w", err) } // get non-exclusive read lock @@ -176,7 +176,7 @@ func (s *Solver) Depsolve(pkgSets []rpmmd.PackageSet) ([]rpmmd.PackageSpec, erro output, err := run(s.dnfJsonCmd, req) if err != nil { - return nil, err + return nil, fmt.Errorf("run (%s) failed: %w", s.dnfJsonCmd, err) } // touch repos to now now := time.Now().Local() @@ -675,7 +675,7 @@ func run(dnfJsonCmd []string, req *Request) ([]byte, error) { cmd := exec.Command(ex, args...) stdin, err := cmd.StdinPipe() if err != nil { - return nil, err + return nil, fmt.Errorf("calling %s failed: %w", ex, err) } cmd.Stderr = os.Stderr @@ -684,12 +684,12 @@ func run(dnfJsonCmd []string, req *Request) ([]byte, error) { err = cmd.Start() if err != nil { - return nil, err + return nil, fmt.Errorf("starting %s failed: %w", ex, err) } err = json.NewEncoder(stdin).Encode(req) if err != nil { - return nil, err + return nil, fmt.Errorf("encoding request for %s failed: %w", ex, err) } stdin.Close() diff --git a/vendor/github.com/osbuild/images/pkg/image/bootc_disk.go b/vendor/github.com/osbuild/images/pkg/image/bootc_disk.go index 08cf81571f2..a2c27eb9ea8 100644 --- a/vendor/github.com/osbuild/images/pkg/image/bootc_disk.go +++ b/vendor/github.com/osbuild/images/pkg/image/bootc_disk.go @@ -5,26 +5,38 @@ import ( "math/rand" "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/customizations/users" + "github.com/osbuild/images/pkg/disk" "github.com/osbuild/images/pkg/manifest" "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/platform" "github.com/osbuild/images/pkg/runner" ) type BootcDiskImage struct { - *OSTreeDiskImage + Base + + Platform platform.Platform + PartitionTable *disk.PartitionTable + + Filename string + + ContainerSource *container.SourceSpec + + // Customizations + KernelOptionsAppend []string + + // "Users" is a bit misleading as only root and its ssh key is supported + // right now because that is all that bootc gives us by default but that + // will most likely change over time. + // See https://github.com/containers/bootc/pull/267 + Users []users.User } func NewBootcDiskImage(container container.SourceSpec) *BootcDiskImage { - // XXX: hardcoded for now - ref := "ostree/1/1/0" - return &BootcDiskImage{ - &OSTreeDiskImage{ - Base: NewBase("bootc-raw-image"), - ContainerSource: &container, - Ref: ref, - OSName: "default", - }, + Base: NewBase("bootc-raw-image"), + ContainerSource: &container, } } @@ -40,14 +52,17 @@ func (img *BootcDiskImage) InstantiateManifestFromContainers(m *manifest.Manifes // this is signified by passing nil to the below pipelines. var hostPipeline manifest.Build - opts := &baseRawOstreeImageOpts{useBootupd: true} - - fileBasename := img.Filename + // TODO: no support for customization right now but minimal support + // for root ssh keys is supported + baseImage := manifest.NewRawBootcImage(buildPipeline, containers, img.Platform) + baseImage.PartitionTable = img.PartitionTable + baseImage.Users = img.Users + baseImage.KernelOptionsAppend = img.KernelOptionsAppend // In BIB, we export multiple images from the same pipeline so we use the // filename as the basename for each export and set the extensions based on // each file format. - baseImage := baseRawOstreeImage(img.OSTreeDiskImage, buildPipeline, opts) + fileBasename := img.Filename baseImage.SetFilename(fmt.Sprintf("%s.raw", fileBasename)) qcow2Pipeline := manifest.NewQCOW2(hostPipeline, baseImage) diff --git a/vendor/github.com/osbuild/images/pkg/manifest/build.go b/vendor/github.com/osbuild/images/pkg/manifest/build.go index acc7cc189ab..ef82d47823d 100644 --- a/vendor/github.com/osbuild/images/pkg/manifest/build.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/build.go @@ -235,11 +235,7 @@ func (p *BuildrootFromContainer) serialize() osbuild.Pipeline { pipeline.Runner = p.runner.String() image := osbuild.NewContainersInputForSingleSource(p.containerSpecs[0]) - options := &osbuild.ContainerDeployOptions{ - Exclude: []string{"/sysroot"}, - } - - stage, err := osbuild.NewContainerDeployStage(image, options) + stage, err := osbuild.NewContainerDeployStage(image, &osbuild.ContainerDeployOptions{}) if err != nil { panic(err) } @@ -247,6 +243,7 @@ func (p *BuildrootFromContainer) serialize() osbuild.Pipeline { pipeline.AddStage(osbuild.NewSELinuxStage( &osbuild.SELinuxStageOptions{ FileContexts: "etc/selinux/targeted/contexts/files/file_contexts", + ExcludePaths: []string{"/sysroot"}, Labels: p.getSELinuxLabels(), }, )) diff --git a/vendor/github.com/osbuild/images/pkg/manifest/pipeline.go b/vendor/github.com/osbuild/images/pkg/manifest/pipeline.go index 4a92e6b561f..ed1d67e79b3 100644 --- a/vendor/github.com/osbuild/images/pkg/manifest/pipeline.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/pipeline.go @@ -97,7 +97,7 @@ func (p Base) getCheckpoint() bool { } func (p *Base) Export() *artifact.Artifact { - panic("can't export pipeline") + panic("can't export pipeline directly from pipeline.Base") } func (p Base) getExport() bool { diff --git a/vendor/github.com/osbuild/images/pkg/manifest/raw_bootc.go b/vendor/github.com/osbuild/images/pkg/manifest/raw_bootc.go new file mode 100644 index 00000000000..dfe4c2da756 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/manifest/raw_bootc.go @@ -0,0 +1,142 @@ +package manifest + +import ( + "fmt" + + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/customizations/users" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" +) + +// A RawBootcImage represents a raw bootc image file which can be booted in a +// hypervisor. +type RawBootcImage struct { + Base + + filename string + platform platform.Platform + + containers []container.SourceSpec + containerSpecs []container.Spec + + // customizations go here because there is no intermediate + // tree, with `bootc install to-filesystem` we can only work + // with the image itself + PartitionTable *disk.PartitionTable + + KernelOptionsAppend []string + + // "Users" is a bit misleading as only root and its ssh key is supported + // right now because that is all that bootc gives us by default but that + // will most likely change over time. + // See https://github.com/containers/bootc/pull/267 + Users []users.User +} + +func (p RawBootcImage) Filename() string { + return p.filename +} + +func (p *RawBootcImage) SetFilename(filename string) { + p.filename = filename +} + +func NewRawBootcImage(buildPipeline Build, containers []container.SourceSpec, platform platform.Platform) *RawBootcImage { + p := &RawBootcImage{ + Base: NewBase("image", buildPipeline), + filename: "disk.img", + platform: platform, + + containers: containers, + } + buildPipeline.addDependent(p) + return p +} + +func (p *RawBootcImage) getContainerSources() []container.SourceSpec { + return p.containers +} + +func (p *RawBootcImage) getContainerSpecs() []container.Spec { + return p.containerSpecs +} + +func (p *RawBootcImage) serializeStart(_ []rpmmd.PackageSpec, containerSpecs []container.Spec, _ []ostree.CommitSpec) { + if len(p.containerSpecs) > 0 { + panic("double call to serializeStart()") + } + p.containerSpecs = containerSpecs +} + +func (p *RawBootcImage) serializeEnd() { + if len(p.containerSpecs) == 0 { + panic("serializeEnd() call when serialization not in progress") + } + p.containerSpecs = nil +} + +func (p *RawBootcImage) serialize() osbuild.Pipeline { + pipeline := p.Base.serialize() + + pt := p.PartitionTable + if pt == nil { + panic(fmt.Errorf("no partition table in live image")) + } + + if len(p.Users) > 1 { + panic(fmt.Errorf("raw bootc image only supports a single root key for user customization, got %v", p.Users)) + } + if len(p.Users) == 1 && p.Users[0].Name != "root" { + panic(fmt.Errorf("raw bootc image only supports the root user, got %v", p.Users)) + } + + for _, stage := range osbuild.GenImagePrepareStages(pt, p.filename, osbuild.PTSfdisk) { + pipeline.AddStage(stage) + } + + if len(p.containerSpecs) != 1 { + panic(fmt.Errorf("expected a single container input got %v", p.containerSpecs)) + } + opts := &osbuild.BootcInstallToFilesystemOptions{ + Kargs: p.KernelOptionsAppend, + } + if len(p.Users) == 1 && p.Users[0].Key != nil { + opts.RootSSHAuthorizedKeys = []string{*p.Users[0].Key} + } + inputs := osbuild.ContainerDeployInputs{ + Images: osbuild.NewContainersInputForSingleSource(p.containerSpecs[0]), + } + devices, mounts, err := osbuild.GenBootupdDevicesMounts(p.filename, p.PartitionTable) + if err != nil { + panic(err) + } + st, err := osbuild.NewBootcInstallToFilesystemStage(opts, inputs, devices, mounts) + if err != nil { + panic(err) + } + pipeline.AddStage(st) + + // XXX: there is no way right now to support any customizations, + // we cannot touch the filesystem after bootc installed it or + // we risk messing with it's selinux labels or future fsverity + // magic. Once we have a mechanism like --copy-etc from + // https://github.com/containers/bootc/pull/267 things should + // be a bit better + + for _, stage := range osbuild.GenImageFinishStages(pt, p.filename) { + pipeline.AddStage(stage) + } + + return pipeline +} + +// XXX: copied from raw.go +func (p *RawBootcImage) Export() *artifact.Artifact { + p.Base.export = true + return artifact.New(p.Name(), p.Filename(), nil) +} diff --git a/vendor/github.com/osbuild/images/pkg/osbuild/bootc_install_to_filesystem_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/bootc_install_to_filesystem_stage.go index 26402a2bd50..06be586016d 100644 --- a/vendor/github.com/osbuild/images/pkg/osbuild/bootc_install_to_filesystem_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/bootc_install_to_filesystem_stage.go @@ -4,6 +4,15 @@ import ( "fmt" ) +type BootcInstallToFilesystemOptions struct { + // options for --root-ssh-authorized-keys + RootSSHAuthorizedKeys []string `json:"root-ssh-authorized-keys,omitempty"` + // options for --karg + Kargs []string `json:"kernel-args,omitempty"` +} + +func (BootcInstallToFilesystemOptions) isStageOptions() {} + // NewBootcInstallToFilesystem creates a new stage for the // org.osbuild.bootc.install-to-filesystem stage. // @@ -12,17 +21,18 @@ import ( // bootc/bootupd find and install all required bootloader bits. // // The mounts input should be generated with GenBootupdDevicesMounts. -func NewBootcInstallToFilesystemStage(inputs ContainersInput, devices map[string]Device, mounts []Mount) (*Stage, error) { +func NewBootcInstallToFilesystemStage(options *BootcInstallToFilesystemOptions, inputs ContainerDeployInputs, devices map[string]Device, mounts []Mount) (*Stage, error) { if err := validateBootupdMounts(mounts); err != nil { return nil, err } - if len(inputs.References) != 1 { - return nil, fmt.Errorf("expected exactly one container input but got: %v (%v)", len(inputs.References), inputs.References) + if len(inputs.Images.References) != 1 { + return nil, fmt.Errorf("expected exactly one container input but got: %v (%v)", len(inputs.Images.References), inputs.Images.References) } return &Stage{ Type: "org.osbuild.bootc.install-to-filesystem", + Options: options, Inputs: inputs, Devices: devices, Mounts: mounts, diff --git a/vendor/github.com/osbuild/images/pkg/osbuild/container_deploy_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/container_deploy_stage.go index 55d510b9211..be7606b2f9d 100644 --- a/vendor/github.com/osbuild/images/pkg/osbuild/container_deploy_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/container_deploy_stage.go @@ -9,7 +9,7 @@ type ContainerDeployInputs struct { func (ContainerDeployInputs) isStageInputs() {} type ContainerDeployOptions struct { - Exclude []string `json:"exclude"` + Exclude []string `json:"exclude,omitempty"` } func (ContainerDeployOptions) isStageOptions() {} diff --git a/vendor/github.com/osbuild/images/pkg/osbuild/selinux_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/selinux_stage.go index d5b0512cef4..196f0fe0ce7 100644 --- a/vendor/github.com/osbuild/images/pkg/osbuild/selinux_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/selinux_stage.go @@ -6,6 +6,7 @@ package osbuild // the filesystem labels to apply to the image. type SELinuxStageOptions struct { FileContexts string `json:"file_contexts"` + ExcludePaths []string `json:"exclude_paths,omitempty"` Labels map[string]string `json:"labels,omitempty"` ForceAutorelabel *bool `json:"force_autorelabel,omitempty"` } diff --git a/vendor/github.com/osbuild/osbuild-composer/pkg/splunk_logger/LICENSE b/vendor/github.com/osbuild/osbuild-composer/pkg/splunk_logger/LICENSE deleted file mode 100644 index 261eeb9e9f8..00000000000 --- a/vendor/github.com/osbuild/osbuild-composer/pkg/splunk_logger/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/modules.txt b/vendor/modules.txt index 0d303098345..5cd4389f765 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -866,9 +866,11 @@ github.com/osbuild/images/pkg/customizations/users github.com/osbuild/images/pkg/disk github.com/osbuild/images/pkg/distro github.com/osbuild/images/pkg/distro/fedora +github.com/osbuild/images/pkg/distro/rhel +github.com/osbuild/images/pkg/distro/rhel/rhel10 +github.com/osbuild/images/pkg/distro/rhel/rhel9 github.com/osbuild/images/pkg/distro/rhel7 github.com/osbuild/images/pkg/distro/rhel8 -github.com/osbuild/images/pkg/distro/rhel9 github.com/osbuild/images/pkg/distro/test_distro github.com/osbuild/images/pkg/distrofactory github.com/osbuild/images/pkg/distroidparser