mirror of
https://github.com/mudler/luet.git
synced 2025-09-03 08:14:46 +00:00
Add Matches() to pkg.Package
This commit is contained in:
@@ -160,7 +160,7 @@ func (db *InMemoryDatabase) FindPackage(p Package) (Package, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if pack.GetFingerPrint() == p.GetFingerPrint() {
|
if pack.Matches(p) {
|
||||||
return pack, nil
|
return pack, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ func (db *InMemoryDatabase) UpdatePackage(p Package) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if pack.GetFingerPrint() == p.GetFingerPrint() {
|
if pack.Matches(p) {
|
||||||
id = k
|
id = k
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
|
@@ -49,6 +49,7 @@ type Package interface {
|
|||||||
|
|
||||||
GetVersion() string
|
GetVersion() string
|
||||||
RequiresContains(Package) bool
|
RequiresContains(Package) bool
|
||||||
|
Matches(m Package) bool
|
||||||
|
|
||||||
AddUse(use string)
|
AddUse(use string)
|
||||||
RemoveUse(use string)
|
RemoveUse(use string)
|
||||||
@@ -221,6 +222,13 @@ func (p *DefaultPackage) Clone() Package {
|
|||||||
return new
|
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) {
|
func (p *DefaultPackage) Expand(world *[]Package) ([]Package, error) {
|
||||||
|
|
||||||
var versionsInWorld []Package
|
var versionsInWorld []Package
|
||||||
@@ -248,11 +256,11 @@ func (p *DefaultPackage) Expand(world *[]Package) ([]Package, error) {
|
|||||||
func (p *DefaultPackage) Revdeps(world *[]Package) []Package {
|
func (p *DefaultPackage) Revdeps(world *[]Package) []Package {
|
||||||
var versionsInWorld []Package
|
var versionsInWorld []Package
|
||||||
for _, w := range *world {
|
for _, w := range *world {
|
||||||
if w.GetFingerPrint() == p.GetFingerPrint() {
|
if w.Matches(p) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, r := range w.GetRequires() {
|
for _, re := range w.GetRequires() {
|
||||||
if r.GetFingerPrint() == p.GetFingerPrint() {
|
if re.Matches(p) {
|
||||||
versionsInWorld = append(versionsInWorld, w)
|
versionsInWorld = append(versionsInWorld, w)
|
||||||
versionsInWorld = append(versionsInWorld, w.Revdeps(world)...)
|
versionsInWorld = append(versionsInWorld, w.Revdeps(world)...)
|
||||||
}
|
}
|
||||||
@@ -279,7 +287,7 @@ func NormalizeFlagged(p Package) {
|
|||||||
|
|
||||||
func (p *DefaultPackage) RequiresContains(s Package) bool {
|
func (p *DefaultPackage) RequiresContains(s Package) bool {
|
||||||
for _, re := range p.GetRequires() {
|
for _, re := range p.GetRequires() {
|
||||||
if re.GetFingerPrint() == s.GetFingerPrint() {
|
if re.Matches(s) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -216,7 +216,7 @@ func (assertions PackagesAssertions) Drop(p pkg.Package) PackagesAssertions {
|
|||||||
ass := PackagesAssertions{}
|
ass := PackagesAssertions{}
|
||||||
|
|
||||||
for _, a := range assertions {
|
for _, a := range assertions {
|
||||||
if a.Package.GetFingerPrint() != p.GetFingerPrint() {
|
if !a.Package.Matches(p) {
|
||||||
ass = append(ass, a)
|
ass = append(ass, a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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))
|
formulas = append(formulas, bf.And(bf.Not(P), r))
|
||||||
|
|
||||||
for _, i := range ls {
|
for _, i := range ls {
|
||||||
if i.GetFingerPrint() == p.GetFingerPrint() {
|
if i.Matches(p) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// XXX: Skip check on any of its requires ? ( Drop to avoid removing system packages when selecting an uninstall)
|
// 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
|
// Build a fake "Installed" - Candidate and its requires tree
|
||||||
var InstalledMinusCandidate []pkg.Package
|
var InstalledMinusCandidate []pkg.Package
|
||||||
for _, i := range s.Installed {
|
for _, i := range s.Installed {
|
||||||
if i.GetFingerPrint() != candidate.GetFingerPrint() && !candidate.RequiresContains(i) {
|
if !i.Matches(candidate) && !candidate.RequiresContains(i) {
|
||||||
InstalledMinusCandidate = append(InstalledMinusCandidate, i)
|
InstalledMinusCandidate = append(InstalledMinusCandidate, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -68,7 +68,7 @@ func (gt *DefaultTree) World() ([]pkg.Package, error) {
|
|||||||
func (gt *DefaultTree) UpdateWorldPackage(p pkg.Package) {
|
func (gt *DefaultTree) UpdateWorldPackage(p pkg.Package) {
|
||||||
//var CacheWorld []pkg.Package
|
//var CacheWorld []pkg.Package
|
||||||
for _, pid := range gt.CacheWorld {
|
for _, pid := range gt.CacheWorld {
|
||||||
if p.GetFingerPrint() == pid.GetFingerPrint() {
|
if p.Matches(pid) {
|
||||||
pid.Requires(p.GetRequires())
|
pid.Requires(p.GetRequires())
|
||||||
pid.Conflicts(p.GetConflicts())
|
pid.Conflicts(p.GetConflicts())
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@ func (gt *DefaultTree) FindPackage(pack pkg.Package) (pkg.Package, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, pid := range packages {
|
for _, pid := range packages {
|
||||||
if pack.GetFingerPrint() == pid.GetFingerPrint() {
|
if pack.Matches(pid) {
|
||||||
return pid, nil
|
return pid, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user