From 8f84e46ab8ed00d36f573bf52adfc16c40453a6b Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Mon, 11 Oct 2021 17:24:39 +0200 Subject: [PATCH] distro/rhel86: add CentOS Stream 8 as alias to RHEL 8.6 Removed old alias from RHEL 8.4. To make aliasing distributions simpler, all distro-specific strings were added to the local distribution type. These were previously global constants of the distribution package and alias alternatives were used conditionally. Now the two distributions are predefined in global map. CentOS exclusions: - s390x arch - ec2 image types: rhui client is not available Signed-off-by: Achilleas Koutsou --- internal/distro/rhel86/distro.go | 91 +++++++++++----- internal/distro/rhel86/pipelines.go | 123 +++++++++------------- internal/distro/rhel86/stage_options.go | 65 +++++++++--- internal/distroregistry/distroregistry.go | 2 +- 4 files changed, 165 insertions(+), 116 deletions(-) diff --git a/internal/distro/rhel86/distro.go b/internal/distro/rhel86/distro.go index 72a2b1819..49f1b3868 100644 --- a/internal/distro/rhel86/distro.go +++ b/internal/distro/rhel86/distro.go @@ -16,12 +16,6 @@ import ( "github.com/osbuild/osbuild-composer/internal/rpmmd" ) -const defaultName = "rhel-86" -const osVersion = "8.6" -const releaseVersion = "8" -const modulePlatformID = "platform:el8" -const ostreeRef = "rhel/8/%s/edge" - const ( // package set names @@ -47,17 +41,49 @@ var mountpointAllowList = []string{ type distribution struct { name string + product string + osVersion string + releaseVersion string modulePlatformID string - ostreeRef string + vendor string + ostreeRefTmpl string + isolabelTmpl string + runner string arches map[string]distro.Arch } +// distribution objects without the arches > image types +var distroMap = map[string]distribution{ + "rhel-86": { + name: "rhel-86", + product: "Red Hat Enterprise Linux", + osVersion: "8.6", + releaseVersion: "8", + modulePlatformID: "platform:el8", + vendor: "redhat", + ostreeRefTmpl: "rhel/8/%s/edge", + isolabelTmpl: "RHEL-8-6-0-BaseOS-%s", + runner: "org.osbuild.rhel86", + }, + "centos-8": { + name: "centos-8", + product: "CentOS Stream", + osVersion: "8-stream", + releaseVersion: "8", + modulePlatformID: "platform:el8", + vendor: "centos", + ostreeRefTmpl: "centos/8/%s/edge", + isolabelTmpl: "CentOS-Stream-8-%s-dvd", + runner: "org.osbuild.centos8", + }, +} + func (d *distribution) Name() string { return d.name } func (d *distribution) Releasever() string { - return releaseVersion + return d.releaseVersion } func (d *distribution) ModulePlatformID() string { @@ -65,7 +91,7 @@ func (d *distribution) ModulePlatformID() string { } func (d *distribution) OSTreeRef() string { - return d.ostreeRef + return d.ostreeRefTmpl } func (d *distribution) ListArches() []string { @@ -207,8 +233,9 @@ func (t *imageType) MIMEType() string { } func (t *imageType) OSTreeRef() string { + d := t.arch.distro if t.rpmOstree { - return fmt.Sprintf(ostreeRef, t.arch.name) + return fmt.Sprintf(d.ostreeRefTmpl, t.arch.name) } return "" } @@ -458,44 +485,48 @@ func (t *imageType) checkOptions(customizations *blueprint.Customizations, optio // New creates a new distro object, defining the supported architectures and image types func New() distro.Distro { - return newDistro(defaultName, modulePlatformID, ostreeRef) + return newDistro("rhel-86") } func NewHostDistro(name, modulePlatformID, ostreeRef string) distro.Distro { - return newDistro(name, modulePlatformID, ostreeRef) + return newDistro("rhel-86") } -func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro { +func NewCentos() distro.Distro { + return newDistro("centos-8") +} + +func NewCentosHostDistro(name, modulePlatformID, ostreeRef string) distro.Distro { + return newDistro("centos-8") +} + +func newDistro(distroName string) distro.Distro { const GigaByte = 1024 * 1024 * 1024 - rd := &distribution{ - name: name, - modulePlatformID: modulePlatformID, - ostreeRef: ostreeRef, - } + rd := distroMap[distroName] // Architecture definitions x86_64 := architecture{ name: distro.X86_64ArchName, - distro: rd, + distro: &rd, legacy: "i386-pc", bootType: distro.HybridBootType, } aarch64 := architecture{ name: distro.Aarch64ArchName, - distro: rd, + distro: &rd, bootType: distro.UEFIBootType, } ppc64le := architecture{ - distro: rd, + distro: &rd, name: distro.Ppc64leArchName, legacy: "powerpc-ieee1275", bootType: distro.LegacyBootType, } s390x := architecture{ - distro: rd, + distro: &rd, name: distro.S390xArchName, bootType: distro.LegacyBootType, } @@ -836,11 +867,19 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro { exports: []string{"bootiso"}, } - x86_64.addImageTypes(qcow2ImgType, vhdImgType, vmdkImgType, openstackImgType, amiImgTypeX86_64, ec2ImgTypeX86_64, ec2HaImgTypeX86_64, ec2SapImgTypeX86_64, tarImgType, tarInstallerImgTypeX86_64, edgeCommitImgType, edgeInstallerImgType, edgeOCIImgType, edgeRawImgType, edgeSimplifiedInstallerImgType) - aarch64.addImageTypes(qcow2ImgType, openstackImgType, amiImgTypeAarch64, ec2ImgTypeAarch64, tarImgType, edgeCommitImgType, edgeInstallerImgType, edgeOCIImgType, edgeRawImgType, edgeSimplifiedInstallerImgType) + x86_64.addImageTypes(qcow2ImgType, vhdImgType, vmdkImgType, openstackImgType, amiImgTypeX86_64, tarImgType, tarInstallerImgTypeX86_64, edgeCommitImgType, edgeInstallerImgType, edgeOCIImgType, edgeRawImgType, edgeSimplifiedInstallerImgType) + aarch64.addImageTypes(qcow2ImgType, openstackImgType, amiImgTypeAarch64, tarImgType, edgeCommitImgType, edgeInstallerImgType, edgeOCIImgType, edgeRawImgType, edgeSimplifiedInstallerImgType) ppc64le.addImageTypes(qcow2ImgType, tarImgType) s390x.addImageTypes(qcow2ImgType, tarImgType) - rd.addArches(x86_64, aarch64, ppc64le, s390x) - return rd + if strings.HasPrefix(distroName, "rhel") { + // add ec2 image types to RHEL distro only + x86_64.addImageTypes(ec2ImgTypeX86_64, ec2HaImgTypeX86_64, ec2SapImgTypeX86_64) + aarch64.addImageTypes(ec2ImgTypeAarch64) + + // add s390x to RHEL distro only + rd.addArches(s390x) + } + rd.addArches(x86_64, aarch64, ppc64le) + return &rd } diff --git a/internal/distro/rhel86/pipelines.go b/internal/distro/rhel86/pipelines.go index cc615242a..975c75148 100644 --- a/internal/distro/rhel86/pipelines.go +++ b/internal/distro/rhel86/pipelines.go @@ -18,7 +18,7 @@ import ( func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error) { pipelines := make([]osbuild.Pipeline, 0) - pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey])) + pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner)) treePipeline, err := osPipeline(repos, packageSetSpecs[osPkgsKey], packageSetSpecs[blueprintPkgsKey], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget) if err != nil { @@ -76,7 +76,7 @@ func prependKernelCmdlineStage(pipeline *osbuild.Pipeline, t *imageType, pt *dis func vhdPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error) { pipelines := make([]osbuild.Pipeline, 0) - pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey])) + pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner)) treePipeline, err := osPipeline(repos, packageSetSpecs[osPkgsKey], packageSetSpecs[blueprintPkgsKey], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget) if err != nil { return nil, err @@ -107,7 +107,7 @@ func vhdPipelines(t *imageType, customizations *blueprint.Customizations, option func vmdkPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error) { pipelines := make([]osbuild.Pipeline, 0) - pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey])) + pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner)) treePipeline, err := osPipeline(repos, packageSetSpecs[osPkgsKey], packageSetSpecs[blueprintPkgsKey], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget) if err != nil { return nil, err @@ -138,7 +138,7 @@ func vmdkPipelines(t *imageType, customizations *blueprint.Customizations, optio func openstackPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error) { pipelines := make([]osbuild.Pipeline, 0) - pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey])) + pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner)) treePipeline, err := osPipeline(repos, packageSetSpecs[osPkgsKey], packageSetSpecs[blueprintPkgsKey], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget) if err != nil { return nil, err @@ -403,7 +403,7 @@ func ec2CommonPipelines(t *imageType, customizations *blueprint.Customizations, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand, withRHUI bool, diskfile string) ([]osbuild.Pipeline, error) { pipelines := make([]osbuild.Pipeline, 0) - pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey])) + pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner)) partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng) if err != nil { @@ -441,7 +441,7 @@ func ec2SapPipelines(t *imageType, customizations *blueprint.Customizations, opt repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand, withRHUI bool, diskfile string) ([]osbuild.Pipeline, error) { pipelines := make([]osbuild.Pipeline, 0) - pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey])) + pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner)) partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng) if err != nil { @@ -614,7 +614,7 @@ func rhelEc2SapPipelines(t *imageType, customizations *blueprint.Customizations, func tarPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error) { pipelines := make([]osbuild.Pipeline, 0) - pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey])) + pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner)) treePipeline, err := osPipeline(repos, packageSetSpecs[osPkgsKey], packageSetSpecs[blueprintPkgsKey], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget) if err != nil { @@ -640,21 +640,24 @@ func makeISORootPath(p string) string { func edgeInstallerPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error) { pipelines := make([]osbuild.Pipeline, 0) - pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey])) + pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner)) installerPackages := packageSetSpecs[installerPkgsKey] - kernelVer := kernelVerStr(installerPackages, "kernel", t.Arch().Name()) + d := t.arch.distro + archName := t.arch.name + kernelVer := kernelVerStr(installerPackages, "kernel", archName) ostreeRepoPath := "/ostree/repo" payloadStages := ostreePayloadStages(options, ostreeRepoPath) kickstartOptions := ostreeKickstartStageOptions(makeISORootPath(ostreeRepoPath), options.OSTree.Ref) - pipelines = append(pipelines, *anacondaTreePipeline(repos, installerPackages, kernelVer, t.Arch().Name())) - pipelines = append(pipelines, *bootISOTreePipeline(kernelVer, t.Arch().Name(), kickstartOptions, payloadStages)) - pipelines = append(pipelines, *bootISOPipeline(t.Filename(), t.Arch().Name(), false)) + pipelines = append(pipelines, *anacondaTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "edge")) + isolabel := fmt.Sprintf(d.isolabelTmpl, archName) + pipelines = append(pipelines, *bootISOTreePipeline(kernelVer, archName, d.vendor, d.product, d.osVersion, isolabel, kickstartOptions, payloadStages)) + pipelines = append(pipelines, *bootISOPipeline(t.Filename(), d.isolabelTmpl, archName, false)) return pipelines, nil } func tarInstallerPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error) { pipelines := make([]osbuild.Pipeline, 0) - pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey])) + pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner)) treePipeline, err := osPipeline(repos, packageSetSpecs[osPkgsKey], packageSetSpecs[blueprintPkgsKey], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget) if err != nil { @@ -679,15 +682,18 @@ func tarInstallerPipelines(t *imageType, customizations *blueprint.Customization tarPath := "/liveimg.tar" tarPayloadStages := []*osbuild.Stage{tarStage("os", tarPath)} kickstartOptions := tarKickstartStageOptions(makeISORootPath(tarPath)) - pipelines = append(pipelines, *anacondaTreePipeline(repos, installerPackages, kernelVer, t.Arch().Name())) - pipelines = append(pipelines, *bootISOTreePipeline(kernelVer, t.Arch().Name(), kickstartOptions, tarPayloadStages)) - pipelines = append(pipelines, *bootISOPipeline(t.Filename(), t.Arch().Name(), true)) + archName := t.arch.name + d := t.arch.distro + pipelines = append(pipelines, *anacondaTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "BaseOS")) + isolabel := fmt.Sprintf(d.isolabelTmpl, archName) + pipelines = append(pipelines, *bootISOTreePipeline(kernelVer, archName, d.vendor, d.product, d.osVersion, isolabel, kickstartOptions, tarPayloadStages)) + pipelines = append(pipelines, *bootISOPipeline(t.Filename(), d.isolabelTmpl, t.Arch().Name(), true)) return pipelines, nil } func edgeCorePipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec) ([]osbuild.Pipeline, error) { pipelines := make([]osbuild.Pipeline, 0) - pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey])) + pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner)) treePipeline, err := ostreeTreePipeline(repos, packageSetSpecs[osPkgsKey], packageSetSpecs[blueprintPkgsKey], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget) if err != nil { @@ -695,7 +701,7 @@ func edgeCorePipelines(t *imageType, customizations *blueprint.Customizations, o } pipelines = append(pipelines, *treePipeline) - pipelines = append(pipelines, *ostreeCommitPipeline(options)) + pipelines = append(pipelines, *ostreeCommitPipeline(options, t.arch.distro.osVersion)) return pipelines, nil } @@ -754,7 +760,7 @@ func edgeImagePipelines(t *imageType, filename string, options distro.ImageOptio func edgeRawImagePipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error) { pipelines := make([]osbuild.Pipeline, 0) - pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey])) + pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner)) imgName := t.filename @@ -769,10 +775,10 @@ func edgeRawImagePipelines(t *imageType, customizations *blueprint.Customization return pipelines, nil } -func buildPipeline(repos []rpmmd.RepoConfig, buildPackageSpecs []rpmmd.PackageSpec) *osbuild.Pipeline { +func buildPipeline(repos []rpmmd.RepoConfig, buildPackageSpecs []rpmmd.PackageSpec, runner string) *osbuild.Pipeline { p := new(osbuild.Pipeline) p.Name = "build" - p.Runner = "org.osbuild.rhel86" + p.Runner = runner p.AddStage(osbuild.NewRPMStage(rpmStageOptions(repos), rpmStageInputs(buildPackageSpecs))) p.AddStage(osbuild.NewSELinuxStage(selinuxStageOptions(true))) return p @@ -952,7 +958,7 @@ func ostreeTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, })) return p, nil } -func ostreeCommitPipeline(options distro.ImageOptions) *osbuild.Pipeline { +func ostreeCommitPipeline(options distro.ImageOptions, osVersion string) *osbuild.Pipeline { p := new(osbuild.Pipeline) p.Name = "ostree-commit" p.Build = "name:build" @@ -1047,7 +1053,7 @@ func ostreePayloadStages(options distro.ImageOptions, ostreeRepoPath string) []* func edgeSimplifiedInstallerPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error) { pipelines := make([]osbuild.Pipeline, 0) - pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey])) + pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner)) installerPackages := packageSetSpecs[installerPkgsKey] kernelVer := kernelVerStr(installerPackages, "kernel", t.Arch().Name()) imgName := "disk.img.xz" @@ -1062,12 +1068,15 @@ func edgeSimplifiedInstallerPipelines(t *imageType, customizations *blueprint.Cu pipelines = append(pipelines, imagePipelines...) // create boot ISO with raw image - installerTreePipeline := simplifiedInstallerTreePipeline(repos, installerPackages, kernelVer, t.Arch().Name()) - efibootTreePipeline := simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, t.Arch().Name()) + d := t.arch.distro + archName := t.arch.name + installerTreePipeline := simplifiedInstallerTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "edge") + isolabel := fmt.Sprintf(d.isolabelTmpl, archName) + efibootTreePipeline := simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, archName, d.vendor, d.product, d.osVersion, isolabel) bootISOTreePipeline := simplifiedInstallerBootISOTreePipeline(imgPipelineName, kernelVer) pipelines = append(pipelines, *installerTreePipeline, *efibootTreePipeline, *bootISOTreePipeline) - pipelines = append(pipelines, *bootISOPipeline(t.Filename(), t.Arch().Name(), false)) + pipelines = append(pipelines, *bootISOPipeline(t.Filename(), d.isolabelTmpl, t.Arch().Name(), false)) return pipelines, nil } @@ -1165,61 +1174,23 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string) *o return p } -func simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, arch string) *osbuild.Pipeline { +func simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, arch, vendor, product, osVersion, isolabel string) *osbuild.Pipeline { p := new(osbuild.Pipeline) p.Name = "efiboot-tree" p.Build = "name:build" - - isolabel := fmt.Sprintf("RHEL-8-6-0-BaseOS-%s", arch) - - var architectures []string - - if arch == "x86_64" { - architectures = []string{"IA32", "X64"} - } else if arch == "aarch64" { - architectures = []string{"AA64"} - } else { - panic("unsupported architecture") - } - - p.AddStage(osbuild.NewGrubISOStage( - &osbuild.GrubISOStageOptions{ - Product: osbuild.Product{ - Name: "Red Hat Enterprise Linux", - Version: osVersion, - }, - ISOLabel: isolabel, - Kernel: osbuild.ISOKernel{ - Dir: "/images/pxeboot", - Opts: []string{"rd.neednet=1", - "console=tty0", - "console=ttyS0", - "systemd.log_target=console", - "systemd.journald.forward_to_console=1", - "edge.liveiso=" + isolabel, - "coreos.inst.install_dev=" + installDevice, - "coreos.inst.image_file=/run/media/iso/disk.img.xz", - "coreos.inst.insecure"}, - }, - Architectures: architectures, - Vendor: "redhat", - }, - )) - + p.AddStage(osbuild.NewGrubISOStage(grubISOStageOptions(installDevice, kernelVer, arch, vendor, product, osVersion, isolabel))) return p } -func simplifiedInstallerTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, kernelVer string, arch string) *osbuild.Pipeline { +func simplifiedInstallerTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, kernelVer, arch, product, osVersion, variant string) *osbuild.Pipeline { p := new(osbuild.Pipeline) p.Name = "coi-tree" p.Build = "name:build" p.AddStage(osbuild.NewRPMStage(rpmStageOptions(repos), rpmStageInputs(packages))) - p.AddStage(osbuild.NewBuildstampStage(buildStampStageOptions(arch))) + p.AddStage(osbuild.NewBuildstampStage(buildStampStageOptions(arch, product, osVersion, variant))) p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{Language: "en_US.UTF-8"})) p.AddStage(osbuild.NewSystemdStage(systemdStageOptions([]string{"coreos-installer"}, nil, nil, ""))) - p.AddStage(osbuild.NewDracutStage(dracutStageOptions(kernelVer, arch, []string{ - "rdcore", - }))) + p.AddStage(osbuild.NewDracutStage(dracutStageOptions(kernelVer, arch, []string{"rdcore"}))) return p } @@ -1298,12 +1269,12 @@ func ostreeDeployPipeline( return p } -func anacondaTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, kernelVer string, arch string) *osbuild.Pipeline { +func anacondaTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, kernelVer, arch, product, osVersion, variant string) *osbuild.Pipeline { p := new(osbuild.Pipeline) p.Name = "anaconda-tree" p.Build = "name:build" p.AddStage(osbuild.NewRPMStage(rpmStageOptions(repos), rpmStageInputs(packages))) - p.AddStage(osbuild.NewBuildstampStage(buildStampStageOptions(arch))) + p.AddStage(osbuild.NewBuildstampStage(buildStampStageOptions(arch, product, osVersion, variant))) p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{Language: "en_US.UTF-8"})) rootPassword := "" @@ -1340,12 +1311,12 @@ func anacondaTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec return p } -func bootISOTreePipeline(kernelVer string, arch string, ksOptions *osbuild.KickstartStageOptions, payloadStages []*osbuild.Stage) *osbuild.Pipeline { +func bootISOTreePipeline(kernelVer, arch, vendor, product, osVersion, isolabel string, ksOptions *osbuild.KickstartStageOptions, payloadStages []*osbuild.Stage) *osbuild.Pipeline { p := new(osbuild.Pipeline) p.Name = "bootiso-tree" p.Build = "name:build" - p.AddStage(osbuild.NewBootISOMonoStage(bootISOMonoStageOptions(kernelVer, arch), bootISOMonoStageInputs())) + p.AddStage(osbuild.NewBootISOMonoStage(bootISOMonoStageOptions(kernelVer, arch, vendor, product, osVersion, isolabel), bootISOMonoStageInputs())) p.AddStage(osbuild.NewKickstartStage(ksOptions)) p.AddStage(osbuild.NewDiscinfoStage(discinfoStageOptions(arch))) @@ -1355,12 +1326,12 @@ func bootISOTreePipeline(kernelVer string, arch string, ksOptions *osbuild.Kicks return p } -func bootISOPipeline(filename string, arch string, isolinux bool) *osbuild.Pipeline { +func bootISOPipeline(filename, isolabel, arch string, isolinux bool) *osbuild.Pipeline { p := new(osbuild.Pipeline) p.Name = "bootiso" p.Build = "name:build" - p.AddStage(osbuild.NewXorrisofsStage(xorrisofsStageOptions(filename, arch, isolinux), xorrisofsStageInputs("bootiso-tree"))) + p.AddStage(osbuild.NewXorrisofsStage(xorrisofsStageOptions(filename, isolabel, arch, isolinux), xorrisofsStageInputs("bootiso-tree"))) p.AddStage(osbuild.NewImplantisomd5Stage(&osbuild.Implantisomd5StageOptions{Filename: filename})) return p @@ -1477,7 +1448,7 @@ func bootloaderConfigStage(t *imageType, partitionTable disk.PartitionTable, ker uefi := t.supportsUEFI() legacy := t.arch.legacy - options := grub2StageOptions(partitionTable.RootPartition(), partitionTable.BootPartition(), kernelOptions, kernel, kernelVer, uefi, legacy, install) + options := grub2StageOptions(partitionTable.RootPartition(), partitionTable.BootPartition(), kernelOptions, kernel, kernelVer, uefi, legacy, t.arch.distro.vendor, install) options.Greenboot = greenboot return osbuild.NewGRUB2Stage(options) diff --git a/internal/distro/rhel86/stage_options.go b/internal/distro/rhel86/stage_options.go index 65aa3f6f6..b93f4ddea 100644 --- a/internal/distro/rhel86/stage_options.go +++ b/internal/distro/rhel86/stage_options.go @@ -147,12 +147,12 @@ func systemdStageOptions(enabledServices, disabledServices []string, s *blueprin } } -func buildStampStageOptions(arch string) *osbuild.BuildstampStageOptions { +func buildStampStageOptions(arch, product, osVersion, variant string) *osbuild.BuildstampStageOptions { return &osbuild.BuildstampStageOptions{ Arch: arch, - Product: "Red Hat Enterprise Linux", + Product: product, Version: osVersion, - Variant: "edge", + Variant: variant, Final: true, } } @@ -259,13 +259,11 @@ func ostreeKickstartStageOptions(ostreeURL, ostreeRef string) *osbuild.Kickstart } } -func bootISOMonoStageOptions(kernelVer string, arch string) *osbuild.BootISOMonoStageOptions { +func bootISOMonoStageOptions(kernelVer, arch, vendor, product, osVersion, isolabel string) *osbuild.BootISOMonoStageOptions { comprOptions := new(osbuild.FSCompressionOptions) if bcj := osbuild.BCJOption(arch); bcj != "" { comprOptions.BCJ = bcj } - isolabel := fmt.Sprintf("RHEL-8-6-0-BaseOS-%s", arch) - var architectures []string if arch == distro.X86_64ArchName { @@ -278,7 +276,7 @@ func bootISOMonoStageOptions(kernelVer string, arch string) *osbuild.BootISOMono return &osbuild.BootISOMonoStageOptions{ Product: osbuild.Product{ - Name: "Red Hat Enterprise Linux", + Name: product, Version: osVersion, }, ISOLabel: isolabel, @@ -286,7 +284,7 @@ func bootISOMonoStageOptions(kernelVer string, arch string) *osbuild.BootISOMono KernelOpts: fmt.Sprintf("inst.ks=hd:LABEL=%s:%s", isolabel, kspath), EFI: osbuild.EFI{ Architectures: architectures, - Vendor: "redhat", + Vendor: vendor, }, ISOLinux: osbuild.ISOLinux{ Enabled: arch == distro.X86_64ArchName, @@ -303,6 +301,40 @@ func bootISOMonoStageOptions(kernelVer string, arch string) *osbuild.BootISOMono } } +func grubISOStageOptions(installDevice, kernelVer, arch, vendor, product, osVersion, isolabel string) *osbuild.GrubISOStageOptions { + var architectures []string + + if arch == "x86_64" { + architectures = []string{"IA32", "X64"} + } else if arch == "aarch64" { + architectures = []string{"AA64"} + } else { + panic("unsupported architecture") + } + + return &osbuild.GrubISOStageOptions{ + Product: osbuild.Product{ + Name: product, + Version: osVersion, + }, + ISOLabel: isolabel, + Kernel: osbuild.ISOKernel{ + Dir: "/images/pxeboot", + Opts: []string{"rd.neednet=1", + "console=tty0", + "console=ttyS0", + "systemd.log_target=console", + "systemd.journald.forward_to_console=1", + "edge.liveiso=" + isolabel, + "coreos.inst.install_dev=" + installDevice, + "coreos.inst.image_file=/run/media/iso/disk.img.xz", + "coreos.inst.insecure"}, + }, + Architectures: architectures, + Vendor: vendor, + } +} + func discinfoStageOptions(arch string) *osbuild.DiscinfoStageOptions { return &osbuild.DiscinfoStageOptions{ BaseArch: arch, @@ -310,10 +342,10 @@ func discinfoStageOptions(arch string) *osbuild.DiscinfoStageOptions { } } -func xorrisofsStageOptions(filename string, arch string, isolinux bool) *osbuild.XorrisofsStageOptions { +func xorrisofsStageOptions(filename, isolabel, arch string, isolinux bool) *osbuild.XorrisofsStageOptions { options := &osbuild.XorrisofsStageOptions{ Filename: filename, - VolID: fmt.Sprintf("RHEL-8-6-0-BaseOS-%s", arch), + VolID: fmt.Sprintf(isolabel, arch), SysID: "LINUX", EFI: "images/efiboot.img", } @@ -330,8 +362,15 @@ func xorrisofsStageOptions(filename string, arch string, isolinux bool) *osbuild return options } -func grub2StageOptions(rootPartition *disk.Partition, bootPartition *disk.Partition, kernelOptions string, - kernel *blueprint.KernelCustomization, kernelVer string, uefi bool, legacy string, install bool) *osbuild.GRUB2StageOptions { +func grub2StageOptions(rootPartition *disk.Partition, + bootPartition *disk.Partition, + kernelOptions string, + kernel *blueprint.KernelCustomization, + kernelVer string, + uefi bool, + legacy string, + vendor string, + install bool) *osbuild.GRUB2StageOptions { if rootPartition == nil { panic("root partition must be defined for grub2 stage, this is a programming error") } @@ -349,7 +388,7 @@ func grub2StageOptions(rootPartition *disk.Partition, bootPartition *disk.Partit if uefi { stageOptions.UEFI = &osbuild.GRUB2UEFI{ - Vendor: "redhat", + Vendor: vendor, Install: install, } } diff --git a/internal/distroregistry/distroregistry.go b/internal/distroregistry/distroregistry.go index f9a8a16df..fa22b2947 100644 --- a/internal/distroregistry/distroregistry.go +++ b/internal/distroregistry/distroregistry.go @@ -23,9 +23,9 @@ var supportedDistros = []supportedDistro{ {fedora33.NewF36, fedora33.NewHostDistro}, {rhel8.New, rhel8.NewHostDistro}, {rhel84.New, rhel84.NewHostDistro}, - {rhel84.NewCentos, rhel84.NewCentosHostDistro}, {rhel85.New, rhel85.NewHostDistro}, {rhel86.New, rhel86.NewHostDistro}, + {rhel86.NewCentos, rhel86.NewCentosHostDistro}, {rhel90beta.New, rhel90beta.NewHostDistro}, {rhel90beta.NewRHEL90, rhel90beta.NewHostDistro}, }