diff --git a/cmd/osbuild-playground/playground.go b/cmd/osbuild-playground/playground.go index f0e4c7593..97579d54f 100644 --- a/cmd/osbuild-playground/playground.go +++ b/cmd/osbuild-playground/playground.go @@ -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", } diff --git a/internal/distro/fedora/pipelines.go b/internal/distro/fedora/pipelines.go index c0191852b..bc40c1eaf 100644 --- a/internal/distro/fedora/pipelines.go +++ b/internal/distro/fedora/pipelines.go @@ -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) diff --git a/internal/manifest/live.go b/internal/manifest/live.go index 6e178a4dd..1260704b9 100644 --- a/internal/manifest/live.go +++ b/internal/manifest/live.go @@ -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 diff --git a/internal/manifest/manifest.go b/internal/manifest/manifest.go index 07fa34c8b..d6ad42a9a 100644 --- a/internal/manifest/manifest.go +++ b/internal/manifest/manifest.go @@ -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 diff --git a/internal/manifest/os.go b/internal/manifest/os.go index 8b5b715df..06064bee3 100644 --- a/internal/manifest/os.go +++ b/internal/manifest/os.go @@ -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)