Fix versioned dep checking

Before versioned deps with the same name would be combined into a single
version range.

For example:
`foo>1 foo>3 foo<4 foo<5` would be merged into the range `3<foo<4`

This was assumed to be fine because of course no package is going to
have conflicting dependencies `foo>3 foo<1` but what was not thought
about it that a package or packages could provide multiple versions of
a provider. Java being example, you could have 8 and 9 provided for at
the same time.

This then causes a problem when you try to install two packages at once,
one requiring `java<8` and the other `java>9` when combined this leads
to a range that can not be satisfied.

Instead we now never merge dependencies but check them all individually.

We also make sure to pull in all already installed providers. The reason
for this is, before if a package did not apear in the dep tree we
assumed it to be satisfied because of the .FindSatisfier in the dep
resolving. So if you installed a package that needs `foo=1` and you
already had a package providing that it would not be in the dep tree and
we assume it is fine. But if you install a package that needs `foo=1`
and install a package that prvoides `foo=2` then foo will all of
a sudden be in the dep tree but only version 2 will be there. For this
reason we also load all the already installed packages in so that the
`foo=1` will be there.
This commit is contained in:
morganamilo 2018-04-03 01:25:47 +01:00
parent f986895aa2
commit 6125dd979e
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E
2 changed files with 28 additions and 6 deletions

View file

@ -543,15 +543,23 @@ func depTreeRecursive(dt *depTree, localDb *alpm.Db, syncDb alpm.DbList, isMake
}
func checkVersions(dt *depTree) error {
depStrings := make([]string, 0)
has := make(map[string][]string)
allDeps := make([]*gopkg.Dependency, 0)
localDb, err := alpmHandle.LocalDb()
if err != nil {
return err
}
for _, pkg := range dt.Aur {
for _, deps := range [3][]string{pkg.Depends, pkg.MakeDepends, pkg.CheckDepends} {
for _, dep := range deps {
_, _dep := splitNameFromDep(dep)
if _dep != "" {
depStrings = append(depStrings, dep)
deps, _ := gopkg.ParseDeps([]string{dep})
if deps[0] != nil {
allDeps = append(allDeps, deps[0])
}
}
}
}
@ -573,7 +581,10 @@ func checkVersions(dt *depTree) error {
for _, pkg := range dt.Repo {
pkg.Depends().ForEach(func(dep alpm.Depend) error {
if dep.Mod != alpm.DepModAny {
depStrings = append(depStrings, dep.String())
deps, _ := gopkg.ParseDeps([]string{dep.String()})
if deps[0] != nil {
allDeps = append(allDeps, deps[0])
}
}
return nil
})
@ -592,9 +603,21 @@ func checkVersions(dt *depTree) error {
}
deps, _ := gopkg.ParseDeps(depStrings)
localDb.PkgCache().ForEach(func(pkg alpm.Package) error {
pkg.Provides().ForEach(func(dep alpm.Depend) error {
if dep.Mod != alpm.DepModAny {
addMapStringSlice(has, dep.Name, dep.Version)
} else {
delete(has, dep.Name)
}
for _, dep := range deps {
return nil
})
return nil
})
for _, dep := range allDeps {
satisfied := false
verStrs, ok := has[dep.Name]
if !ok {

View file

@ -72,7 +72,6 @@ func install(parser *arguments) error {
parser.targets.set(name)
}
requestTargets = parser.targets.toSlice()
if len(dt.Missing) > 0 {