distro/rhel8: update distribution implementation
Update the implementation of the distro.Distro interface to match the one in RHEL 9 and Fedora. The main change is that the runner is a runner.Runner and not a string. The distroMap is replaced by a switch that initialises the distribution struct strings based on the minor version number. The default minor version, created with rhel8.New(), creates a copy of RHEL 8.6 and renames it to "rhel8".
This commit is contained in:
parent
560756a164
commit
1a73e08905
3 changed files with 64 additions and 117 deletions
|
|
@ -257,7 +257,7 @@ var azureRhuiBasePartitionTables = distro.BasePartitionTableMap{
|
|||
func vhdPipelines(compress bool) pipelinesFunc {
|
||||
return func(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, containers []container.Spec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
|
||||
pipelines := make([]osbuild.Pipeline, 0)
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner))
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner.String()))
|
||||
|
||||
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/oscap"
|
||||
"github.com/osbuild/osbuild-composer/internal/ostree"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/runner"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -69,7 +70,7 @@ type distribution struct {
|
|||
vendor string
|
||||
ostreeRefTmpl string
|
||||
isolabelTmpl string
|
||||
runner string
|
||||
runner runner.Runner
|
||||
arches map[string]distro.Arch
|
||||
defaultImageConfig *distro.ImageConfig
|
||||
}
|
||||
|
|
@ -92,94 +93,6 @@ var defaultDistroImageConfig = &distro.ImageConfig{
|
|||
},
|
||||
}
|
||||
|
||||
// distribution objects without the arches > image types
|
||||
var distroMap = map[string]distribution{
|
||||
"rhel-8": {
|
||||
name: "rhel-8",
|
||||
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",
|
||||
defaultImageConfig: defaultDistroImageConfig,
|
||||
},
|
||||
"rhel-84": {
|
||||
name: "rhel-84",
|
||||
product: "Red Hat Enterprise Linux",
|
||||
osVersion: "8.4",
|
||||
releaseVersion: "8",
|
||||
modulePlatformID: "platform:el8",
|
||||
vendor: "redhat",
|
||||
ostreeRefTmpl: "rhel/8/%s/edge",
|
||||
isolabelTmpl: "RHEL-8-4-0-BaseOS-%s",
|
||||
runner: "org.osbuild.rhel84",
|
||||
defaultImageConfig: defaultDistroImageConfig,
|
||||
},
|
||||
"rhel-85": {
|
||||
name: "rhel-85",
|
||||
product: "Red Hat Enterprise Linux",
|
||||
osVersion: "8.5",
|
||||
releaseVersion: "8",
|
||||
modulePlatformID: "platform:el8",
|
||||
vendor: "redhat",
|
||||
ostreeRefTmpl: "rhel/8/%s/edge",
|
||||
isolabelTmpl: "RHEL-8-5-0-BaseOS-%s",
|
||||
runner: "org.osbuild.rhel85",
|
||||
defaultImageConfig: defaultDistroImageConfig,
|
||||
},
|
||||
"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",
|
||||
defaultImageConfig: defaultDistroImageConfig,
|
||||
},
|
||||
"rhel-87": {
|
||||
name: "rhel-87",
|
||||
product: "Red Hat Enterprise Linux",
|
||||
osVersion: "8.7",
|
||||
releaseVersion: "8",
|
||||
modulePlatformID: "platform:el8",
|
||||
vendor: "redhat",
|
||||
ostreeRefTmpl: "rhel/8/%s/edge",
|
||||
isolabelTmpl: "RHEL-8-7-0-BaseOS-%s",
|
||||
runner: "org.osbuild.rhel87",
|
||||
defaultImageConfig: defaultDistroImageConfig,
|
||||
},
|
||||
"rhel-88": {
|
||||
name: "rhel-88",
|
||||
product: "Red Hat Enterprise Linux",
|
||||
osVersion: "8.8",
|
||||
releaseVersion: "8",
|
||||
modulePlatformID: "platform:el8",
|
||||
vendor: "redhat",
|
||||
ostreeRefTmpl: "rhel/8/%s/edge",
|
||||
isolabelTmpl: "RHEL-8-8-0-BaseOS-%s",
|
||||
runner: "org.osbuild.rhel88",
|
||||
defaultImageConfig: defaultDistroImageConfig,
|
||||
},
|
||||
"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",
|
||||
defaultImageConfig: defaultDistroImageConfig,
|
||||
},
|
||||
}
|
||||
|
||||
func (d *distribution) Name() string {
|
||||
return d.name
|
||||
}
|
||||
|
|
@ -678,63 +591,97 @@ 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("rhel-8")
|
||||
// default minor: create default minor version (current GA) and rename it
|
||||
d := newDistro("rhel", 6)
|
||||
d.name = "rhel-8"
|
||||
return d
|
||||
|
||||
}
|
||||
|
||||
func NewHostDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
||||
return newDistro("rhel-8")
|
||||
return New()
|
||||
}
|
||||
|
||||
func NewRHEL84() distro.Distro {
|
||||
return newDistro("rhel-84")
|
||||
return newDistro("rhel", 4)
|
||||
}
|
||||
|
||||
func NewRHEL84HostDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
||||
return newDistro("rhel-84")
|
||||
return NewRHEL84()
|
||||
}
|
||||
|
||||
func NewRHEL85() distro.Distro {
|
||||
return newDistro("rhel-85")
|
||||
return newDistro("rhel", 5)
|
||||
}
|
||||
|
||||
func NewRHEL85HostDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
||||
return newDistro("rhel-85")
|
||||
return NewRHEL85()
|
||||
}
|
||||
|
||||
func NewRHEL86() distro.Distro {
|
||||
return newDistro("rhel-86")
|
||||
return newDistro("rhel", 6)
|
||||
}
|
||||
|
||||
func NewRHEL86HostDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
||||
return newDistro("rhel-86")
|
||||
return NewRHEL86()
|
||||
}
|
||||
|
||||
func NewRHEL87() distro.Distro {
|
||||
return newDistro("rhel-87")
|
||||
return newDistro("rhel", 7)
|
||||
}
|
||||
|
||||
func NewRHEL87HostDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
||||
return newDistro("rhel-87")
|
||||
return NewRHEL87()
|
||||
}
|
||||
|
||||
func NewRHEL88() distro.Distro {
|
||||
return newDistro("rhel-88")
|
||||
return newDistro("rhel", 8)
|
||||
}
|
||||
|
||||
func NewRHEL88HostDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
||||
return newDistro("rhel-88")
|
||||
return NewRHEL88()
|
||||
}
|
||||
|
||||
func NewCentos() distro.Distro {
|
||||
return newDistro("centos-8")
|
||||
return newDistro("centos", 0)
|
||||
}
|
||||
|
||||
func NewCentosHostDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
||||
return newDistro("centos-8")
|
||||
return NewCentos()
|
||||
}
|
||||
|
||||
func newDistro(distroName string) distro.Distro {
|
||||
rd := distroMap[distroName]
|
||||
func newDistro(name string, minor int) *distribution {
|
||||
var rd distribution
|
||||
switch name {
|
||||
case "rhel":
|
||||
rd = distribution{
|
||||
name: fmt.Sprintf("rhel-8%d", minor),
|
||||
product: "Red Hat Enterprise Linux",
|
||||
osVersion: fmt.Sprintf("8.%d", minor),
|
||||
releaseVersion: "8",
|
||||
modulePlatformID: "platform:el8",
|
||||
vendor: "redhat",
|
||||
ostreeRefTmpl: "rhel/8/%s/edge",
|
||||
isolabelTmpl: fmt.Sprintf("RHEL-8-%d-0-BaseOS-%%s", minor),
|
||||
runner: &runner.RHEL{Major: uint64(8), Minor: uint64(minor)},
|
||||
defaultImageConfig: defaultDistroImageConfig,
|
||||
}
|
||||
case "centos":
|
||||
rd = distribution{
|
||||
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: &runner.CentOS{Version: uint64(8)},
|
||||
defaultImageConfig: defaultDistroImageConfig,
|
||||
}
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown distro name: %s", name))
|
||||
}
|
||||
|
||||
// Architecture definitions
|
||||
x86_64 := architecture{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import (
|
|||
|
||||
func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, containers []container.Spec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
|
||||
pipelines := make([]osbuild.Pipeline, 0)
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner))
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner.String()))
|
||||
|
||||
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
|
||||
if err != nil {
|
||||
|
|
@ -56,7 +56,7 @@ func prependKernelCmdlineStage(pipeline *osbuild.Pipeline, t *imageType, pt *dis
|
|||
|
||||
func vmdkPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, containers []container.Spec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
|
||||
pipelines := make([]osbuild.Pipeline, 0)
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner))
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner.String()))
|
||||
|
||||
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
|
||||
if err != nil {
|
||||
|
|
@ -84,7 +84,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, containers []container.Spec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
|
||||
pipelines := make([]osbuild.Pipeline, 0)
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner))
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner.String()))
|
||||
|
||||
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
|
||||
if err != nil {
|
||||
|
|
@ -114,7 +114,7 @@ func ec2CommonPipelines(t *imageType, customizations *blueprint.Customizations,
|
|||
repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, containers []container.Spec,
|
||||
rng *rand.Rand, diskfile string) ([]osbuild.Pipeline, error) {
|
||||
pipelines := make([]osbuild.Pipeline, 0)
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner))
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner.String()))
|
||||
|
||||
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
|
||||
if err != nil {
|
||||
|
|
@ -154,7 +154,7 @@ func rhelEc2Pipelines(t *imageType, customizations *blueprint.Customizations, op
|
|||
|
||||
func gcePipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, containers []container.Spec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
|
||||
pipelines := make([]osbuild.Pipeline, 0)
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner))
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner.String()))
|
||||
|
||||
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
|
||||
if err != nil {
|
||||
|
|
@ -188,7 +188,7 @@ func gcePipelines(t *imageType, customizations *blueprint.Customizations, option
|
|||
|
||||
func tarPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, containers []container.Spec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
|
||||
pipelines := make([]osbuild.Pipeline, 0)
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner))
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner.String()))
|
||||
|
||||
treePipeline, err := osPipeline(t, repos, packageSetSpecs[osPkgsKey], containers, customizations, options, nil)
|
||||
if err != nil {
|
||||
|
|
@ -209,7 +209,7 @@ func makeISORootPath(p string) string {
|
|||
|
||||
func edgeInstallerPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, containers []container.Spec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
|
||||
pipelines := make([]osbuild.Pipeline, 0)
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner))
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner.String()))
|
||||
installerPackages := packageSetSpecs[installerPkgsKey]
|
||||
d := t.arch.distro
|
||||
archName := t.Arch().Name()
|
||||
|
|
@ -230,7 +230,7 @@ func edgeInstallerPipelines(t *imageType, customizations *blueprint.Customizatio
|
|||
|
||||
func imageInstallerPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, containers []container.Spec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
|
||||
pipelines := make([]osbuild.Pipeline, 0)
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner))
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner.String()))
|
||||
|
||||
treePipeline, err := osPipeline(t, repos, packageSetSpecs[osPkgsKey], containers, customizations, options, nil)
|
||||
if err != nil {
|
||||
|
|
@ -270,7 +270,7 @@ func imageInstallerPipelines(t *imageType, customizations *blueprint.Customizati
|
|||
|
||||
func edgeCorePipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, containers []container.Spec) ([]osbuild.Pipeline, error) {
|
||||
pipelines := make([]osbuild.Pipeline, 0)
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner))
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner.String()))
|
||||
|
||||
treePipeline, err := osPipeline(t, repos, packageSetSpecs[osPkgsKey], containers, customizations, options, nil)
|
||||
if err != nil {
|
||||
|
|
@ -333,7 +333,7 @@ func edgeImagePipelines(t *imageType, customizations *blueprint.Customizations,
|
|||
|
||||
func edgeRawImagePipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, containers []container.Spec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
|
||||
pipelines := make([]osbuild.Pipeline, 0)
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner))
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner.String()))
|
||||
|
||||
imgName := t.filename
|
||||
|
||||
|
|
@ -776,7 +776,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, containers []container.Spec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
|
||||
pipelines := make([]osbuild.Pipeline, 0)
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner))
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner.String()))
|
||||
installerPackages := packageSetSpecs[installerPkgsKey]
|
||||
kernelVer := rpmmd.GetVerStrFromPackageSpecListPanic(installerPackages, "kernel")
|
||||
imgName := "image.raw.xz"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue