From 2a4cd1966dd5fe56a2eed1cd51f18b99e49ebfd8 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Thu, 16 Feb 2023 13:14:03 +0100 Subject: [PATCH] distro: pass all repos to initializeManifest Pass through all repos to the initalizeManifest() function. Each pipeline will then select which repositories it needs based on the PackageSets field of each repository. Before, we only passed global repos down to the manifest generators and pipeline-specific repositories would only be used if they were attached to package sets and were handled explicitly by a pipeline generator. The repositories of the "blueprint" package set are explicitly added to the workload and returned by the "os" pipeline. The repositories of the "installer" package set are explicitly added to the "anaconda-tree" pipeline. If a repository was specified for any other pipeline, for example "build", the repositories for the that package set were never added to the pipeline. Fixes #3290 --- internal/distro/fedora/distro.go | 7 +------ internal/distro/rhel7/distro.go | 8 ++------ internal/distro/rhel8/imagetype.go | 8 ++------ internal/distro/rhel9/imagetype.go | 7 +------ 4 files changed, 6 insertions(+), 24 deletions(-) diff --git a/internal/distro/fedora/distro.go b/internal/distro/fedora/distro.go index f0a727b0e..163087d50 100644 --- a/internal/distro/fedora/distro.go +++ b/internal/distro/fedora/distro.go @@ -559,7 +559,6 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti } // amend with repository information - globalRepos := make([]rpmmd.RepoConfig, 0) for _, repo := range repos { if len(repo.PackageSets) > 0 { // only apply the repo to the listed package sets @@ -568,10 +567,6 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti ps.Repositories = append(ps.Repositories, repo) packageSets[psName] = ps } - } else { - // no package sets were listed, so apply the repo - // to all package sets - globalRepos = append(globalRepos, repo) } } @@ -610,7 +605,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, options, globalRepos, packageSets, containers, 0) + manifest, err := t.initializeManifest(&bp, options, repos, packageSets, containers, 0) if err != nil { // TODO: handle manifest initialization errors more gracefully, we // refuse to initialize manifests with invalid config. diff --git a/internal/distro/rhel7/distro.go b/internal/distro/rhel7/distro.go index ea5186226..65c12d3c4 100644 --- a/internal/distro/rhel7/distro.go +++ b/internal/distro/rhel7/distro.go @@ -409,7 +409,6 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti } // amend with repository information - globalRepos := make([]rpmmd.RepoConfig, 0) for _, repo := range repos { if len(repo.PackageSets) > 0 { // only apply the repo to the listed package sets @@ -418,10 +417,6 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti ps.Repositories = append(ps.Repositories, repo) packageSets[psName] = ps } - } else { - // no package sets were listed, so apply the repo - // to all package sets - globalRepos = append(globalRepos, repo) } } @@ -442,13 +437,14 @@ 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, options, globalRepos, packageSets, containers, 0) + manifest, err := t.initializeManifest(&bp, options, repos, packageSets, containers, 0) if err != nil { // TODO: handle manifest initialization errors more gracefully, we // refuse to initialize manifests with invalid config. logrus.Errorf("Initializing the manifest failed for %s (%s/%s): %v", t.Name(), t.arch.distro.Name(), t.arch.Name(), err) return nil } + return overridePackageNamesInSets(manifest.GetPackageSetChains()) } diff --git a/internal/distro/rhel8/imagetype.go b/internal/distro/rhel8/imagetype.go index cce60dc78..a81089af2 100644 --- a/internal/distro/rhel8/imagetype.go +++ b/internal/distro/rhel8/imagetype.go @@ -256,7 +256,6 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti } // amend with repository information - globalRepos := make([]rpmmd.RepoConfig, 0) for _, repo := range repos { if len(repo.PackageSets) > 0 { // only apply the repo to the listed package sets @@ -265,10 +264,6 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti ps.Repositories = append(ps.Repositories, repo) packageSets[psName] = ps } - } else { - // no package sets were listed, so apply the repo - // to all package sets - globalRepos = append(globalRepos, repo) } } @@ -307,13 +302,14 @@ 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, options, globalRepos, packageSets, containers, 0) + manifest, err := t.initializeManifest(&bp, options, repos, packageSets, containers, 0) if err != nil { // TODO: handle manifest initialization errors more gracefully, we // refuse to initialize manifests with invalid config. logrus.Errorf("Initializing the manifest failed for %s (%s/%s): %v", t.Name(), t.arch.distro.Name(), t.arch.Name(), err) return nil } + return overridePackageNamesInSets(manifest.GetPackageSetChains()) } diff --git a/internal/distro/rhel9/imagetype.go b/internal/distro/rhel9/imagetype.go index 723b44394..b90365b7a 100644 --- a/internal/distro/rhel9/imagetype.go +++ b/internal/distro/rhel9/imagetype.go @@ -256,7 +256,6 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti } // amend with repository information - globalRepos := make([]rpmmd.RepoConfig, 0) for _, repo := range repos { if len(repo.PackageSets) > 0 { // only apply the repo to the listed package sets @@ -265,10 +264,6 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti ps.Repositories = append(ps.Repositories, repo) packageSets[psName] = ps } - } else { - // no package sets were listed, so apply the repo - // to all package sets - globalRepos = append(globalRepos, repo) } } @@ -307,7 +302,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, options, globalRepos, packageSets, containers, 0) + manifest, err := t.initializeManifest(&bp, options, repos, packageSets, containers, 0) if err != nil { // TODO: handle manifest initialization errors more gracefully, we // refuse to initialize manifests with invalid config.