mirror of
https://github.com/mudler/luet.git
synced 2025-09-18 16:32:16 +00:00
Make Expand and Revdeps consume a database
This commit is contained in:
committed by
Ettore Di Giacinto
parent
595c10f357
commit
556668fcc4
@@ -115,12 +115,11 @@ 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 {
|
||||
packages, err := pp.Expand(&w)
|
||||
packages, err := pp.Expand(db)
|
||||
// Expand, and relax search - if not found pick the same one
|
||||
if err != nil || len(packages) == 0 {
|
||||
cp = pp
|
||||
@@ -249,10 +248,9 @@ func (s *Solver) Uninstall(c pkg.Package) ([]pkg.Package, error) {
|
||||
var res []pkg.Package
|
||||
candidate, err := s.InstalledDatabase.FindPackage(c)
|
||||
if err != nil {
|
||||
w := s.InstalledDatabase.World()
|
||||
|
||||
// return nil, errors.Wrap(err, "Couldn't find required package in db definition")
|
||||
packages, err := c.Expand(&w)
|
||||
packages, err := c.Expand(s.InstalledDatabase)
|
||||
// Info("Expanded", packages, err)
|
||||
if err != nil || len(packages) == 0 {
|
||||
candidate = c
|
||||
|
@@ -665,7 +665,12 @@ var _ = Describe("Solver", func() {
|
||||
old := pkg.NewPackage("A", "1.3.1", []*pkg.DefaultPackage{}, []*pkg.DefaultPackage{})
|
||||
|
||||
It("Expands correctly", func() {
|
||||
lst, err := a.Expand(&[]pkg.Package{a1, a11, a01, a02, a03, old})
|
||||
definitions := pkg.NewInMemoryDatabase(false)
|
||||
for _, p := range []pkg.Package{a1, a11, a01, a02, a03, old} {
|
||||
_, err := definitions.CreatePackage(p)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
lst, err := a.Expand(definitions)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(lst).To(ContainElement(a11))
|
||||
Expect(lst).To(ContainElement(a1))
|
||||
|
Reference in New Issue
Block a user