manifest/os: drop kernelName and bootLoader from New()

The kernel name is optional and can be set later.

The bootloader we skip entirely. Instead, set the architecture, which now becomes
mandatory. Use it to deduce the bootloader, and in the future other pipelines can read
this property from the OS Pipeline, rather than having it passed in.
This commit is contained in:
Tom Gundersen 2022-07-04 23:34:43 +01:00 committed by Achilleas Koutsou
parent fd5180d52d
commit de6c628069
5 changed files with 42 additions and 39 deletions

View file

@ -31,7 +31,7 @@ func MyManifest(m *manifest.Manifest, options *MyOptions, repos []rpmmd.RepoConf
build := manifest.NewBuildPipeline(m, runner, repos)
// create a non-bootable OS tree containing the `core` comps group
os := manifest.NewOSPipeline(m, build, repos, manifest.BOOTLOADER_GRUB, "")
os := manifest.NewOSPipeline(m, build, manifest.ARCH_X86_64, repos)
os.ExtraBasePackages = []string{
"@core",
}

View file

@ -209,19 +209,19 @@ func osPipeline(m *manifest.Manifest,
}
}
var bootLoader manifest.BootLoader
if t.Arch().Name() == distro.S390xArchName {
bootLoader = manifest.BOOTLOADER_ZIPL
} else {
bootLoader = manifest.BOOTLOADER_GRUB
var arch manifest.Arch
switch t.Arch().Name() {
case distro.X86_64ArchName:
arch = manifest.ARCH_X86_64
case distro.Aarch64ArchName:
arch = manifest.ARCH_AARCH64
case distro.Ppc64leArchName:
arch = manifest.ARCH_PPC64LE
case distro.S390xArchName:
arch = manifest.ARCH_S390X
}
var kernelName string
if t.bootable {
kernelName = c.GetKernel().Name
}
pl := manifest.NewOSPipeline(m, buildPipeline, repos, bootLoader, kernelName)
pl := manifest.NewOSPipeline(m, buildPipeline, arch, repos)
pl.PartitionTable = pt
if t.rpmOstree {
@ -255,6 +255,10 @@ func osPipeline(m *manifest.Manifest,
pl.BIOSPlatform = t.arch.legacy
if t.bootable {
pl.KernelName = c.GetKernel().Name
}
var kernelOptions []string
if t.kernelOptions != "" {
kernelOptions = append(kernelOptions, t.kernelOptions)

View file

@ -51,14 +51,14 @@ func (p *LiveImgPipeline) serialize() osbuild2.Pipeline {
pipeline.AddStage(stage)
}
switch p.treePipeline.bootLoader {
case BOOTLOADER_GRUB:
switch p.treePipeline.arch {
case ARCH_S390X:
loopback := osbuild2.NewLoopbackDevice(&osbuild2.LoopbackDeviceOptions{Filename: p.filename})
pipeline.AddStage(osbuild2.NewZiplInstStage(osbuild2.NewZiplInstStageOptions(p.treePipeline.kernelVer, pt), loopback, copyDevices, copyMounts))
default:
if grubLegacy := p.treePipeline.BIOSPlatform; grubLegacy != "" {
pipeline.AddStage(osbuild2.NewGrub2InstStage(osbuild2.NewGrub2InstStageOption(p.filename, pt, grubLegacy)))
}
case BOOTLOADER_ZIPL:
loopback := osbuild2.NewLoopbackDevice(&osbuild2.LoopbackDeviceOptions{Filename: p.filename})
pipeline.AddStage(osbuild2.NewZiplInstStage(osbuild2.NewZiplInstStageOptions(p.treePipeline.kernelVer, pt), loopback, copyDevices, copyMounts))
}
return pipeline

View file

@ -9,6 +9,15 @@ import (
"github.com/osbuild/osbuild-composer/internal/rpmmd"
)
type Arch uint64
const (
ARCH_X86_64 Arch = iota
ARCH_AARCH64
ARCH_S390X
ARCH_PPC64LE
)
type osTreeCommit struct {
checksum string
url string

View file

@ -12,13 +12,6 @@ import (
"github.com/osbuild/osbuild-composer/internal/rpmmd"
)
type BootLoader uint64
const (
BOOTLOADER_GRUB BootLoader = iota
BOOTLOADER_ZIPL
)
type OSPipelineOSTree struct {
Parent *OSPipelineOSTreeParent
}
@ -49,6 +42,9 @@ type OSPipeline struct {
OSTree *OSPipelineOSTree
// Partition table, if nil the tree cannot be put on a partioned disk
PartitionTable *disk.PartitionTable
// KernelName indicates that a kernel is installed, and names the kernel
// package.
KernelName string
// KernelOptionsAppend are appended to the kernel commandline
KernelOptionsAppend []string
// UEFIVendor indicates whether or not the image should support UEFI and
@ -102,8 +98,7 @@ type OSPipeline struct {
repos []rpmmd.RepoConfig
packageSpecs []rpmmd.PackageSpec
bootLoader BootLoader
kernelName string
arch Arch
kernelVer string
}
@ -115,14 +110,11 @@ type OSPipeline struct {
// kernel package that will be used on the target system.
func NewOSPipeline(m *Manifest,
buildPipeline *BuildPipeline,
repos []rpmmd.RepoConfig,
bootLoader BootLoader,
kernelName string) *OSPipeline {
arch Arch,
repos []rpmmd.RepoConfig) *OSPipeline {
p := &OSPipeline{
BasePipeline: NewBasePipeline(m, "os", buildPipeline, nil),
repos: repos,
bootLoader: bootLoader,
kernelName: kernelName,
Language: "C.UTF-8",
Hostname: "localhost.localdomain",
Timezone: "UTC",
@ -184,8 +176,8 @@ func (p *OSPipeline) serializeStart(packages []rpmmd.PackageSpec) {
panic("double call to serializeStart()")
}
p.packageSpecs = packages
if p.kernelName != "" {
p.kernelVer = rpmmd.GetVerStrFromPackageSpecListPanic(p.packageSpecs, p.kernelName)
if p.KernelName != "" {
p.kernelVer = rpmmd.GetVerStrFromPackageSpecListPanic(p.packageSpecs, p.KernelName)
}
}
@ -362,8 +354,10 @@ func (p *OSPipeline) serialize() osbuild2.Pipeline {
pipeline.AddStage(osbuild2.NewFSTabStage(osbuild2.NewFSTabStageOptions(pt)))
var bootloader *osbuild2.Stage
switch p.bootLoader {
case BOOTLOADER_GRUB:
switch p.arch {
case ARCH_S390X:
bootloader = osbuild2.NewZiplStage(new(osbuild2.ZiplStageOptions))
default:
options := osbuild2.NewGrub2StageOptionsUnified(pt, p.kernelVer, p.UEFIVendor != "", p.BIOSPlatform, p.UEFIVendor, false)
if cfg := p.Grub2Config; cfg != nil {
// TODO: don't store Grub2Config in OSPipeline, making the overrides unnecessary
@ -376,10 +370,6 @@ func (p *OSPipeline) serialize() osbuild2.Pipeline {
options.Config = cfg
}
bootloader = osbuild2.NewGRUB2Stage(options)
case BOOTLOADER_ZIPL:
bootloader = osbuild2.NewZiplStage(new(osbuild2.ZiplStageOptions))
default:
panic("unknown bootloader")
}
pipeline.AddStage(bootloader)