MatchesDependency should check on Provides: as well.

This commit is contained in:
Andrey Smirnov
2014-07-11 16:30:41 +04:00
parent ede5449440
commit b42fd71acf
2 changed files with 14 additions and 5 deletions

View File

@@ -199,16 +199,19 @@ func (p *Package) MatchesArchitecture(arch string) bool {
// MatchesDependency checks whether package matches specified dependency
func (p *Package) MatchesDependency(dep Dependency) bool {
if dep.Pkg != p.Name {
return false
}
if dep.Architecture != "" && !p.MatchesArchitecture(dep.Architecture) {
return false
}
if dep.Relation == VersionDontCare {
return true
if utils.StrSliceHasItem(p.Provides, dep.Pkg) {
return true
}
return dep.Pkg == p.Name
}
if dep.Pkg != p.Name {
return false
}
r := CompareVersions(p.Version, dep.Version)

View File

@@ -218,6 +218,12 @@ func (s *PackageSuite) TestMatchesDependency(c *C) {
c.Check(func() {
p.MatchesDependency(Dependency{Pkg: "alien-arena-common", Architecture: "i386", Relation: VersionRegexp, Version: "7\\.40-.*"})
}, Panics, "regexp matching not implemented yet")
// Provides
c.Check(p.MatchesDependency(Dependency{Pkg: "game", Relation: VersionDontCare}), Equals, false)
p.Provides = []string{"fun", "game"}
c.Check(p.MatchesDependency(Dependency{Pkg: "game", Relation: VersionDontCare}), Equals, true)
c.Check(p.MatchesDependency(Dependency{Pkg: "game", Architecture: "amd64", Relation: VersionDontCare}), Equals, false)
}
func (s *PackageSuite) TestGetDependencies(c *C) {