diff --git a/pkg/package/database_mem.go b/pkg/package/database_mem.go index 2fda53de..8b135f8e 100644 --- a/pkg/package/database_mem.go +++ b/pkg/package/database_mem.go @@ -160,7 +160,7 @@ func (db *InMemoryDatabase) FindPackage(p Package) (Package, error) { if err != nil { return nil, err } - if pack.GetFingerPrint() == p.GetFingerPrint() { + if pack.Matches(p) { return pack, nil } } @@ -175,7 +175,7 @@ func (db *InMemoryDatabase) UpdatePackage(p Package) error { if err != nil { return err } - if pack.GetFingerPrint() == p.GetFingerPrint() { + if pack.Matches(p) { id = k found = true break diff --git a/pkg/package/package.go b/pkg/package/package.go index ae97493c..43cf1d9f 100644 --- a/pkg/package/package.go +++ b/pkg/package/package.go @@ -49,6 +49,7 @@ type Package interface { GetVersion() string RequiresContains(Package) bool + Matches(m Package) bool AddUse(use string) RemoveUse(use string) @@ -221,6 +222,13 @@ func (p *DefaultPackage) Clone() Package { return new } +func (p *DefaultPackage) Matches(m Package) bool { + if p.GetFingerPrint() == m.GetFingerPrint() { + return true + } + return false +} + func (p *DefaultPackage) Expand(world *[]Package) ([]Package, error) { var versionsInWorld []Package @@ -248,11 +256,11 @@ func (p *DefaultPackage) Expand(world *[]Package) ([]Package, error) { func (p *DefaultPackage) Revdeps(world *[]Package) []Package { var versionsInWorld []Package for _, w := range *world { - if w.GetFingerPrint() == p.GetFingerPrint() { + if w.Matches(p) { continue } - for _, r := range w.GetRequires() { - if r.GetFingerPrint() == p.GetFingerPrint() { + for _, re := range w.GetRequires() { + if re.Matches(p) { versionsInWorld = append(versionsInWorld, w) versionsInWorld = append(versionsInWorld, w.Revdeps(world)...) } @@ -279,7 +287,7 @@ func NormalizeFlagged(p Package) { func (p *DefaultPackage) RequiresContains(s Package) bool { for _, re := range p.GetRequires() { - if re.GetFingerPrint() == s.GetFingerPrint() { + if re.Matches(s) { return true } diff --git a/pkg/solver/decoder.go b/pkg/solver/decoder.go index 0481f8db..4dd58aea 100644 --- a/pkg/solver/decoder.go +++ b/pkg/solver/decoder.go @@ -216,7 +216,7 @@ func (assertions PackagesAssertions) Drop(p pkg.Package) PackagesAssertions { ass := PackagesAssertions{} for _, a := range assertions { - if a.Package.GetFingerPrint() != p.GetFingerPrint() { + if !a.Package.Matches(p) { ass = append(ass, a) } } diff --git a/pkg/solver/solver.go b/pkg/solver/solver.go index 5ae6ea3c..d82c0d8c 100644 --- a/pkg/solver/solver.go +++ b/pkg/solver/solver.go @@ -126,7 +126,7 @@ func (s *Solver) ConflictsWith(p pkg.Package, ls []pkg.Package) (bool, error) { formulas = append(formulas, bf.And(bf.Not(P), r)) for _, i := range ls { - if i.GetFingerPrint() == p.GetFingerPrint() { + if i.Matches(p) { continue } // XXX: Skip check on any of its requires ? ( Drop to avoid removing system packages when selecting an uninstall) @@ -163,7 +163,7 @@ func (s *Solver) Uninstall(candidate pkg.Package) ([]pkg.Package, error) { // Build a fake "Installed" - Candidate and its requires tree var InstalledMinusCandidate []pkg.Package for _, i := range s.Installed { - if i.GetFingerPrint() != candidate.GetFingerPrint() && !candidate.RequiresContains(i) { + if !i.Matches(candidate) && !candidate.RequiresContains(i) { InstalledMinusCandidate = append(InstalledMinusCandidate, i) } } diff --git a/pkg/tree/tree.go b/pkg/tree/tree.go index 6130242e..9c1d14f7 100644 --- a/pkg/tree/tree.go +++ b/pkg/tree/tree.go @@ -68,7 +68,7 @@ func (gt *DefaultTree) World() ([]pkg.Package, error) { func (gt *DefaultTree) UpdateWorldPackage(p pkg.Package) { //var CacheWorld []pkg.Package for _, pid := range gt.CacheWorld { - if p.GetFingerPrint() == pid.GetFingerPrint() { + if p.Matches(pid) { pid.Requires(p.GetRequires()) pid.Conflicts(p.GetConflicts()) } @@ -83,7 +83,7 @@ func (gt *DefaultTree) FindPackage(pack pkg.Package) (pkg.Package, error) { return nil, err } for _, pid := range packages { - if pack.GetFingerPrint() == pid.GetFingerPrint() { + if pack.Matches(pid) { return pid, nil } }