Move copyPipelineTreeInputs() from distros to osbuild2

Move the `copyPipelineTreeInputs()` function duplicated in many
distro definitions to the `osbuild2` package as
`NewCopyStagePipelineTreeInputs()`.

This will prevent creating another copy of the code in rhel-84 for
the `gce` image.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
Tomas Hozza 2022-02-16 09:51:24 +01:00 committed by Ondřej Budai
parent 0efbe0c55e
commit c9b72033ee
9 changed files with 21 additions and 49 deletions

View file

@ -979,12 +979,12 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string) *o
}
inputName := "root-tree"
copyInputs := copyPipelineTreeInputs(inputName, "efiboot-tree")
copyInputs := osbuild.NewCopyStagePipelineTreeInputs(inputName, "efiboot-tree")
copyOptions, copyDevices, copyMounts := copyFSTreeOptions(inputName, "efiboot-tree", &pt, loopback)
p.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
inputName = "coi"
copyInputs = copyPipelineTreeInputs(inputName, "coi-tree")
copyInputs = osbuild.NewCopyStagePipelineTreeInputs(inputName, "coi-tree")
p.AddStage(osbuild.NewCopyStageSimple(
&osbuild.CopyStageOptions{
Paths: []osbuild.CopyStagePath{
@ -1002,7 +1002,7 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string) *o
))
inputName = "efi-tree"
copyInputs = copyPipelineTreeInputs(inputName, "efiboot-tree")
copyInputs = osbuild.NewCopyStagePipelineTreeInputs(inputName, "efiboot-tree")
p.AddStage(osbuild.NewCopyStageSimple(
&osbuild.CopyStageOptions{
Paths: []osbuild.CopyStagePath{
@ -1235,7 +1235,7 @@ func liveImagePipeline(inputPipelineName string, outputFilename string, pt *disk
inputName := "root-tree"
copyOptions, copyDevices, copyMounts := copyFSTreeOptions(inputName, inputPipelineName, pt, loopback)
copyInputs := copyPipelineTreeInputs(inputName, inputPipelineName)
copyInputs := osbuild.NewCopyStagePipelineTreeInputs(inputName, inputPipelineName)
p.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
p.AddStage(bootloaderInstStage(outputFilename, pt, arch, kernelVer, copyDevices, copyMounts, loopback))
return p

View file

@ -50,15 +50,6 @@ func xorrisofsStageInputs(pipeline string) *osbuild.XorrisofsStageInputs {
return &osbuild.XorrisofsStageInputs{Tree: input}
}
func copyPipelineTreeInputs(name, inputPipeline string) *osbuild.CopyStageInputs {
inputName := name
treeInput := osbuild.CopyStageInput{}
treeInput.Type = "org.osbuild.tree"
treeInput.Origin = "org.osbuild.pipeline"
treeInput.References = []string{"name:" + inputPipeline}
return &osbuild.CopyStageInputs{inputName: treeInput}
}
func qemuStageInputs(stage, file string) *osbuild.QEMUStageInputs {
stageKey := "name:" + stage
ref := map[string]osbuild.QEMUFile{

View file

@ -716,12 +716,12 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string) *o
}
inputName := "root-tree"
copyInputs := copyPipelineTreeInputs(inputName, "efiboot-tree")
copyInputs := osbuild.NewCopyStagePipelineTreeInputs(inputName, "efiboot-tree")
copyOptions, copyDevices, copyMounts := copyFSTreeOptions(inputName, "efiboot-tree", &pt, loopback)
p.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
inputName = "coi"
copyInputs = copyPipelineTreeInputs(inputName, "coi-tree")
copyInputs = osbuild.NewCopyStagePipelineTreeInputs(inputName, "coi-tree")
p.AddStage(osbuild.NewCopyStageSimple(
&osbuild.CopyStageOptions{
Paths: []osbuild.CopyStagePath{
@ -739,7 +739,7 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string) *o
))
inputName = "efi-tree"
copyInputs = copyPipelineTreeInputs(inputName, "efiboot-tree")
copyInputs = osbuild.NewCopyStagePipelineTreeInputs(inputName, "efiboot-tree")
p.AddStage(osbuild.NewCopyStageSimple(
&osbuild.CopyStageOptions{
Paths: []osbuild.CopyStagePath{
@ -958,7 +958,7 @@ func liveImagePipeline(inputPipelineName string, outputFilename string, pt *disk
inputName := "root-tree"
copyOptions, copyDevices, copyMounts := copyFSTreeOptions(inputName, inputPipelineName, pt, loopback)
copyInputs := copyPipelineTreeInputs(inputName, inputPipelineName)
copyInputs := osbuild.NewCopyStagePipelineTreeInputs(inputName, inputPipelineName)
p.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
p.AddStage(bootloaderInstStage(outputFilename, pt, arch, kernelVer, copyDevices, copyMounts, loopback))
return p

View file

@ -50,15 +50,6 @@ func xorrisofsStageInputs(pipeline string) *osbuild.XorrisofsStageInputs {
return &osbuild.XorrisofsStageInputs{Tree: input}
}
func copyPipelineTreeInputs(name, inputPipeline string) *osbuild.CopyStageInputs {
inputName := name
treeInput := osbuild.CopyStageInput{}
treeInput.Type = "org.osbuild.tree"
treeInput.Origin = "org.osbuild.pipeline"
treeInput.References = []string{"name:" + inputPipeline}
return &osbuild.CopyStageInputs{inputName: treeInput}
}
func qemuStageInputs(stage, file string) *osbuild.QEMUStageInputs {
stageKey := "name:" + stage
ref := map[string]osbuild.QEMUFile{

View file

@ -713,12 +713,12 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rn
}
inputName := "root-tree"
copyInputs := copyPipelineTreeInputs(inputName, "efiboot-tree")
copyInputs := osbuild.NewCopyStagePipelineTreeInputs(inputName, "efiboot-tree")
copyOptions, copyDevices, copyMounts := copyFSTreeOptions(inputName, "efiboot-tree", &pt, loopback)
p.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
inputName = "coi"
copyInputs = copyPipelineTreeInputs(inputName, "coi-tree")
copyInputs = osbuild.NewCopyStagePipelineTreeInputs(inputName, "coi-tree")
p.AddStage(osbuild.NewCopyStageSimple(
&osbuild.CopyStageOptions{
Paths: []osbuild.CopyStagePath{
@ -736,7 +736,7 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rn
))
inputName = "efi-tree"
copyInputs = copyPipelineTreeInputs(inputName, "efiboot-tree")
copyInputs = osbuild.NewCopyStagePipelineTreeInputs(inputName, "efiboot-tree")
p.AddStage(osbuild.NewCopyStageSimple(
&osbuild.CopyStageOptions{
Paths: []osbuild.CopyStagePath{
@ -955,7 +955,7 @@ func liveImagePipeline(inputPipelineName string, outputFilename string, pt *disk
inputName := "root-tree"
copyOptions, copyDevices, copyMounts := copyFSTreeOptions(inputName, inputPipelineName, pt, loopback)
copyInputs := copyPipelineTreeInputs(inputName, inputPipelineName)
copyInputs := osbuild.NewCopyStagePipelineTreeInputs(inputName, inputPipelineName)
p.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
p.AddStage(bootloaderInstStage(outputFilename, pt, arch, kernelVer, copyDevices, copyMounts, loopback))
return p

View file

@ -50,15 +50,6 @@ func xorrisofsStageInputs(pipeline string) *osbuild.XorrisofsStageInputs {
return &osbuild.XorrisofsStageInputs{Tree: input}
}
func copyPipelineTreeInputs(name, inputPipeline string) *osbuild.CopyStageInputs {
inputName := name
treeInput := osbuild.CopyStageInput{}
treeInput.Type = "org.osbuild.tree"
treeInput.Origin = "org.osbuild.pipeline"
treeInput.References = []string{"name:" + inputPipeline}
return &osbuild.CopyStageInputs{inputName: treeInput}
}
func qemuStageInputs(stage, file string) *osbuild.QEMUStageInputs {
stageKey := "name:" + stage
ref := map[string]osbuild.QEMUFile{

View file

@ -1045,7 +1045,7 @@ func liveImagePipeline(inputPipelineName string, outputFilename string, pt *disk
inputName := "root-tree"
copyOptions, copyDevices, copyMounts := copyFSTreeOptions(inputName, inputPipelineName, pt, loopback)
copyInputs := copyPipelineTreeInputs(inputName, inputPipelineName)
copyInputs := osbuild.NewCopyStagePipelineTreeInputs(inputName, inputPipelineName)
p.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
p.AddStage(bootloaderInstStage(outputFilename, pt, arch, kernelVer, copyDevices, copyMounts, loopback))
return p

View file

@ -50,15 +50,6 @@ func xorrisofsStageInputs() *osbuild.XorrisofsStageInputs {
return &osbuild.XorrisofsStageInputs{Tree: input}
}
func copyPipelineTreeInputs(name, inputPipeline string) *osbuild.CopyStageInputs {
inputName := "root-tree"
treeInput := osbuild.CopyStageInput{}
treeInput.Type = "org.osbuild.tree"
treeInput.Origin = "org.osbuild.pipeline"
treeInput.References = []string{"name:" + inputPipeline}
return &osbuild.CopyStageInputs{inputName: treeInput}
}
func qemuStageInputs(stage, file string) *osbuild.QEMUStageInputs {
stageKey := "name:" + stage
ref := map[string]osbuild.QEMUFile{

View file

@ -58,3 +58,11 @@ func NewCopyStageSimple(options *CopyStageOptions, inputs CopyStageInputsNew) *S
Inputs: stageInputs,
}
}
func NewCopyStagePipelineTreeInputs(inputName, inputPipeline string) *CopyStageInputs {
treeInput := CopyStageInput{}
treeInput.Type = "org.osbuild.tree"
treeInput.Origin = "org.osbuild.pipeline"
treeInput.References = []string{"name:" + inputPipeline}
return &CopyStageInputs{inputName: treeInput}
}