Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incomplete dependencies with follow-all-variants #644

Merged
merged 1 commit into from
Sep 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions deb/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ func NewPackageListFromRefList(reflist *PackageRefList, collection *PackageColle
return result, nil
}

// Has checks whether package is already in the list
func (l *PackageList) Has(p *Package) bool {
key := l.keyFunc(p)
_, ok := l.packages[key]

return ok
}

// Add appends package to package list, additionally checking for uniqueness
func (l *PackageList) Add(p *Package) error {
key := l.keyFunc(p)
Expand Down Expand Up @@ -511,15 +519,27 @@ func (l *PackageList) FilterWithProgress(queries []PackageQuery, withDependencie

// try to satisfy dependencies
for _, dep := range missing {
// dependency might have already been satisfied
// with packages already been added
if result.Search(dep, false) != nil {
continue
if dependencyOptions&DepFollowAllVariants == 0 {
// dependency might have already been satisfied
// with packages already been added
//
// when follow-all-variants is enabled, we need to try to expand anyway,
// as even if dependency is satisfied now, there might be other ways to satisfy dependency
if result.Search(dep, false) != nil {
if dependencyOptions&DepVerboseResolve == DepVerboseResolve && progress != nil {
progress.ColoredPrintf("@{y}Already satisfied dependency@|: %s with %s", &dep, result.Search(dep, true))
}
continue
}
}

searchResults := l.Search(dep, true)
if len(searchResults) > 0 {
for _, p := range searchResults {
if result.Has(p) {
continue
}

if dependencyOptions&DepVerboseResolve == DepVerboseResolve && progress != nil {
progress.ColoredPrintf("@{g}Injecting package@|: %s", p)
}
Expand Down
7 changes: 7 additions & 0 deletions deb/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,13 @@ func ParseDependency(dep string) (d Dependency, err error) {
}

d.Pkg = strings.TrimSpace(dep[0:i])
if strings.ContainsRune(d.Pkg, ':') {
parts := strings.SplitN(d.Pkg, ":", 2)
d.Pkg, d.Architecture = parts[0], parts[1]
if d.Architecture == "any" {
d.Architecture = ""
}
}

rel := ""
if dep[i+1] == '>' || dep[i+1] == '<' || dep[i+1] == '=' {
Expand Down
14 changes: 14 additions & 0 deletions deb/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,20 @@ func (s *VersionSuite) TestParseDependency(c *C) {
c.Check(d.Version, Equals, "1.6")
c.Check(d.Architecture, Equals, "i386")

d, e = ParseDependency("python:any (>= 2.7~)")
c.Check(e, IsNil)
c.Check(d.Pkg, Equals, "python")
c.Check(d.Relation, Equals, VersionGreaterOrEqual)
c.Check(d.Version, Equals, "2.7~")
c.Check(d.Architecture, Equals, "")

d, e = ParseDependency("python:amd64 (>= 2.7~)")
c.Check(e, IsNil)
c.Check(d.Pkg, Equals, "python")
c.Check(d.Relation, Equals, VersionGreaterOrEqual)
c.Check(d.Version, Equals, "2.7~")
c.Check(d.Architecture, Equals, "amd64")

d, e = ParseDependency("dpkg{i386}")
c.Check(e, IsNil)
c.Check(d.Pkg, Equals, "dpkg")
Expand Down
1 change: 1 addition & 0 deletions system/t05_snapshot/PullSnapshot15Test_gold
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[snap1]: Snapshot from mirror [wheezy-main]: http://mirror.yandex.ru/debian/ wheezy
[snap2]: Snapshot from mirror [wheezy-backports]: http://mirror.yandex.ru/debian/ wheezy-backports
Already satisfied dependency: init-system-helpers (>= 1.18~) [i386] with [init-system-helpers_1.18~bpo70+1_all]
Building indexes...
Dependencies would be pulled into snapshot:
Injecting package: init-system-helpers_1.18~bpo70+1_all
Expand Down