manifest: provide depsolved packages when serializing

Rather than providing packageSpecs when constructing the
Manifest, do so at Serialize() time.

This allows the overall flow to be:

```
m := Manifest.New()
m.AddPipeline()
...
c := m.GetPackageSetChains()
p := Depsolve(c)
m.Serialize(p)
```
This commit is contained in:
Tom Gundersen 2022-06-29 20:05:37 +01:00
parent c042af7d9c
commit 28b8a790b5
8 changed files with 135 additions and 105 deletions

View file

@ -490,7 +490,7 @@ func (a *architecture) Distro() distro.Distro {
return a.distro
}
type pipelinesFunc func(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]manifest.Pipeline, error)
type pipelinesFunc func(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet, rng *rand.Rand) ([]manifest.Pipeline, error)
type packageSetFunc func(t *imageType) rpmmd.PackageSet
@ -628,7 +628,7 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti
}
// create a manifest object and instantiate it with the computed packageSetChains
manifest, err := t.initializeManifest(bp.Customizations, options, repos, distro.MakePackageSetChains(t, mergedSets, repos), nil, 0)
manifest, err := t.initializeManifest(bp.Customizations, options, repos, distro.MakePackageSetChains(t, mergedSets, repos), 0)
if err != nil {
// TODO: handle manifest initialization errors more gracefully, we
// refuse to initialize manifests with invalid config.
@ -638,6 +638,7 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti
manifestChains := manifest.GetPackageSetChains()
// the returned package set chains are indexed by pipeline
// name, we need to reindex by package set name
// TODO: drop translation, see Manifest()
distroChains := make(map[string][]rpmmd.PackageSet)
for name, chain := range manifestChains {
switch name {
@ -738,7 +739,6 @@ func (t *imageType) initializeManifest(customizations *blueprint.Customizations,
options distro.ImageOptions,
repos []rpmmd.RepoConfig,
packageSetChains map[string][]rpmmd.PackageSet,
packageSpecSets map[string][]rpmmd.PackageSpec,
seed int64) (*manifest.Manifest, error) {
if err := t.checkOptions(customizations, options); err != nil {
@ -750,7 +750,7 @@ func (t *imageType) initializeManifest(customizations *blueprint.Customizations,
/* #nosec G404 */
rng := rand.New(source)
pipelines, err := t.pipelines(t, customizations, options, repos, packageSetChains, packageSpecSets, rng)
pipelines, err := t.pipelines(t, customizations, options, repos, packageSetChains, rng)
if err != nil {
return nil, err
}
@ -767,15 +767,33 @@ func (t *imageType) initializeManifest(customizations *blueprint.Customizations,
func (t *imageType) Manifest(customizations *blueprint.Customizations,
options distro.ImageOptions,
repos []rpmmd.RepoConfig,
packageSpecSets map[string][]rpmmd.PackageSpec,
distroPackageSets map[string][]rpmmd.PackageSpec,
seed int64) (distro.Manifest, error) {
manifest, err := t.initializeManifest(customizations, options, repos, nil, packageSpecSets, seed)
manifest, err := t.initializeManifest(customizations, options, repos, nil, seed)
if err != nil {
return distro.Manifest{}, err
}
return manifest.Serialize()
// TODO: drop transaltion, see GetPackageSets()
manifestPackageSets := make(map[string][]rpmmd.PackageSpec)
for name, set := range distroPackageSets {
switch name {
case osPkgsKey:
manifestPackageSets["os"] = set
manifestPackageSets["ostree-tree"] = set
case containerPkgsKey:
manifestPackageSets["container-tree"] = set
case installerPkgsKey:
manifestPackageSets["anaconda-tree"] = set
case buildPkgsKey:
manifestPackageSets["build"] = set
default:
panic(fmt.Sprintf("unknown pacakge set name: %s", name))
}
}
return manifest.Serialize(manifestPackageSets)
}
func isMountpointAllowed(mountpoint string) bool {

View file

@ -10,13 +10,13 @@ import (
"github.com/osbuild/osbuild-composer/internal/rpmmd"
)
func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]manifest.Pipeline, error) {
func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet, rng *rand.Rand) ([]manifest.Pipeline, error) {
pipelines := make([]manifest.Pipeline, 0)
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos, packageSetSpecs[buildPkgsKey])
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos)
pipelines = append(pipelines, buildPipeline)
treePipeline, err := osPipeline(buildPipeline, t, repos, packageSetSpecs[osPkgsKey], customizations, options, rng)
treePipeline, err := osPipeline(buildPipeline, t, repos, customizations, options, rng)
if err != nil {
return nil, err
}
@ -44,13 +44,13 @@ func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, opti
return pipelines, nil
}
func vhdPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]manifest.Pipeline, error) {
func vhdPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet, rng *rand.Rand) ([]manifest.Pipeline, error) {
pipelines := make([]manifest.Pipeline, 0)
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos, packageSetSpecs[buildPkgsKey])
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos)
pipelines = append(pipelines, buildPipeline)
treePipeline, err := osPipeline(buildPipeline, t, repos, packageSetSpecs[osPkgsKey], customizations, options, rng)
treePipeline, err := osPipeline(buildPipeline, t, repos, customizations, options, rng)
if err != nil {
return nil, err
}
@ -76,13 +76,13 @@ func vhdPipelines(t *imageType, customizations *blueprint.Customizations, option
return pipelines, nil
}
func vmdkPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]manifest.Pipeline, error) {
func vmdkPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet, rng *rand.Rand) ([]manifest.Pipeline, error) {
pipelines := make([]manifest.Pipeline, 0)
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos, packageSetSpecs[buildPkgsKey])
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos)
pipelines = append(pipelines, buildPipeline)
treePipeline, err := osPipeline(buildPipeline, t, repos, packageSetSpecs[osPkgsKey], customizations, options, rng)
treePipeline, err := osPipeline(buildPipeline, t, repos, customizations, options, rng)
if err != nil {
return nil, err
}
@ -108,13 +108,13 @@ func vmdkPipelines(t *imageType, customizations *blueprint.Customizations, optio
return pipelines, nil
}
func openstackPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]manifest.Pipeline, error) {
func openstackPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet, rng *rand.Rand) ([]manifest.Pipeline, error) {
pipelines := make([]manifest.Pipeline, 0)
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos, packageSetSpecs[buildPkgsKey])
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos)
pipelines = append(pipelines, buildPipeline)
treePipeline, err := osPipeline(buildPipeline, t, repos, packageSetSpecs[osPkgsKey], customizations, options, rng)
treePipeline, err := osPipeline(buildPipeline, t, repos, customizations, options, rng)
if err != nil {
return nil, err
}
@ -142,14 +142,13 @@ func openstackPipelines(t *imageType, customizations *blueprint.Customizations,
func ec2CommonPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions,
repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet,
packageSetSpecs map[string][]rpmmd.PackageSpec,
rng *rand.Rand, diskfile string) ([]manifest.Pipeline, error) {
pipelines := make([]manifest.Pipeline, 0)
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos, packageSetSpecs[buildPkgsKey])
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos)
pipelines = append(pipelines, buildPipeline)
treePipeline, err := osPipeline(buildPipeline, t, repos, packageSetSpecs[osPkgsKey], customizations, options, rng)
treePipeline, err := osPipeline(buildPipeline, t, repos, customizations, options, rng)
if err != nil {
return nil, err
}
@ -175,23 +174,22 @@ func ec2CommonPipelines(t *imageType, customizations *blueprint.Customizations,
// ec2Pipelines returns pipelines which produce uncompressed EC2 images which are expected to use RHSM for content
func ec2Pipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions,
repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet,
packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]manifest.Pipeline, error) {
return ec2CommonPipelines(t, customizations, options, repos, packageSetChains, packageSetSpecs, rng, t.Filename())
rng *rand.Rand) ([]manifest.Pipeline, error) {
return ec2CommonPipelines(t, customizations, options, repos, packageSetChains, rng, t.Filename())
}
func iotInstallerPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions,
repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet, packageSetSpecs map[string][]rpmmd.PackageSpec,
repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet,
rng *rand.Rand) ([]manifest.Pipeline, error) {
pipelines := make([]manifest.Pipeline, 0)
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos, packageSetSpecs[buildPkgsKey])
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos)
pipelines = append(pipelines, buildPipeline)
installerPackages := packageSetSpecs[installerPkgsKey]
d := t.arch.distro
ksUsers := len(customizations.GetUsers())+len(customizations.GetGroups()) > 0
anacondaTreePipeline := anacondaTreePipeline(buildPipeline, repos, installerPackages, t.Arch().Name(), d.product, d.osVersion, "IoT", ksUsers)
anacondaTreePipeline := anacondaTreePipeline(buildPipeline, repos, t.Arch().Name(), d.product, d.osVersion, "IoT", ksUsers)
installerChain := packageSetChains[installerPkgsKey]
if len(installerChain) >= 1 {
anacondaTreePipeline.ExtraPackages = installerChain[0].Include
@ -206,10 +204,9 @@ func iotInstallerPipelines(t *imageType, customizations *blueprint.Customization
}
func iotCorePipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions,
repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet,
packageSetSpecs map[string][]rpmmd.PackageSpec) (*manifest.BuildPipeline, *manifest.OSPipeline, *manifest.OSTreeCommitPipeline, error) {
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos, packageSetSpecs[buildPkgsKey])
treePipeline, err := osPipeline(buildPipeline, t, repos, packageSetSpecs[osPkgsKey], customizations, options, nil)
repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet) (*manifest.BuildPipeline, *manifest.OSPipeline, *manifest.OSTreeCommitPipeline, error) {
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos)
treePipeline, err := osPipeline(buildPipeline, t, repos, customizations, options, nil)
if err != nil {
return nil, nil, nil, err
}
@ -232,10 +229,10 @@ func iotCorePipelines(t *imageType, customizations *blueprint.Customizations, op
func iotCommitPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions,
repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet,
packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]manifest.Pipeline, error) {
rng *rand.Rand) ([]manifest.Pipeline, error) {
pipelines := make([]manifest.Pipeline, 0)
buildPipeline, treePipeline, commitPipeline, err := iotCorePipelines(t, customizations, options, repos, packageSetChains, packageSetSpecs)
buildPipeline, treePipeline, commitPipeline, err := iotCorePipelines(t, customizations, options, repos, packageSetChains)
if err != nil {
return nil, err
}
@ -246,17 +243,17 @@ func iotCommitPipelines(t *imageType, customizations *blueprint.Customizations,
func iotContainerPipelines(t *imageType, customizations *blueprint.Customizations,
options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet,
packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]manifest.Pipeline, error) {
rng *rand.Rand) ([]manifest.Pipeline, error) {
pipelines := make([]manifest.Pipeline, 0)
buildPipeline, treePipeline, commitPipeline, err := iotCorePipelines(t, customizations, options, repos, packageSetChains, packageSetSpecs)
buildPipeline, treePipeline, commitPipeline, err := iotCorePipelines(t, customizations, options, repos, packageSetChains)
if err != nil {
return nil, err
}
nginxConfigPath := "/etc/nginx.conf"
httpPort := "8080"
containerTreePipeline := containerTreePipeline(buildPipeline, commitPipeline, repos, packageSetSpecs[containerPkgsKey], options, customizations, nginxConfigPath, httpPort)
containerTreePipeline := containerTreePipeline(buildPipeline, commitPipeline, repos, options, customizations, nginxConfigPath, httpPort)
containerChain := packageSetChains[osPkgsKey]
if len(containerChain) >= 1 {
containerTreePipeline.ExtraPackages = containerChain[0].Include
@ -273,7 +270,6 @@ func iotContainerPipelines(t *imageType, customizations *blueprint.Customization
func osPipeline(buildPipeline *manifest.BuildPipeline,
t *imageType,
repos []rpmmd.RepoConfig,
packages []rpmmd.PackageSpec,
c *blueprint.Customizations,
options distro.ImageOptions,
rng *rand.Rand) (*manifest.OSPipeline, error) {
@ -302,7 +298,7 @@ func osPipeline(buildPipeline *manifest.BuildPipeline,
kernelName = c.GetKernel().Name
}
pl := manifest.NewOSPipeline(buildPipeline, t.rpmOstree, options.OSTree.Parent, options.OSTree.URL, repos, packages, pt, bootLoader, t.arch.legacy, kernelName)
pl := manifest.NewOSPipeline(buildPipeline, t.rpmOstree, options.OSTree.Parent, options.OSTree.URL, repos, pt, bootLoader, t.arch.legacy, kernelName)
if t.supportsUEFI() {
pl.UEFIVendor = t.arch.distro.vendor
@ -402,8 +398,8 @@ func ostreeCommitPipeline(buildPipeline *manifest.BuildPipeline, treePipeline *m
return p
}
func containerTreePipeline(buildPipeline *manifest.BuildPipeline, commitPipeline *manifest.OSTreeCommitPipeline, repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, options distro.ImageOptions, c *blueprint.Customizations, nginxConfigPath, listenPort string) *manifest.OSTreeCommitServerTreePipeline {
p := manifest.NewOSTreeCommitServerTreePipeline(buildPipeline, repos, packages, commitPipeline, nginxConfigPath, listenPort)
func containerTreePipeline(buildPipeline *manifest.BuildPipeline, commitPipeline *manifest.OSTreeCommitPipeline, repos []rpmmd.RepoConfig, options distro.ImageOptions, c *blueprint.Customizations, nginxConfigPath, listenPort string) *manifest.OSTreeCommitServerTreePipeline {
p := manifest.NewOSTreeCommitServerTreePipeline(buildPipeline, repos, commitPipeline, nginxConfigPath, listenPort)
language, _ := c.GetPrimaryLocale()
if language != nil {
p.Language = *language
@ -418,8 +414,8 @@ func containerPipeline(buildPipeline *manifest.BuildPipeline, treePipeline *mani
return p
}
func anacondaTreePipeline(buildPipeline *manifest.BuildPipeline, repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, arch, product, osVersion, variant string, users bool) *manifest.AnacondaPipeline {
p := manifest.NewAnacondaPipeline(buildPipeline, repos, packages, "kernel", arch, product, osVersion)
func anacondaTreePipeline(buildPipeline *manifest.BuildPipeline, repos []rpmmd.RepoConfig, arch, product, osVersion, variant string, users bool) *manifest.AnacondaPipeline {
p := manifest.NewAnacondaPipeline(buildPipeline, repos, "kernel", arch, product, osVersion)
p.Users = users
p.Variant = variant
p.Biosdevname = (arch == distro.X86_64ArchName)
@ -443,13 +439,13 @@ func bootISOPipeline(buildPipeline *manifest.BuildPipeline, treePipeline *manife
return p
}
func containerPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]manifest.Pipeline, error) {
func containerPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetChains map[string][]rpmmd.PackageSet, rng *rand.Rand) ([]manifest.Pipeline, error) {
pipelines := make([]manifest.Pipeline, 0)
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos, packageSetSpecs[buildPkgsKey])
buildPipeline := manifest.NewBuildPipeline(t.arch.distro.runner, repos)
pipelines = append(pipelines, buildPipeline)
treePipeline, err := osPipeline(buildPipeline, t, repos, packageSetSpecs[osPkgsKey], customizations, options, rng)
treePipeline, err := osPipeline(buildPipeline, t, repos, customizations, options, rng)
if err != nil {
return nil, err
}

View file

@ -42,7 +42,6 @@ type AnacondaPipeline struct {
// installer for.
func NewAnacondaPipeline(buildPipeline *BuildPipeline,
repos []rpmmd.RepoConfig,
packages []rpmmd.PackageSpec,
kernelName,
arch,
product,
@ -50,7 +49,6 @@ func NewAnacondaPipeline(buildPipeline *BuildPipeline,
p := &AnacondaPipeline{
BasePipeline: NewBasePipeline("anaconda-tree", buildPipeline, nil),
repos: repos,
packageSpecs: packages,
kernelName: kernelName,
arch: arch,
product: product,
@ -74,21 +72,28 @@ func (p *AnacondaPipeline) getPackageSpecs() []rpmmd.PackageSpec {
return p.packageSpecs
}
func (p *AnacondaPipeline) serializeStart() {
if p.kernelVer != "" {
func (p *AnacondaPipeline) serializeStart(packages []rpmmd.PackageSpec) {
if len(p.packageSpecs) > 0 {
panic("double call to serializeStart()")
}
p.kernelVer = rpmmd.GetVerStrFromPackageSpecListPanic(p.packageSpecs, p.kernelName)
p.packageSpecs = packages
if p.kernelName != "" {
p.kernelVer = rpmmd.GetVerStrFromPackageSpecListPanic(p.packageSpecs, p.kernelName)
}
}
func (p *AnacondaPipeline) serializeEnd() {
if p.kernelVer == "" {
if len(p.packageSpecs) == 0 {
panic("serializeEnd() call when serialization not in progress")
}
p.kernelVer = ""
p.packageSpecs = nil
}
func (p *AnacondaPipeline) serialize() osbuild2.Pipeline {
if len(p.packageSpecs) == 0 {
panic("serialization not started")
}
pipeline := p.BasePipeline.serialize()
pipeline.AddStage(osbuild2.NewRPMStage(osbuild2.NewRPMStageOptions(p.repos), osbuild2.NewRpmStageSourceFilesInputs(p.packageSpecs)))

View file

@ -25,12 +25,11 @@ type BuildPipeline struct {
// NewBuildPipeline creates a new build pipeline from the repositories in repos
// and the specified packages.
func NewBuildPipeline(runner string, repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec) *BuildPipeline {
func NewBuildPipeline(runner string, repos []rpmmd.RepoConfig) *BuildPipeline {
pipeline := &BuildPipeline{
BasePipeline: NewBasePipeline("build", nil, &runner),
dependents: make([]Pipeline, 0),
repos: repos,
packageSpecs: packages,
}
return pipeline
}
@ -58,7 +57,24 @@ func (p *BuildPipeline) getPackageSpecs() []rpmmd.PackageSpec {
return p.packageSpecs
}
func (p *BuildPipeline) serializeStart(packages []rpmmd.PackageSpec) {
if len(p.packageSpecs) > 0 {
panic("double call to serializeStart()")
}
p.packageSpecs = packages
}
func (p *BuildPipeline) serializeEnd() {
if len(p.packageSpecs) == 0 {
panic("serializeEnd() call when serialization not in progress")
}
p.packageSpecs = nil
}
func (p *BuildPipeline) serialize() osbuild2.Pipeline {
if len(p.packageSpecs) == 0 {
panic("serialization not started")
}
pipeline := p.BasePipeline.serialize()
pipeline.AddStage(osbuild2.NewRPMStage(osbuild2.NewRPMStageOptions(p.repos), osbuild2.NewRpmStageSourceFilesInputs(p.packageSpecs)))

View file

@ -32,14 +32,12 @@ type OSTreeCommitServerTreePipeline struct {
// nginx will be listening on.
func NewOSTreeCommitServerTreePipeline(buildPipeline *BuildPipeline,
repos []rpmmd.RepoConfig,
packageSpecs []rpmmd.PackageSpec,
commitPipeline *OSTreeCommitPipeline,
nginxConfigPath,
listenPort string) *OSTreeCommitServerTreePipeline {
p := &OSTreeCommitServerTreePipeline{
BasePipeline: NewBasePipeline("container-tree", buildPipeline, nil),
repos: repos,
packageSpecs: packageSpecs,
commitPipeline: commitPipeline,
nginxConfigPath: nginxConfigPath,
listenPort: listenPort,
@ -63,7 +61,24 @@ func (p *OSTreeCommitServerTreePipeline) getPackageSpecs() []rpmmd.PackageSpec {
return p.packageSpecs
}
func (p *OSTreeCommitServerTreePipeline) serializeStart(packages []rpmmd.PackageSpec) {
if len(p.packageSpecs) > 0 {
panic("double call to serializeStart()")
}
p.packageSpecs = packages
}
func (p *OSTreeCommitServerTreePipeline) serializeEnd() {
if len(p.packageSpecs) == 0 {
panic("serializeEnd() call when serialization not in progress")
}
p.packageSpecs = nil
}
func (p *OSTreeCommitServerTreePipeline) serialize() osbuild2.Pipeline {
if len(p.packageSpecs) == 0 {
panic("serialization not started")
}
pipeline := p.BasePipeline.serialize()
pipeline.AddStage(osbuild2.NewRPMStage(osbuild2.NewRPMStageOptions(p.repos), osbuild2.NewRpmStageSourceFilesInputs(p.packageSpecs)))

View file

@ -19,18 +19,12 @@ type osTreeCommit struct {
type OSBuildManifest []byte
type Manifest struct {
pipelines []Pipeline
packageSpecs []rpmmd.PackageSpec
osTreeCommits []osTreeCommit
inlineData []string
pipelines []Pipeline
}
func New() Manifest {
return Manifest{
pipelines: make([]Pipeline, 0),
packageSpecs: make([]rpmmd.PackageSpec, 0),
osTreeCommits: make([]osTreeCommit, 0),
inlineData: make([]string, 0),
pipelines: make([]Pipeline, 0),
}
}
@ -41,21 +35,6 @@ func (m *Manifest) AddPipeline(p Pipeline) {
}
}
m.pipelines = append(m.pipelines, p)
m.addPackages(p.getPackageSpecs())
m.addOSTreeCommits(p.getOSTreeCommits())
m.addInline(p.getInline())
}
func (m *Manifest) addPackages(packages []rpmmd.PackageSpec) {
m.packageSpecs = append(m.packageSpecs, packages...)
}
func (m *Manifest) addOSTreeCommits(commits []osTreeCommit) {
m.osTreeCommits = append(m.osTreeCommits, commits...)
}
func (m *Manifest) addInline(data []string) {
m.inlineData = append(m.inlineData, data...)
}
func (m Manifest) GetPackageSetChains() map[string][]rpmmd.PackageSet {
@ -70,22 +49,23 @@ func (m Manifest) GetPackageSetChains() map[string][]rpmmd.PackageSet {
return chains
}
func (m Manifest) Serialize() (distro.Manifest, error) {
var commits []ostree.CommitSource
for _, commit := range m.osTreeCommits {
commits = []ostree.CommitSource{
{
Checksum: commit.checksum, URL: commit.url,
},
}
}
func (m Manifest) Serialize(packageSets map[string][]rpmmd.PackageSpec) (distro.Manifest, error) {
pipelines := make([]osbuild2.Pipeline, 0)
packages := make([]rpmmd.PackageSpec, 0)
commits := make([]ostree.CommitSource, 0)
inline := make([]string, 0)
for _, pipeline := range m.pipelines {
pipeline.serializeStart()
pipeline.serializeStart(packageSets[pipeline.Name()])
}
for _, pipeline := range m.pipelines {
for _, commit := range pipeline.getOSTreeCommits() {
commits = append(commits, ostree.CommitSource{
Checksum: commit.checksum, URL: commit.url,
})
}
pipelines = append(pipelines, pipeline.serialize())
packages = append(packages, packageSets[pipeline.Name()]...)
inline = append(inline, pipeline.getInline()...)
}
for _, pipeline := range m.pipelines {
pipeline.serializeEnd()
@ -95,7 +75,7 @@ func (m Manifest) Serialize() (distro.Manifest, error) {
osbuild2.Manifest{
Version: "2",
Pipelines: pipelines,
Sources: osbuild2.GenSources(m.packageSpecs, commits, m.inlineData),
Sources: osbuild2.GenSources(packages, commits, inline),
},
)
}

View file

@ -107,7 +107,6 @@ func NewOSPipeline(buildPipeline *BuildPipeline,
osTreeParent string,
osTreeURL string,
repos []rpmmd.RepoConfig,
packages []rpmmd.PackageSpec,
partitionTable *disk.PartitionTable,
bootLoader BootLoader,
grubLegacy string,
@ -122,7 +121,6 @@ func NewOSPipeline(buildPipeline *BuildPipeline,
osTreeParent: osTreeParent,
osTreeURL: osTreeURL,
repos: repos,
packageSpecs: packages,
partitionTable: partitionTable,
bootLoader: bootLoader,
grubLegacy: grubLegacy,
@ -171,27 +169,29 @@ func (p *OSPipeline) getPackageSpecs() []rpmmd.PackageSpec {
return p.packageSpecs
}
func (p *OSPipeline) serializeStart() {
if p.kernelName == "" {
return
}
if p.kernelVer != "" {
func (p *OSPipeline) serializeStart(packages []rpmmd.PackageSpec) {
if len(p.packageSpecs) > 0 {
panic("double call to serializeStart()")
}
p.kernelVer = rpmmd.GetVerStrFromPackageSpecListPanic(p.packageSpecs, p.kernelName)
p.packageSpecs = packages
if p.kernelName != "" {
p.kernelVer = rpmmd.GetVerStrFromPackageSpecListPanic(p.packageSpecs, p.kernelName)
}
}
func (p *OSPipeline) serializeEnd() {
if p.kernelName == "" {
return
}
if p.kernelVer == "" {
if len(p.packageSpecs) == 0 {
panic("serializeEnd() call when serialization not in progress")
}
p.kernelVer = ""
p.packageSpecs = nil
}
func (p *OSPipeline) serialize() osbuild2.Pipeline {
if len(p.packageSpecs) == 0 {
panic("serialization not started")
}
pipeline := p.BasePipeline.serialize()
if p.osTree && p.osTreeParent != "" {

View file

@ -15,7 +15,7 @@ type Pipeline interface {
Name() string
getBuildPackages() []string
getPackageSetChain() []rpmmd.PackageSet
serializeStart()
serializeStart([]rpmmd.PackageSpec)
serializeEnd()
serialize() osbuild2.Pipeline
getPackageSpecs() []rpmmd.PackageSpec
@ -83,7 +83,7 @@ func NewBasePipeline(name string, build *BuildPipeline, runner *string) BasePipe
// serializeStart must be called exactly once before each call
// to serialize().
func (p BasePipeline) serializeStart() {
func (p BasePipeline) serializeStart([]rpmmd.PackageSpec) {
}
// serializeEnd must be called exactly once after each call to