Prefer exact match on package name over provides match

When searching for packages which might satisfy given dependency,
aptly was first returning packages which `Provides` mentioned
name. By default aptly is picking up only first match (unless
follow all variants options is enabled), so `Provides:` takes
precedence over exact package name match.

Invert this logic by searching first for package name match.
This commit is contained in:
Andrey Smirnov
2017-09-25 18:24:45 +03:00
parent 325d391007
commit 6d2f265980
4 changed files with 15 additions and 12 deletions

View File

@@ -441,18 +441,6 @@ func (l *PackageList) Search(dep Dependency, allMatches bool) (searchResults []*
panic("list not indexed, can't search")
}
if dep.Relation == VersionDontCare {
for _, p := range l.providesIndex[dep.Pkg] {
if dep.Architecture == "" || p.MatchesArchitecture(dep.Architecture) {
searchResults = append(searchResults, p)
if !allMatches {
break
}
}
}
}
i := sort.Search(len(l.packagesIndex), func(j int) bool { return l.packagesIndex[j].Name >= dep.Pkg })
for i < len(l.packagesIndex) && l.packagesIndex[i].Name == dep.Pkg {
@@ -468,6 +456,18 @@ func (l *PackageList) Search(dep Dependency, allMatches bool) (searchResults []*
i++
}
if dep.Relation == VersionDontCare {
for _, p := range l.providesIndex[dep.Pkg] {
if dep.Architecture == "" || p.MatchesArchitecture(dep.Architecture) {
searchResults = append(searchResults, p)
if !allMatches {
break
}
}
}
}
return
}

View File

@@ -85,6 +85,7 @@ tar_1.26+dfsg-0.1_amd64
tar_1.26+dfsg-0.1_i386
ttf-bitstream-vera_1.10-8_all
ttf-dejavu-core_2.33-3_all
ttf-freefont_20120503-1_all
ucf_3.0025+nmu3_all
x11-common_1:7.7+3~deb7u1_all
xfonts-encodings_1:1.0.4-1_all

View File

@@ -85,6 +85,7 @@ tar_1.26+dfsg-0.1_amd64
tar_1.26+dfsg-0.1_i386
ttf-bitstream-vera_1.10-8_all
ttf-dejavu-core_2.33-3_all
ttf-freefont_20120503-1_all
ucf_3.0025+nmu3_all
x11-common_1:7.7+3~deb7u1_all
xfonts-encodings_1:1.0.4-1_all

View File

@@ -85,6 +85,7 @@ tar_1.26+dfsg-0.1_amd64
tar_1.26+dfsg-0.1_i386
ttf-bitstream-vera_1.10-8_all
ttf-dejavu-core_2.33-3_all
ttf-freefont_20120503-1_all
ucf_3.0025+nmu3_all
x11-common_1:7.7+3~deb7u1_all
xfonts-encodings_1:1.0.4-1_all