manifest/build: implement getPackageSetChain

A build pipeline now tracks all its dependents, and each pipeline
now implements a `getBuildPackages()` method. For now those
return the empty slice, but will be extended by each pipeline in the
future.

`getPackageSetChain() of the build pipeline simply collects all the
build package sets of its dependents.
This commit is contained in:
Tom Gundersen 2022-06-28 23:42:21 +01:00
parent 0743eb2f81
commit fc08579c29
14 changed files with 62 additions and 12 deletions

View file

@ -44,7 +44,7 @@ func NewAnacondaPipeline(buildPipeline *BuildPipeline,
product,
version string) *AnacondaPipeline {
kernelVer := rpmmd.GetVerStrFromPackageSpecListPanic(packages, kernelName)
return &AnacondaPipeline{
p := &AnacondaPipeline{
BasePipeline: NewBasePipeline("anaconda-tree", buildPipeline, nil),
repos: repos,
packageSpecs: packages,
@ -53,6 +53,8 @@ func NewAnacondaPipeline(buildPipeline *BuildPipeline,
product: product,
version: version,
}
buildPipeline.addDependent(p)
return p
}
func (p *AnacondaPipeline) getPackageSpecs() []rpmmd.PackageSpec {

View file

@ -15,6 +15,7 @@ import (
type BuildPipeline struct {
BasePipeline
dependents []Pipeline
repos []rpmmd.RepoConfig
packageSpecs []rpmmd.PackageSpec
}
@ -24,12 +25,32 @@ type BuildPipeline struct {
func NewBuildPipeline(runner string, repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec) *BuildPipeline {
pipeline := &BuildPipeline{
BasePipeline: NewBasePipeline("build", nil, &runner),
dependents: make([]Pipeline, 0),
repos: repos,
packageSpecs: packages,
}
return pipeline
}
func (p *BuildPipeline) addDependent(dep Pipeline) {
p.dependents = append(p.dependents, dep)
}
func (p *BuildPipeline) getPackageSetChain() []rpmmd.PackageSet {
packages := []string{}
for _, pipeline := range p.dependents {
packages = append(packages, pipeline.getBuildPackages()...)
}
return []rpmmd.PackageSet{
{
Include: packages,
Repositories: p.repos,
},
}
}
func (p *BuildPipeline) getPackageSpecs() []rpmmd.PackageSpec {
return p.packageSpecs
}

View file

@ -17,11 +17,13 @@ type OSTreeCommitPipeline struct {
// treePipeline is the tree representing the content of the commit.
// ref is the ref to create the commit under.
func NewOSTreeCommitPipeline(buildPipeline *BuildPipeline, treePipeline *OSPipeline, ref string) *OSTreeCommitPipeline {
return &OSTreeCommitPipeline{
p := &OSTreeCommitPipeline{
BasePipeline: NewBasePipeline("ostree-commit", buildPipeline, nil),
treePipeline: treePipeline,
ref: ref,
}
buildPipeline.addDependent(p)
return p
}
func (p *OSTreeCommitPipeline) serialize() osbuild2.Pipeline {

View file

@ -33,7 +33,7 @@ func NewOSTreeCommitServerTreePipeline(buildPipeline *BuildPipeline,
commitPipeline *OSTreeCommitPipeline,
nginxConfigPath,
listenPort string) *OSTreeCommitServerTreePipeline {
return &OSTreeCommitServerTreePipeline{
p := &OSTreeCommitServerTreePipeline{
BasePipeline: NewBasePipeline("container-tree", buildPipeline, nil),
repos: repos,
packageSpecs: packageSpecs,
@ -42,6 +42,8 @@ func NewOSTreeCommitServerTreePipeline(buildPipeline *BuildPipeline,
listenPort: listenPort,
Language: "en_US",
}
buildPipeline.addDependent(p)
return p
}
func (p *OSTreeCommitServerTreePipeline) getPackageSpecs() []rpmmd.PackageSpec {

View file

@ -15,11 +15,13 @@ type ISOPipeline struct {
}
func NewISOPipeline(buildPipeline *BuildPipeline, treePipeline *ISOTreePipeline, filename string) *ISOPipeline {
return &ISOPipeline{
p := &ISOPipeline{
BasePipeline: NewBasePipeline("bootiso", buildPipeline, nil),
treePipeline: treePipeline,
filename: filename,
}
buildPipeline.addDependent(p)
return p
}
func (p *ISOPipeline) serialize() osbuild2.Pipeline {

View file

@ -32,7 +32,7 @@ func NewISOTreePipeline(buildPipeline *BuildPipeline, anacondaPipeline *Anaconda
// TODO: replace isoLabelTmpl with more high-level properties
isoLabel := fmt.Sprintf(isoLabelTmpl, anacondaPipeline.arch)
return &ISOTreePipeline{
p := &ISOTreePipeline{
BasePipeline: NewBasePipeline("bootiso-tree", buildPipeline, nil),
anacondaPipeline: anacondaPipeline,
isoLabel: isoLabel,
@ -40,6 +40,8 @@ func NewISOTreePipeline(buildPipeline *BuildPipeline, anacondaPipeline *Anaconda
osTreeURL: osTreeURL,
osTreeRef: osTreeRef,
}
buildPipeline.addDependent(p)
return p
}
func (p *ISOTreePipeline) getOSTreeCommits() []osTreeCommit {

View file

@ -14,11 +14,13 @@ type LiveImgPipeline struct {
}
func NewLiveImgPipeline(buildPipeline *BuildPipeline, treePipeline *OSPipeline, filename string) *LiveImgPipeline {
return &LiveImgPipeline{
p := &LiveImgPipeline{
BasePipeline: NewBasePipeline("image", buildPipeline, nil),
treePipeline: treePipeline,
filename: filename,
}
buildPipeline.addDependent(p)
return p
}
func (p *LiveImgPipeline) serialize() osbuild2.Pipeline {

View file

@ -17,12 +17,14 @@ type OCIContainerPipeline struct {
}
func NewOCIContainerPipeline(buildPipeline *BuildPipeline, treePipeline *BasePipeline, architecture, filename string) *OCIContainerPipeline {
return &OCIContainerPipeline{
p := &OCIContainerPipeline{
BasePipeline: NewBasePipeline("container", buildPipeline, nil),
treePipeline: treePipeline,
architecture: architecture,
filename: filename,
}
buildPipeline.addDependent(p)
return p
}
func (p *OCIContainerPipeline) serialize() osbuild2.Pipeline {

View file

@ -106,7 +106,7 @@ func NewOSPipeline(buildPipeline *BuildPipeline,
if kernelName != "" {
kernelVer = rpmmd.GetVerStrFromPackageSpecListPanic(packages, kernelName)
}
return &OSPipeline{
p := &OSPipeline{
BasePipeline: NewBasePipeline(name, buildPipeline, nil),
osTree: osTree,
osTreeParent: osTreeParent,
@ -122,6 +122,8 @@ func NewOSPipeline(buildPipeline *BuildPipeline,
Timezone: "UTC",
SElinux: "targeted",
}
buildPipeline.addDependent(p)
return p
}
func (p *OSPipeline) getOSTreeCommits() []osTreeCommit {

View file

@ -13,6 +13,7 @@ import (
type Pipeline interface {
Name() string
getBuildPackages() []string
getPackageSetChain() []rpmmd.PackageSet
serialize() osbuild2.Pipeline
getPackageSpecs() []rpmmd.PackageSpec
@ -35,6 +36,10 @@ func (p BasePipeline) Name() string {
return p.name
}
func (p BasePipeline) getBuildPackages() []string {
return []string{}
}
func (p BasePipeline) getPackageSetChain() []rpmmd.PackageSet {
return []rpmmd.PackageSet{}
}

View file

@ -17,11 +17,13 @@ type QCOW2Pipeline struct {
// raw image. The pipeline name is the name of the new pipeline. Filename is the name
// of the produced qcow2 image.
func NewQCOW2Pipeline(buildPipeline *BuildPipeline, imgPipeline *LiveImgPipeline, filename string) *QCOW2Pipeline {
return &QCOW2Pipeline{
p := &QCOW2Pipeline{
BasePipeline: NewBasePipeline("qcow2", buildPipeline, nil),
imgPipeline: imgPipeline,
filename: filename,
}
buildPipeline.addDependent(p)
return p
}
func (p *QCOW2Pipeline) serialize() osbuild2.Pipeline {

View file

@ -15,11 +15,13 @@ type TarPipeline struct {
// filesystem tree which will be the contents of the tar file. The pipelinename
// is the name of the pipeline. The filename is the name of the output tar file.
func NewTarPipeline(buildPipeline *BuildPipeline, inputPipeline *BasePipeline, pipelinename, filename string) *TarPipeline {
return &TarPipeline{
p := &TarPipeline{
BasePipeline: NewBasePipeline(pipelinename, buildPipeline, nil),
inputPipeline: inputPipeline,
filename: filename,
}
buildPipeline.addDependent(p)
return p
}
func (p *TarPipeline) serialize() osbuild2.Pipeline {

View file

@ -15,11 +15,13 @@ type VMDKPipeline struct {
// NewVMDKPipeline creates a new VMDK pipeline. imgPipeline is the pipeline producing the
// raw image. Filename is the name of the produced image.
func NewVMDKPipeline(buildPipeline *BuildPipeline, imgPipeline *LiveImgPipeline, filename string) *VMDKPipeline {
return &VMDKPipeline{
p := &VMDKPipeline{
BasePipeline: NewBasePipeline("vmdk", buildPipeline, nil),
imgPipeline: imgPipeline,
filename: filename,
}
buildPipeline.addDependent(p)
return p
}
func (p *VMDKPipeline) serialize() osbuild2.Pipeline {

View file

@ -16,11 +16,13 @@ type VPCPipeline struct {
// raw image. The pipeline name is the name of the new pipeline. Filename is the name
// of the produced image.
func NewVPCPipeline(buildPipeline *BuildPipeline, imgPipeline *LiveImgPipeline, filename string) *VPCPipeline {
return &VPCPipeline{
p := &VPCPipeline{
BasePipeline: NewBasePipeline("vpc", buildPipeline, nil),
imgPipeline: imgPipeline,
filename: filename,
}
buildPipeline.addDependent(p)
return p
}
func (p *VPCPipeline) serialize() osbuild2.Pipeline {