diff --git a/internal/manifest/anaconda.go b/internal/manifest/anaconda.go index e464b8451..2d2f2b675 100644 --- a/internal/manifest/anaconda.go +++ b/internal/manifest/anaconda.go @@ -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 { diff --git a/internal/manifest/build.go b/internal/manifest/build.go index 76b4e7691..03c57b340 100644 --- a/internal/manifest/build.go +++ b/internal/manifest/build.go @@ -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 } diff --git a/internal/manifest/commit.go b/internal/manifest/commit.go index 715872659..a2f35a087 100644 --- a/internal/manifest/commit.go +++ b/internal/manifest/commit.go @@ -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 { diff --git a/internal/manifest/commit_server_tree.go b/internal/manifest/commit_server_tree.go index 82cc1ef91..9e6a00bd8 100644 --- a/internal/manifest/commit_server_tree.go +++ b/internal/manifest/commit_server_tree.go @@ -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 { diff --git a/internal/manifest/iso.go b/internal/manifest/iso.go index cedc58a02..964af95e1 100644 --- a/internal/manifest/iso.go +++ b/internal/manifest/iso.go @@ -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 { diff --git a/internal/manifest/iso_tree.go b/internal/manifest/iso_tree.go index 439ec7fb9..ef5efc52a 100644 --- a/internal/manifest/iso_tree.go +++ b/internal/manifest/iso_tree.go @@ -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 { diff --git a/internal/manifest/live.go b/internal/manifest/live.go index e64ae182f..ee7c49a04 100644 --- a/internal/manifest/live.go +++ b/internal/manifest/live.go @@ -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 { diff --git a/internal/manifest/oci_container.go b/internal/manifest/oci_container.go index 2bac6678c..a904015fe 100644 --- a/internal/manifest/oci_container.go +++ b/internal/manifest/oci_container.go @@ -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 { diff --git a/internal/manifest/os.go b/internal/manifest/os.go index 13335a58f..0a5b7d159 100644 --- a/internal/manifest/os.go +++ b/internal/manifest/os.go @@ -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 { diff --git a/internal/manifest/pipeline.go b/internal/manifest/pipeline.go index 656ba873d..6831f0085 100644 --- a/internal/manifest/pipeline.go +++ b/internal/manifest/pipeline.go @@ -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{} } diff --git a/internal/manifest/qcow2.go b/internal/manifest/qcow2.go index d69b0c921..23a992903 100644 --- a/internal/manifest/qcow2.go +++ b/internal/manifest/qcow2.go @@ -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 { diff --git a/internal/manifest/tar.go b/internal/manifest/tar.go index 96b88d091..2c1ab95e5 100644 --- a/internal/manifest/tar.go +++ b/internal/manifest/tar.go @@ -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 { diff --git a/internal/manifest/vmdk.go b/internal/manifest/vmdk.go index 493d34fd7..d39b63445 100644 --- a/internal/manifest/vmdk.go +++ b/internal/manifest/vmdk.go @@ -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 { diff --git a/internal/manifest/vpc.go b/internal/manifest/vpc.go index 29adee4af..cef0ca7fd 100644 --- a/internal/manifest/vpc.go +++ b/internal/manifest/vpc.go @@ -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 {