diff --git a/pkg/package/package.go b/pkg/package/package.go index 83335263..06831f08 100644 --- a/pkg/package/package.go +++ b/pkg/package/package.go @@ -154,20 +154,20 @@ func (p *DefaultPackage) Expand(world []Package) ([]Package, error) { var versionsInWorld []Package for _, w := range world { - if w.GetName() == p.GetName() { - - v, err := version.NewVersion(w.GetVersion()) - if err != nil { - return nil, err - } - constraints, err := version.NewConstraint(p.GetVersion()) - if err != nil { - return nil, err - } - if constraints.Check(v) { - versionsInWorld = append(versionsInWorld, w) - } + if w.GetName() != p.GetName() { + continue + } + v, err := version.NewVersion(w.GetVersion()) + if err != nil { + return nil, err + } + constraints, err := version.NewConstraint(p.GetVersion()) + if err != nil { + return nil, err + } + if constraints.Check(v) { + versionsInWorld = append(versionsInWorld, w) } } diff --git a/pkg/solver/solver.go b/pkg/solver/solver.go index 860524aa..1616da18 100644 --- a/pkg/solver/solver.go +++ b/pkg/solver/solver.go @@ -157,9 +157,6 @@ func (s *Solver) ConflictsWithInstalled(p pkg.Package) (bool, error) { // Uninstall takes a candidate package and return a list of packages that would be removed // in order to purge the candidate. Returns error if unsat. -// XXX: this should be turned in unsat/sat instead of computing the reverse set -// e.g. world is ok with Px (installed-x-th) and removal of package (candidate?) -// collect unsatisfieds and repeat until we get no more unsatisfieds func (s *Solver) Uninstall(candidate pkg.Package) ([]pkg.Package, error) { var res []pkg.Package @@ -187,17 +184,20 @@ func (s *Solver) Uninstall(candidate pkg.Package) ([]pkg.Package, error) { if err != nil { return nil, err } - if !c { // If doesn't conflict with installed we just consider it for removal + + // If doesn't conflict with installed we just consider it for removal and look for the next one + if !c { + res = append(res, a.Package.IsFlagged(false)) + continue + } + + // If does conflicts, give it another chance by checking conflicts if in case we didn't installed our candidate and all the required packages in the system + c, err = s.ConflictsWith(a.Package, InstalledMinusCandidate) + if err != nil { + return nil, err + } + if !c { res = append(res, a.Package.IsFlagged(false)) - } else { - // If does conficlits, give it another chance checking conflicts if in case we didn't installed our candidate and all the requires in the system - c, err := s.ConflictsWith(a.Package, InstalledMinusCandidate) - if err != nil { - return nil, err - } - if !c { - res = append(res, a.Package.IsFlagged(false)) - } } }