distro/rhel9: update distribution implementation
Update the implementation of the distro.Distro interface to match the one in Fedora. The main change is that the runner is a runner.Runner and not a string. The distroMap is replaced by two functions that initialise a distribution struct from a template (one for CentOS and one for RHEL).
This commit is contained in:
parent
310578757a
commit
7bcbab0ba5
4 changed files with 79 additions and 79 deletions
|
|
@ -237,7 +237,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 {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"math/rand"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
|
|
@ -17,6 +18,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 (
|
||||
|
|
@ -71,12 +73,12 @@ type distribution struct {
|
|||
vendor string
|
||||
ostreeRefTmpl string
|
||||
isolabelTmpl string
|
||||
runner string
|
||||
runner runner.Runner
|
||||
arches map[string]distro.Arch
|
||||
defaultImageConfig *distro.ImageConfig
|
||||
}
|
||||
|
||||
// RHEL-based OS image configuration defaults
|
||||
// CentOS- and RHEL-based OS image configuration defaults
|
||||
var defaultDistroImageConfig = &distro.ImageConfig{
|
||||
Timezone: common.StringToPtr("America/New_York"),
|
||||
Locale: common.StringToPtr("C.UTF-8"),
|
||||
|
|
@ -94,56 +96,34 @@ var defaultDistroImageConfig = &distro.ImageConfig{
|
|||
},
|
||||
}
|
||||
|
||||
// distribution objects without the arches > image types
|
||||
var distroMap = map[string]distribution{
|
||||
"rhel-90": {
|
||||
name: "rhel-90",
|
||||
product: "Red Hat Enterprise Linux",
|
||||
osVersion: "9.0",
|
||||
releaseVersion: "9",
|
||||
modulePlatformID: "platform:el9",
|
||||
vendor: "redhat",
|
||||
ostreeRefTmpl: "rhel/9/%s/edge",
|
||||
isolabelTmpl: "RHEL-9-0-0-BaseOS-%s",
|
||||
runner: "org.osbuild.rhel90",
|
||||
defaultImageConfig: defaultDistroImageConfig,
|
||||
},
|
||||
"rhel-91": {
|
||||
name: "rhel-91",
|
||||
product: "Red Hat Enterprise Linux",
|
||||
osVersion: "9.1",
|
||||
releaseVersion: "9",
|
||||
modulePlatformID: "platform:el9",
|
||||
vendor: "redhat",
|
||||
ostreeRefTmpl: "rhel/9/%s/edge",
|
||||
isolabelTmpl: "RHEL-9-1-0-BaseOS-%s",
|
||||
runner: "org.osbuild.rhel91",
|
||||
defaultImageConfig: defaultDistroImageConfig,
|
||||
},
|
||||
"rhel-92": {
|
||||
name: "rhel-92",
|
||||
product: "Red Hat Enterprise Linux",
|
||||
osVersion: "9.2",
|
||||
releaseVersion: "9",
|
||||
modulePlatformID: "platform:el9",
|
||||
vendor: "redhat",
|
||||
ostreeRefTmpl: "rhel/9/%s/edge",
|
||||
isolabelTmpl: "RHEL-9-2-0-BaseOS-%s",
|
||||
runner: "org.osbuild.rhel92",
|
||||
defaultImageConfig: defaultDistroImageConfig,
|
||||
},
|
||||
"centos-9": {
|
||||
name: "centos-9",
|
||||
func getCentOSDistro(version int) distribution {
|
||||
return distribution{
|
||||
name: fmt.Sprintf("centos-%d", version),
|
||||
product: "CentOS Stream",
|
||||
osVersion: "9-stream",
|
||||
releaseVersion: "9",
|
||||
modulePlatformID: "platform:el9",
|
||||
osVersion: fmt.Sprintf("%d-stream", version),
|
||||
releaseVersion: strconv.Itoa(version),
|
||||
modulePlatformID: fmt.Sprintf("platform:el%d", version),
|
||||
vendor: "centos",
|
||||
ostreeRefTmpl: "centos/9/%s/edge",
|
||||
isolabelTmpl: "CentOS-Stream-9-BaseOS-%s",
|
||||
runner: "org.osbuild.centos9",
|
||||
ostreeRefTmpl: fmt.Sprintf("centos/%d/%%s/edge", version),
|
||||
isolabelTmpl: fmt.Sprintf("CentOS-Stream-%d-BaseOS-%%s", version),
|
||||
runner: &runner.CentOS{Version: uint64(version)},
|
||||
defaultImageConfig: defaultDistroImageConfig,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func getRHELDistro(major, minor int) distribution {
|
||||
return distribution{
|
||||
name: fmt.Sprintf("rhel-%d%d", major, minor),
|
||||
product: "Red Hat Enterprise Linux",
|
||||
osVersion: fmt.Sprintf("%d.%d", major, minor),
|
||||
releaseVersion: strconv.Itoa(major),
|
||||
modulePlatformID: fmt.Sprintf("platform:el%d", major),
|
||||
vendor: "redhat",
|
||||
ostreeRefTmpl: fmt.Sprintf("rhel/%d/%%s/edge", major),
|
||||
isolabelTmpl: fmt.Sprintf("RHEL-%d-%d-0-BaseOS-%%s", major, minor),
|
||||
runner: &runner.RHEL{Major: uint64(major), Minor: uint64(minor)},
|
||||
defaultImageConfig: defaultDistroImageConfig,
|
||||
}
|
||||
}
|
||||
|
||||
func (d *distribution) Name() string {
|
||||
|
|
@ -640,41 +620,61 @@ func (t *imageType) checkOptions(customizations *blueprint.Customizations, optio
|
|||
return nil
|
||||
}
|
||||
|
||||
// New creates a new distro object, defining the supported architectures and image types
|
||||
func New() distro.Distro {
|
||||
return newDistro("rhel-90")
|
||||
return NewRHEL90()
|
||||
}
|
||||
|
||||
func NewHostDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
||||
return newDistro("rhel-90")
|
||||
// NOTE: args are ignored - host distro constructors are deprecated
|
||||
return NewRHEL90()
|
||||
}
|
||||
|
||||
func NewCentOS9() distro.Distro {
|
||||
return newDistro("centos", 9, 0)
|
||||
}
|
||||
|
||||
func NewCentOS9HostDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
||||
// NOTE: args are ignored - host distro constructors are deprecated
|
||||
return NewCentOS9()
|
||||
}
|
||||
|
||||
func NewRHEL90() distro.Distro {
|
||||
return newDistro("rhel", 9, 0)
|
||||
}
|
||||
|
||||
func NewRHEL90HostDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
||||
// NOTE: args are ignored - host distro constructors are deprecated
|
||||
return NewRHEL90()
|
||||
}
|
||||
|
||||
func NewRHEL91() distro.Distro {
|
||||
return newDistro("rhel-91")
|
||||
return newDistro("rhel", 9, 1)
|
||||
}
|
||||
|
||||
func NewRHEL91HostDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
||||
return newDistro("rhel-91")
|
||||
// NOTE: args are ignored - host distro constructors are deprecated
|
||||
return NewRHEL91()
|
||||
}
|
||||
|
||||
func NewRHEL92() distro.Distro {
|
||||
return newDistro("rhel-92")
|
||||
return newDistro("rhel", 9, 2)
|
||||
}
|
||||
|
||||
func NewRHEL92HostDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
||||
return newDistro("rhel-92")
|
||||
// NOTE: args are ignored - host distro constructors are deprecated
|
||||
return NewRHEL92()
|
||||
}
|
||||
|
||||
func NewCentos() distro.Distro {
|
||||
return newDistro("centos-9")
|
||||
}
|
||||
|
||||
func NewCentosHostDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
||||
return newDistro("centos-9")
|
||||
}
|
||||
|
||||
func newDistro(distroName string) distro.Distro {
|
||||
rd := distroMap[distroName]
|
||||
func newDistro(name string, major, minor int) distro.Distro {
|
||||
var rd distribution
|
||||
switch name {
|
||||
case "rhel":
|
||||
rd = getRHELDistro(major, minor)
|
||||
case "centos":
|
||||
rd = getCentOSDistro(major)
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown distro name: %s", name))
|
||||
}
|
||||
|
||||
// Architecture definitions
|
||||
x86_64 := architecture{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,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, kernelOptions string,
|
|||
|
||||
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 {
|
||||
|
|
@ -81,7 +81,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 {
|
||||
|
|
@ -108,7 +108,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 {
|
||||
|
|
@ -149,7 +149,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 {
|
||||
|
|
@ -183,7 +183,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 {
|
||||
|
|
@ -204,7 +204,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()
|
||||
|
|
@ -225,7 +225,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 {
|
||||
|
|
@ -265,7 +265,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 {
|
||||
|
|
@ -328,7 +328,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
|
||||
|
||||
|
|
@ -758,7 +758,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 := "disk.img.xz"
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ var supportedDistros = []supportedDistro{
|
|||
{rhel9.New, rhel9.NewHostDistro},
|
||||
{rhel9.NewRHEL91, rhel9.NewRHEL91HostDistro},
|
||||
{rhel9.NewRHEL92, rhel9.NewRHEL92HostDistro},
|
||||
{rhel9.NewCentos, rhel9.NewCentosHostDistro},
|
||||
{rhel9.NewCentOS9, rhel9.NewCentOS9HostDistro},
|
||||
}
|
||||
|
||||
type supportedDistro struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue