Skip to content

Commit 7ee9918

Browse files
committed
reducer: make sure to expand to noarch
When getting an arch make sure to expand to noarch as well, because some RPMs may have dependencies that have no architecture, this seems to be how RPM work
1 parent da7af3d commit 7ee9918

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

pkg/reducer/reducer.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ type RepoReducer struct {
1919
repoFiles []string
2020
provides map[string][]*api.Package
2121
implicitRequires []string
22-
arch string
2322
architectures []string
23+
architecturesSet map[string]bool
2424
repos *bazeldnf.Repositories
2525
cacheHelper *repo.CacheHelper
2626
}
@@ -38,19 +38,19 @@ func (r *RepoReducer) Load() error {
3838
return err
3939
}
4040
for i, p := range repoFile.Packages {
41-
if skip(p.Arch, r.architectures) {
41+
if skip(p.Arch, r.architecturesSet) {
4242
continue
4343
}
4444
r.packages = append(r.packages, repoFile.Packages[i])
4545
}
4646
}
47-
repos, err := r.cacheHelper.CurrentPrimaries(r.repos, r.arch)
47+
repos, err := r.cacheHelper.CurrentPrimaries(r.repos, r.architecturesSet)
4848
if err != nil {
4949
return err
5050
}
5151
for _, rpmrepo := range repos {
5252
for i, p := range rpmrepo.Packages {
53-
if skip(p.Arch, r.architectures) {
53+
if skip(p.Arch, r.architecturesSet) {
5454
continue
5555
}
5656
r.packages = append(r.packages, rpmrepo.Packages[i])
@@ -204,28 +204,28 @@ func NewRepoReducer(repos *bazeldnf.Repositories, repoFiles []string, lang strin
204204
if baseSystem != "" {
205205
implicitRequires = append(implicitRequires, baseSystem)
206206
}
207+
architecturesSet := map[string]bool{}
208+
for _, arch := range []string{"noarch", arch} {
209+
architecturesSet[arch] = true
210+
}
207211
return &RepoReducer{
208212
packages: nil,
209213
lang: lang,
210214
implicitRequires: implicitRequires,
211215
repoFiles: repoFiles,
212216
provides: map[string][]*api.Package{},
213217
architectures: []string{"noarch", arch},
214-
arch: arch,
218+
architecturesSet: architecturesSet,
215219
repos: repos,
216220
cacheHelper: cacheHelper,
217221
}
218222
}
219223

220-
func skip(arch string, arches []string) bool {
221-
skip := true
222-
for _, a := range arches {
223-
if a == arch {
224-
skip = false
225-
break
226-
}
224+
func skip(arch string, arches map[string]bool) bool {
225+
if _, ok := arches[arch]; ok {
226+
return false
227227
}
228-
return skip
228+
return true
229229
}
230230

231231
// FixPackages contains hacks which should probably not have to exist

pkg/repo/cache.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,10 @@ func (r *CacheHelper) CurrentFilelistsForPackages(repo *bazeldnf.Repository, arc
256256
return filelistpkgs, remaining, nil
257257
}
258258

259-
func (r *CacheHelper) CurrentPrimaries(repos *bazeldnf.Repositories, arch string) (primaries []*api.Repository, err error) {
259+
func (r *CacheHelper) CurrentPrimaries(repos *bazeldnf.Repositories, architecturesSet map[string]bool) (primaries []*api.Repository, err error) {
260260
for i, repo := range repos.Repositories {
261-
if repo.Arch != arch {
261+
if _, ok := architecturesSet[repo.Arch]; !ok {
262+
logrus.Infof("Ignoring primary for %s - %s", repo.Name, repo.Arch)
262263
continue
263264
}
264265
primary, err := r.CurrentPrimary(&repos.Repositories[i])

0 commit comments

Comments
 (0)