mirror of
https://github.com/mudler/luet.git
synced 2025-09-25 06:24:46 +00:00
Decoder must search in assertions only
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
pkg "github.com/mudler/luet/pkg/package"
|
pkg "github.com/mudler/luet/pkg/package"
|
||||||
@@ -122,6 +123,18 @@ func (assertions PackagesAssertions) EnsureOrder() PackagesAssertions {
|
|||||||
return orderedAssertions
|
return orderedAssertions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX: Search assumes that a Package GetPackageName() is contained in GetFingerPrint()
|
||||||
|
func (assertions PackagesAssertions) Search(f string) *PackageAssert {
|
||||||
|
for _, a := range assertions {
|
||||||
|
if a.Value {
|
||||||
|
if strings.Contains(a.Package.GetFingerPrint(), f) {
|
||||||
|
return &a
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
func (assertions PackagesAssertions) Order(definitiondb pkg.PackageDatabase, fingerprint string) PackagesAssertions {
|
func (assertions PackagesAssertions) Order(definitiondb pkg.PackageDatabase, fingerprint string) PackagesAssertions {
|
||||||
|
|
||||||
orderedAssertions := PackagesAssertions{}
|
orderedAssertions := PackagesAssertions{}
|
||||||
@@ -151,13 +164,15 @@ func (assertions PackagesAssertions) Order(definitiondb pkg.PackageDatabase, fin
|
|||||||
// graph.AddNodes(fingerprints...)
|
// graph.AddNodes(fingerprints...)
|
||||||
for _, a := range unorderedAssertions {
|
for _, a := range unorderedAssertions {
|
||||||
for _, requiredDef := range a.Package.GetRequires() {
|
for _, requiredDef := range a.Package.GetRequires() {
|
||||||
req, err := definitiondb.FindPackageCandidate(requiredDef)
|
// We cannot search for fingerprint, as we could have selector in versions.
|
||||||
if err != nil {
|
// We know that the assertions are unique for packages
|
||||||
req = requiredDef
|
req := assertions.Search(requiredDef.GetPackageName())
|
||||||
|
if req != nil {
|
||||||
|
requiredDef = req.Package
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expand also here, as we need to order them (or instead the solver should give back the dep correctly?)
|
// Expand also here, as we need to order them (or instead the solver should give back the dep correctly?)
|
||||||
graph.AddEdge(a.Package.GetFingerPrint(), req.GetFingerPrint())
|
graph.AddEdge(a.Package.GetFingerPrint(), requiredDef.GetFingerPrint())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result, err := graph.TopSort(fingerprint)
|
result, err := graph.TopSort(fingerprint)
|
||||||
|
Reference in New Issue
Block a user