Skip to content

Commit

Permalink
reducer: make sure to expand to noarch
Browse files Browse the repository at this point in the history
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
  • Loading branch information
manuelnaranjo committed Dec 10, 2024
1 parent da7af3d commit 7ee9918
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
26 changes: 13 additions & 13 deletions pkg/reducer/reducer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ type RepoReducer struct {
repoFiles []string
provides map[string][]*api.Package
implicitRequires []string
arch string
architectures []string
architecturesSet map[string]bool
repos *bazeldnf.Repositories
cacheHelper *repo.CacheHelper
}
Expand All @@ -38,19 +38,19 @@ func (r *RepoReducer) Load() error {
return err
}
for i, p := range repoFile.Packages {
if skip(p.Arch, r.architectures) {
if skip(p.Arch, r.architecturesSet) {
continue
}
r.packages = append(r.packages, repoFile.Packages[i])
}
}
repos, err := r.cacheHelper.CurrentPrimaries(r.repos, r.arch)
repos, err := r.cacheHelper.CurrentPrimaries(r.repos, r.architecturesSet)
if err != nil {
return err
}
for _, rpmrepo := range repos {
for i, p := range rpmrepo.Packages {
if skip(p.Arch, r.architectures) {
if skip(p.Arch, r.architecturesSet) {
continue
}
r.packages = append(r.packages, rpmrepo.Packages[i])
Expand Down Expand Up @@ -204,28 +204,28 @@ func NewRepoReducer(repos *bazeldnf.Repositories, repoFiles []string, lang strin
if baseSystem != "" {
implicitRequires = append(implicitRequires, baseSystem)
}
architecturesSet := map[string]bool{}
for _, arch := range []string{"noarch", arch} {
architecturesSet[arch] = true
}
return &RepoReducer{
packages: nil,
lang: lang,
implicitRequires: implicitRequires,
repoFiles: repoFiles,
provides: map[string][]*api.Package{},
architectures: []string{"noarch", arch},
arch: arch,
architecturesSet: architecturesSet,
repos: repos,
cacheHelper: cacheHelper,
}
}

func skip(arch string, arches []string) bool {
skip := true
for _, a := range arches {
if a == arch {
skip = false
break
}
func skip(arch string, arches map[string]bool) bool {
if _, ok := arches[arch]; ok {
return false
}
return skip
return true
}

// FixPackages contains hacks which should probably not have to exist
Expand Down
5 changes: 3 additions & 2 deletions pkg/repo/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,10 @@ func (r *CacheHelper) CurrentFilelistsForPackages(repo *bazeldnf.Repository, arc
return filelistpkgs, remaining, nil
}

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

0 comments on commit 7ee9918

Please sign in to comment.