distro: export common types
squash unused type
This commit is contained in:
parent
ee0af8b901
commit
382b5370c0
5 changed files with 31 additions and 46 deletions
|
|
@ -11,6 +11,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/disk"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
||||
|
|
@ -136,6 +137,8 @@ type SubscriptionImageOptions struct {
|
|||
Insights bool
|
||||
}
|
||||
|
||||
type BasePartitionTableMap map[string]disk.PartitionTable
|
||||
|
||||
// A Manifest is an opaque JSON object, which is a valid input to osbuild
|
||||
type Manifest []byte
|
||||
|
||||
|
|
|
|||
|
|
@ -53,8 +53,6 @@ const (
|
|||
blueprintPkgsKey = "blueprint"
|
||||
)
|
||||
|
||||
type basePartitionTableMap map[string]disk.PartitionTable
|
||||
|
||||
var mountpointAllowList = []string{
|
||||
"/", "/var", "/var/*", "/home", "/home/*", "/opt", "/opt/*",
|
||||
"/srv", "/srv/*", "/usr", "/usr/*", "/app", "/app/*",
|
||||
|
|
@ -203,7 +201,7 @@ type imageType struct {
|
|||
// If set to a value, it is preferred over the architecture value
|
||||
bootType distro.BootType
|
||||
// List of valid arches for the image type
|
||||
basePartitionTables basePartitionTableMap
|
||||
basePartitionTables distro.BasePartitionTableMap
|
||||
}
|
||||
|
||||
func (t *imageType) Name() string {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
)
|
||||
|
||||
var defaultBasePartitionTables = basePartitionTableMap{
|
||||
var defaultBasePartitionTables = distro.BasePartitionTableMap{
|
||||
distro.X86_64ArchName: disk.PartitionTable{
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
|
|
@ -112,7 +112,7 @@ var defaultBasePartitionTables = basePartitionTableMap{
|
|||
},
|
||||
}
|
||||
|
||||
var ec2BasePartitionTables = basePartitionTableMap{
|
||||
var ec2BasePartitionTables = distro.BasePartitionTableMap{
|
||||
distro.X86_64ArchName: disk.PartitionTable{
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
|
|
|
|||
|
|
@ -50,24 +50,6 @@ const (
|
|||
blueprintPkgsKey = "blueprint"
|
||||
)
|
||||
|
||||
const (
|
||||
// architecture names
|
||||
|
||||
x86_64ArchName = "x86_64"
|
||||
aarch64ArchName = "aarch64"
|
||||
ppc64leArchName = "ppc64le"
|
||||
s390xArchName = "s390x"
|
||||
)
|
||||
|
||||
type BootType string
|
||||
|
||||
const (
|
||||
UnsetBootType BootType = ""
|
||||
LegacyBootType BootType = "legacy"
|
||||
UEFIBootType BootType = "uefi"
|
||||
HybridBootType BootType = "hybrid"
|
||||
)
|
||||
|
||||
type distribution struct {
|
||||
name string
|
||||
modulePlatformID string
|
||||
|
|
@ -129,7 +111,7 @@ type architecture struct {
|
|||
imageTypeAliases map[string]string
|
||||
packageSets map[string]rpmmd.PackageSet
|
||||
legacy string
|
||||
bootType BootType
|
||||
bootType distro.BootType
|
||||
}
|
||||
|
||||
func (a *architecture) Name() string {
|
||||
|
|
@ -208,7 +190,9 @@ type imageType struct {
|
|||
// bootable image
|
||||
bootable bool
|
||||
// If set to a value, it is preferred over the architecture value
|
||||
bootType BootType
|
||||
bootType distro.BootType
|
||||
// List of valid arches for the image type
|
||||
basePartitionTables distro.BasePartitionTableMap
|
||||
}
|
||||
|
||||
func (t *imageType) Name() string {
|
||||
|
|
@ -275,11 +259,11 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint) map[string]rpmmd.Package
|
|||
var addUEFIBootPkg bool
|
||||
|
||||
switch bt := t.getBootType(); bt {
|
||||
case LegacyBootType:
|
||||
case distro.LegacyBootType:
|
||||
addLegacyBootPkg = true
|
||||
case UEFIBootType:
|
||||
case distro.UEFIBootType:
|
||||
addUEFIBootPkg = true
|
||||
case HybridBootType:
|
||||
case distro.HybridBootType:
|
||||
addLegacyBootPkg = true
|
||||
addUEFIBootPkg = true
|
||||
default:
|
||||
|
|
@ -326,9 +310,9 @@ func (t *imageType) Exports() []string {
|
|||
|
||||
// getBootType returns the BootType which should be used for this particular
|
||||
// combination of architecture and image type.
|
||||
func (t *imageType) getBootType() BootType {
|
||||
func (t *imageType) getBootType() distro.BootType {
|
||||
bootType := t.arch.bootType
|
||||
if t.bootType != UnsetBootType {
|
||||
if t.bootType != distro.UnsetBootType {
|
||||
bootType = t.bootType
|
||||
}
|
||||
return bootType
|
||||
|
|
@ -336,7 +320,7 @@ func (t *imageType) getBootType() BootType {
|
|||
|
||||
func (t *imageType) supportsUEFI() bool {
|
||||
bootType := t.getBootType()
|
||||
if bootType == HybridBootType || bootType == UEFIBootType {
|
||||
if bootType == distro.HybridBootType || bootType == distro.UEFIBootType {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
|
@ -478,7 +462,7 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
|||
|
||||
// Architecture definitions
|
||||
x86_64 := architecture{
|
||||
name: x86_64ArchName,
|
||||
name: distro.X86_64ArchName,
|
||||
distro: rd,
|
||||
packageSets: map[string]rpmmd.PackageSet{
|
||||
buildPkgsKey: x8664BuildPackageSet(),
|
||||
|
|
@ -487,36 +471,36 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
|||
edgePkgsKey: x8664EdgeCommitPackageSet(),
|
||||
},
|
||||
legacy: "i386-pc",
|
||||
bootType: HybridBootType,
|
||||
bootType: distro.HybridBootType,
|
||||
}
|
||||
|
||||
aarch64 := architecture{
|
||||
name: aarch64ArchName,
|
||||
name: distro.Aarch64ArchName,
|
||||
distro: rd,
|
||||
packageSets: map[string]rpmmd.PackageSet{
|
||||
bootUEFIPkgsKey: aarch64UEFIBootPackageSet(),
|
||||
edgePkgsKey: aarch64EdgeCommitPackageSet(),
|
||||
},
|
||||
bootType: UEFIBootType,
|
||||
bootType: distro.UEFIBootType,
|
||||
}
|
||||
|
||||
ppc64le := architecture{
|
||||
distro: rd,
|
||||
name: ppc64leArchName,
|
||||
name: distro.Ppc64leArchName,
|
||||
packageSets: map[string]rpmmd.PackageSet{
|
||||
bootLegacyPkgsKey: ppc64leLegacyBootPackageSet(),
|
||||
buildPkgsKey: ppc64leBuildPackageSet(),
|
||||
},
|
||||
legacy: "powerpc-ieee1275",
|
||||
bootType: LegacyBootType,
|
||||
bootType: distro.LegacyBootType,
|
||||
}
|
||||
s390x := architecture{
|
||||
distro: rd,
|
||||
name: s390xArchName,
|
||||
name: distro.S390xArchName,
|
||||
packageSets: map[string]rpmmd.PackageSet{
|
||||
bootLegacyPkgsKey: s390xLegacyBootPackageSet(),
|
||||
},
|
||||
bootType: LegacyBootType,
|
||||
bootType: distro.LegacyBootType,
|
||||
}
|
||||
|
||||
// Shared Services
|
||||
|
|
@ -666,7 +650,7 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
|||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
bootable: true,
|
||||
bootType: LegacyBootType,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: ec2Pipelines,
|
||||
exports: []string{"image"},
|
||||
|
|
@ -701,7 +685,7 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
|||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
bootable: true,
|
||||
bootType: LegacyBootType,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
exports: []string{"archive"},
|
||||
|
|
@ -736,7 +720,7 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
|||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
bootable: true,
|
||||
bootType: LegacyBootType,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
exports: []string{"archive"},
|
||||
|
|
|
|||
|
|
@ -396,10 +396,10 @@ func ec2CommonPipelines(t *imageType, customizations *blueprint.Customizations,
|
|||
var err error
|
||||
switch arch := t.arch.Name(); arch {
|
||||
// rhel-ec2-x86_64, rhel-ha-ec2
|
||||
case x86_64ArchName:
|
||||
case distro.X86_64ArchName:
|
||||
treePipeline, err = ec2X86_64BaseTreePipeline(repos, packageSetSpecs[osPkgsKey], packageSetSpecs[blueprintPkgsKey], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget, withRHUI, &partitionTable)
|
||||
// rhel-ec2-aarch64
|
||||
case aarch64ArchName:
|
||||
case distro.Aarch64ArchName:
|
||||
treePipeline, err = ec2BaseTreePipeline(repos, packageSetSpecs[osPkgsKey], packageSetSpecs[blueprintPkgsKey], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget, withRHUI, &partitionTable)
|
||||
default:
|
||||
return nil, fmt.Errorf("ec2CommonPipelines: unsupported image architecture: %q", arch)
|
||||
|
|
@ -973,7 +973,7 @@ func qemuPipeline(inputPipelineName, inputFilename, outputFilename, format, qcow
|
|||
}
|
||||
|
||||
func bootloaderConfigStage(t *imageType, partitionTable disk.PartitionTable, kernel *blueprint.KernelCustomization, kernelVer string) *osbuild.Stage {
|
||||
if t.arch.name == s390xArchName {
|
||||
if t.arch.name == distro.S390xArchName {
|
||||
return osbuild.NewZiplStage(new(osbuild.ZiplStageOptions))
|
||||
}
|
||||
|
||||
|
|
@ -989,7 +989,7 @@ func bootloaderInstStage(filename string, pt *disk.PartitionTable, arch *archite
|
|||
return osbuild.NewGrub2InstStage(grub2InstStageOptions(filename, pt, platform))
|
||||
}
|
||||
|
||||
if arch.name == s390xArchName {
|
||||
if arch.name == distro.S390xArchName {
|
||||
return osbuild.NewZiplInstStage(ziplInstStageOptions(kernelVer, pt), disk, devices, mounts)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue