distro/rhel90: copy devices and mounts changes

Rebase brings RHEL 9.0 definition with old Mounts and Devices. Changes
applied to new distro pipelines and stage options.
This commit is contained in:
Achilleas Koutsou 2021-08-18 13:07:46 +02:00 committed by Tom Gundersen
parent 745443181e
commit 321dcc56bf
2 changed files with 15 additions and 26 deletions

View file

@ -873,10 +873,10 @@ func liveImagePipeline(inputPipelineName string, outputFilename string, pt *disk
p.Name = "image"
p.Build = "name:build"
loopback := osbuild.NewLoopbackDevice(&osbuild.LoopbackDeviceOptions{Filename: outputFilename})
p.AddStage(osbuild.NewTruncateStage(&osbuild.TruncateStageOptions{Filename: outputFilename, Size: fmt.Sprintf("%d", pt.Size)}))
sfOptions, sfDevices := sfdiskStageOptions(pt, loopback)
p.AddStage(osbuild.NewSfdiskStage(sfOptions, sfDevices))
sfOptions := sfdiskStageOptions(pt)
loopback := osbuild.NewLoopbackDevice(&osbuild.LoopbackDeviceOptions{Filename: outputFilename})
p.AddStage(osbuild.NewSfdiskStage(sfOptions, loopback))
for _, stage := range mkfsStages(pt, loopback) {
p.AddStage(stage)
@ -934,28 +934,24 @@ func mkfsStages(pt *disk.PartitionTable, device *osbuild.Device) []*osbuild2.Sta
UUID: p.Filesystem.UUID,
Label: p.Filesystem.Label,
}
devices := &osbuild.MkfsXfsStageDevices{Device: *stageDevice}
stage = osbuild.NewMkfsXfsStage(options, devices)
stage = osbuild.NewMkfsXfsStage(options, stageDevice)
case "vfat":
options := &osbuild.MkfsFATStageOptions{
VolID: strings.Replace(p.Filesystem.UUID, "-", "", -1),
}
devices := &osbuild.MkfsFATStageDevices{Device: *stageDevice}
stage = osbuild.NewMkfsFATStage(options, devices)
stage = osbuild.NewMkfsFATStage(options, stageDevice)
case "btrfs":
options := &osbuild.MkfsBtrfsStageOptions{
UUID: p.Filesystem.UUID,
Label: p.Filesystem.Label,
}
devices := &osbuild.MkfsBtrfsStageDevices{Device: *stageDevice}
stage = osbuild.NewMkfsBtrfsStage(options, devices)
stage = osbuild.NewMkfsBtrfsStage(options, stageDevice)
case "ext4":
options := &osbuild.MkfsExt4StageOptions{
UUID: p.Filesystem.UUID,
Label: p.Filesystem.Label,
}
devices := &osbuild.MkfsExt4StageDevices{Device: *stageDevice}
stage = osbuild.NewMkfsExt4Stage(options, devices)
stage = osbuild.NewMkfsExt4Stage(options, stageDevice)
default:
panic("unknown fs type " + p.Type)
}
@ -985,17 +981,14 @@ func bootloaderConfigStage(t *imageType, partitionTable disk.PartitionTable, ker
return osbuild.NewGRUB2Stage(grub2StageOptions(partitionTable.RootPartition(), partitionTable.BootPartition(), kernelOptions, kernel, kernelVer, uefi, legacy))
}
func bootloaderInstStage(filename string, pt *disk.PartitionTable, arch *architecture, kernelVer string, devices *osbuild.CopyStageDevices, mounts *osbuild.CopyStageMounts, disk *osbuild.Device) *osbuild.Stage {
func bootloaderInstStage(filename string, pt *disk.PartitionTable, arch *architecture, kernelVer string, devices *osbuild.Devices, mounts *osbuild.Mounts, disk *osbuild.Device) *osbuild.Stage {
platform := arch.legacy
if platform != "" {
return osbuild.NewGrub2InstStage(grub2InstStageOptions(filename, pt, platform))
}
if arch.name == s390xArchName {
devmap := map[string]osbuild.Device(*devices)
devmap["disk"] = *disk
ziplDevices := osbuild.CopyStageDevices(devmap)
return osbuild.NewZiplInstStage(ziplInstStageOptions(kernelVer, pt), &ziplDevices, mounts)
return osbuild.NewZiplInstStage(ziplInstStageOptions(kernelVer, pt), disk, devices, mounts)
}
return nil

View file

@ -352,11 +352,7 @@ func grub2StageOptions(rootPartition *disk.Partition, bootPartition *disk.Partit
// sfdiskStageOptions creates the options and devices properties for an
// org.osbuild.sfdisk stage based on a partition table description
func sfdiskStageOptions(pt *disk.PartitionTable, device *osbuild.Device) (*osbuild.SfdiskStageOptions, *osbuild.SfdiskStageDevices) {
stageDevices := &osbuild.SfdiskStageDevices{
Device: *device,
}
func sfdiskStageOptions(pt *disk.PartitionTable) *osbuild.SfdiskStageOptions {
partitions := make([]osbuild.Partition, len(pt.Partitions))
for idx, p := range pt.Partitions {
partitions[idx] = osbuild.Partition{
@ -373,7 +369,7 @@ func sfdiskStageOptions(pt *disk.PartitionTable, device *osbuild.Device) (*osbui
Partitions: partitions,
}
return stageOptions, stageDevices
return stageOptions
}
// copyFSTreeOptions creates the options, inputs, devices, and mounts properties
@ -381,8 +377,8 @@ func sfdiskStageOptions(pt *disk.PartitionTable, device *osbuild.Device) (*osbui
// table description to define the mounts
func copyFSTreeOptions(inputName, inputPipeline string, pt *disk.PartitionTable, device *osbuild.Device) (
*osbuild.CopyStageOptions,
*osbuild.CopyStageDevices,
*osbuild.CopyStageMounts,
*osbuild.Devices,
*osbuild.Mounts,
) {
// assume loopback device for simplicity since it's the only one currently supported
// panic if the conversion fails
@ -433,8 +429,8 @@ func copyFSTreeOptions(inputName, inputPipeline string, pt *disk.PartitionTable,
return mounts[i].Target < mounts[j].Target
})
stageMounts := osbuild.CopyStageMounts(mounts)
stageDevices := osbuild.CopyStageDevices(devices)
stageMounts := osbuild.Mounts(mounts)
stageDevices := osbuild.Devices(devices)
options := osbuild.CopyStageOptions{
Paths: []osbuild.CopyStagePath{