Expand also when selecting candidates to install/uninstall

This commit is contained in:
Ettore Di Giacinto
2019-11-29 19:01:55 +01:00
parent e31f8820e2
commit ff3b322ea2
3 changed files with 77 additions and 8 deletions

View File

@@ -114,12 +114,18 @@ func (s *Solver) BuildWorld(includeInstalled bool) (bf.Formula, error) {
func (s *Solver) getList(db pkg.PackageDatabase, lsp []pkg.Package) ([]pkg.Package, error) {
var ls []pkg.Package
w := db.World()
for _, pp := range lsp {
cp, err := db.FindPackage(pp)
if err != nil {
cp = pp //Relax search, otherwise we cannot compute solutions for packages not in definitions
//return nil, errors.Wrap(err, "Package not found in db")
packages, err := pp.Expand(&w)
// Expand, and relax search - if not found pick the same one
if err != nil || len(packages) == 0 {
cp = pp
} else {
cp = pkg.Best(packages)
}
}
ls = append(ls, cp)
}
@@ -193,7 +199,17 @@ func (s *Solver) Uninstall(c pkg.Package) ([]pkg.Package, error) {
var res []pkg.Package
candidate, err := s.InstalledDatabase.FindPackage(c)
if err != nil {
candidate = c //Relax search, otherwise we cannot compute solutions for packages not in definitions
w := s.InstalledDatabase.World()
// return nil, errors.Wrap(err, "Couldn't find required package in db definition")
packages, err := c.Expand(&w)
// Info("Expanded", packages, err)
if err != nil || len(packages) == 0 {
candidate = c
} else {
candidate = pkg.Best(packages)
}
//Relax search, otherwise we cannot compute solutions for packages not in definitions
// return nil, errors.Wrap(err, "Package not found between installed")
}
// Build a fake "Installed" - Candidate and its requires tree