mirror of
https://github.com/mudler/luet.git
synced 2025-09-02 07:45:02 +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 {
|
||||
return nil, err
|
||||
}
|
||||
if pack.GetFingerPrint() == p.GetFingerPrint() {
|
||||
if pack.Matches(p) {
|
||||
return pack, nil
|
||||
}
|
||||
}
|
||||
@@ -175,7 +175,7 @@ func (db *InMemoryDatabase) UpdatePackage(p Package) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if pack.GetFingerPrint() == p.GetFingerPrint() {
|
||||
if pack.Matches(p) {
|
||||
id = k
|
||||
found = true
|
||||
break
|
||||
|
@@ -49,6 +49,7 @@ type Package interface {
|
||||
|
||||
GetVersion() string
|
||||
RequiresContains(Package) bool
|
||||
Matches(m Package) bool
|
||||
|
||||
AddUse(use string)
|
||||
RemoveUse(use string)
|
||||
@@ -221,6 +222,13 @@ func (p *DefaultPackage) Clone() Package {
|
||||
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) {
|
||||
|
||||
var versionsInWorld []Package
|
||||
@@ -248,11 +256,11 @@ func (p *DefaultPackage) Expand(world *[]Package) ([]Package, error) {
|
||||
func (p *DefaultPackage) Revdeps(world *[]Package) []Package {
|
||||
var versionsInWorld []Package
|
||||
for _, w := range *world {
|
||||
if w.GetFingerPrint() == p.GetFingerPrint() {
|
||||
if w.Matches(p) {
|
||||
continue
|
||||
}
|
||||
for _, r := range w.GetRequires() {
|
||||
if r.GetFingerPrint() == p.GetFingerPrint() {
|
||||
for _, re := range w.GetRequires() {
|
||||
if re.Matches(p) {
|
||||
versionsInWorld = append(versionsInWorld, w)
|
||||
versionsInWorld = append(versionsInWorld, w.Revdeps(world)...)
|
||||
}
|
||||
@@ -279,7 +287,7 @@ func NormalizeFlagged(p Package) {
|
||||
|
||||
func (p *DefaultPackage) RequiresContains(s Package) bool {
|
||||
for _, re := range p.GetRequires() {
|
||||
if re.GetFingerPrint() == s.GetFingerPrint() {
|
||||
if re.Matches(s) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
@@ -216,7 +216,7 @@ func (assertions PackagesAssertions) Drop(p pkg.Package) PackagesAssertions {
|
||||
ass := PackagesAssertions{}
|
||||
|
||||
for _, a := range assertions {
|
||||
if a.Package.GetFingerPrint() != p.GetFingerPrint() {
|
||||
if !a.Package.Matches(p) {
|
||||
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))
|
||||
|
||||
for _, i := range ls {
|
||||
if i.GetFingerPrint() == p.GetFingerPrint() {
|
||||
if i.Matches(p) {
|
||||
continue
|
||||
}
|
||||
// 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
|
||||
var InstalledMinusCandidate []pkg.Package
|
||||
for _, i := range s.Installed {
|
||||
if i.GetFingerPrint() != candidate.GetFingerPrint() && !candidate.RequiresContains(i) {
|
||||
if !i.Matches(candidate) && !candidate.RequiresContains(i) {
|
||||
InstalledMinusCandidate = append(InstalledMinusCandidate, i)
|
||||
}
|
||||
}
|
||||
|
@@ -68,7 +68,7 @@ func (gt *DefaultTree) World() ([]pkg.Package, error) {
|
||||
func (gt *DefaultTree) UpdateWorldPackage(p pkg.Package) {
|
||||
//var CacheWorld []pkg.Package
|
||||
for _, pid := range gt.CacheWorld {
|
||||
if p.GetFingerPrint() == pid.GetFingerPrint() {
|
||||
if p.Matches(pid) {
|
||||
pid.Requires(p.GetRequires())
|
||||
pid.Conflicts(p.GetConflicts())
|
||||
}
|
||||
@@ -83,7 +83,7 @@ func (gt *DefaultTree) FindPackage(pack pkg.Package) (pkg.Package, error) {
|
||||
return nil, err
|
||||
}
|
||||
for _, pid := range packages {
|
||||
if pack.GetFingerPrint() == pid.GetFingerPrint() {
|
||||
if pack.Matches(pid) {
|
||||
return pid, nil
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user