distro: copy PackageSets() functionality into Manifest()
Copy the functionality of the ImageType.PackageSets() methods into ImageType.Manifest() for each distro. The Manifest() method now collects all package sets and repositories from the blueprint and image type and after generating the Manifest instance, calls the GetPackageSetChains() method to attach the computed package sets to the Manifest before returning it. The package sets in the call are now renamed to staticPackageSets to differentiate from the dynamic (computed) package sets that are affected by the manifest generation.
This commit is contained in:
parent
1a38939abf
commit
d5c4a0c31f
4 changed files with 96 additions and 12 deletions
|
|
@ -264,6 +264,26 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
containers []container.Spec,
|
||||
seed int64) (*manifest.Manifest, []string, error) {
|
||||
|
||||
// merge package sets that appear in the image type with the package sets
|
||||
// of the same name from the distro and arch
|
||||
staticPackageSets := make(map[string]rpmmd.PackageSet)
|
||||
|
||||
for name, getter := range t.packageSets {
|
||||
staticPackageSets[name] = getter(t)
|
||||
}
|
||||
|
||||
// amend with repository information
|
||||
for _, repo := range repos {
|
||||
if len(repo.PackageSets) > 0 {
|
||||
// only apply the repo to the listed package sets
|
||||
for _, psName := range repo.PackageSets {
|
||||
ps := staticPackageSets[psName]
|
||||
ps.Repositories = append(ps.Repositories, repo)
|
||||
staticPackageSets[psName] = ps
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// the os pipeline filters repos based on the `osPkgsKey` package set, merge the repos which
|
||||
// contain a payload package set into the `osPkgsKey`, so those repos are included when
|
||||
// building the rpm stage in the os pipeline
|
||||
|
|
@ -283,7 +303,6 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
}
|
||||
repos = mergedRepos
|
||||
|
||||
var packageSets map[string]rpmmd.PackageSet
|
||||
warnings, err := t.checkOptions(bp, options)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
|
@ -293,7 +312,7 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
// always assume Custom.
|
||||
w := &workload.Custom{
|
||||
BaseWorkload: workload.BaseWorkload{
|
||||
Repos: packageSets[blueprintPkgsKey].Repositories,
|
||||
Repos: staticPackageSets[blueprintPkgsKey].Repositories,
|
||||
},
|
||||
Packages: bp.GetPackagesEx(false),
|
||||
}
|
||||
|
|
@ -307,7 +326,7 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
/* #nosec G404 */
|
||||
rng := rand.New(source)
|
||||
|
||||
img, err := t.image(w, t, bp.Customizations, options, packageSets, containers, rng)
|
||||
img, err := t.image(w, t, bp.Customizations, options, staticPackageSets, containers, rng)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
@ -317,6 +336,8 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
manifest.Content.PackageSets = manifest.GetPackageSetChains()
|
||||
|
||||
return &manifest, warnings, err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -156,6 +156,26 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
containers []container.Spec,
|
||||
seed int64) (*manifest.Manifest, []string, error) {
|
||||
|
||||
// merge package sets that appear in the image type with the package sets
|
||||
// of the same name from the distro and arch
|
||||
staticPackageSets := make(map[string]rpmmd.PackageSet)
|
||||
|
||||
for name, getter := range t.packageSets {
|
||||
staticPackageSets[name] = getter(t)
|
||||
}
|
||||
|
||||
// amend with repository information
|
||||
for _, repo := range repos {
|
||||
if len(repo.PackageSets) > 0 {
|
||||
// only apply the repo to the listed package sets
|
||||
for _, psName := range repo.PackageSets {
|
||||
ps := staticPackageSets[psName]
|
||||
ps.Repositories = append(ps.Repositories, repo)
|
||||
staticPackageSets[psName] = ps
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// the os pipeline filters repos based on the `osPkgsKey` package set, merge the repos which
|
||||
// contain a payload package set into the `osPkgsKey`, so those repos are included when
|
||||
// building the rpm stage in the os pipeline
|
||||
|
|
@ -180,12 +200,11 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
var packageSets map[string]rpmmd.PackageSet
|
||||
w := t.workload
|
||||
if w == nil {
|
||||
cw := &workload.Custom{
|
||||
BaseWorkload: workload.BaseWorkload{
|
||||
Repos: packageSets[blueprintPkgsKey].Repositories,
|
||||
Repos: staticPackageSets[blueprintPkgsKey].Repositories,
|
||||
},
|
||||
Packages: bp.GetPackagesEx(false),
|
||||
}
|
||||
|
|
@ -204,7 +223,7 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
if t.image == nil {
|
||||
return nil, nil, nil
|
||||
}
|
||||
img, err := t.image(w, t, bp.Customizations, options, packageSets, containers, rng)
|
||||
img, err := t.image(w, t, bp.Customizations, options, staticPackageSets, containers, rng)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
@ -214,6 +233,8 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
manifest.Content.PackageSets = overridePackageNamesInSets(manifest.GetPackageSetChains())
|
||||
|
||||
return &manifest, warnings, err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,6 +190,26 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
containers []container.Spec,
|
||||
seed int64) (*manifest.Manifest, []string, error) {
|
||||
|
||||
// merge package sets that appear in the image type with the package sets
|
||||
// of the same name from the distro and arch
|
||||
staticPackageSets := make(map[string]rpmmd.PackageSet)
|
||||
|
||||
for name, getter := range t.packageSets {
|
||||
staticPackageSets[name] = getter(t)
|
||||
}
|
||||
|
||||
// amend with repository information
|
||||
for _, repo := range repos {
|
||||
if len(repo.PackageSets) > 0 {
|
||||
// only apply the repo to the listed package sets
|
||||
for _, psName := range repo.PackageSets {
|
||||
ps := staticPackageSets[psName]
|
||||
ps.Repositories = append(ps.Repositories, repo)
|
||||
staticPackageSets[psName] = ps
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// the os pipeline filters repos based on the `osPkgsKey` package set, merge the repos which
|
||||
// contain a payload package set into the `osPkgsKey`, so those repos are included when
|
||||
// building the rpm stage in the os pipeline
|
||||
|
|
@ -215,11 +235,10 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
}
|
||||
|
||||
w := t.workload
|
||||
var packageSets map[string]rpmmd.PackageSet
|
||||
if w == nil {
|
||||
cw := &workload.Custom{
|
||||
BaseWorkload: workload.BaseWorkload{
|
||||
Repos: packageSets[blueprintPkgsKey].Repositories,
|
||||
Repos: staticPackageSets[blueprintPkgsKey].Repositories,
|
||||
},
|
||||
Packages: bp.GetPackagesEx(false),
|
||||
}
|
||||
|
|
@ -238,7 +257,7 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
if t.image == nil {
|
||||
return nil, nil, nil
|
||||
}
|
||||
img, err := t.image(w, t, bp.Customizations, options, packageSets, containers, rng)
|
||||
img, err := t.image(w, t, bp.Customizations, options, staticPackageSets, containers, rng)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
@ -248,6 +267,8 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
manifest.Content.PackageSets = overridePackageNamesInSets(manifest.GetPackageSetChains())
|
||||
|
||||
return &manifest, warnings, err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -193,6 +193,26 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
containers []container.Spec,
|
||||
seed int64) (*manifest.Manifest, []string, error) {
|
||||
|
||||
// merge package sets that appear in the image type with the package sets
|
||||
// of the same name from the distro and arch
|
||||
staticPackageSets := make(map[string]rpmmd.PackageSet)
|
||||
|
||||
for name, getter := range t.packageSets {
|
||||
staticPackageSets[name] = getter(t)
|
||||
}
|
||||
|
||||
// amend with repository information
|
||||
for _, repo := range repos {
|
||||
if len(repo.PackageSets) > 0 {
|
||||
// only apply the repo to the listed package sets
|
||||
for _, psName := range repo.PackageSets {
|
||||
ps := staticPackageSets[psName]
|
||||
ps.Repositories = append(ps.Repositories, repo)
|
||||
staticPackageSets[psName] = ps
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// the os pipeline filters repos based on the `osPkgsKey` package set, merge the repos which
|
||||
// contain a payload package set into the `osPkgsKey`, so those repos are included when
|
||||
// building the rpm stage in the os pipeline
|
||||
|
|
@ -217,12 +237,11 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
var packageSets map[string]rpmmd.PackageSet
|
||||
w := t.workload
|
||||
if w == nil {
|
||||
cw := &workload.Custom{
|
||||
BaseWorkload: workload.BaseWorkload{
|
||||
Repos: packageSets[blueprintPkgsKey].Repositories,
|
||||
Repos: staticPackageSets[blueprintPkgsKey].Repositories,
|
||||
},
|
||||
Packages: bp.GetPackagesEx(false),
|
||||
}
|
||||
|
|
@ -238,7 +257,7 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
/* #nosec G404 */
|
||||
rng := rand.New(source)
|
||||
|
||||
img, err := t.image(w, t, bp.Customizations, options, packageSets, containers, rng)
|
||||
img, err := t.image(w, t, bp.Customizations, options, staticPackageSets, containers, rng)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
@ -248,6 +267,8 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint,
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
manifest.Content.PackageSets = manifest.GetPackageSetChains()
|
||||
|
||||
return &manifest, warnings, err
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue