mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-26 13:47:40 +00:00
Deduplicate variants slice before processing it.
This commit is contained in:
Vendored
+29
@@ -169,6 +169,33 @@ func (l *PackageList) Architectures() (result []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// depSliceDeduplicate removes dups in slice of Dependencies
|
||||||
|
func depSliceDeduplicate(s []Dependency) []Dependency {
|
||||||
|
l := len(s)
|
||||||
|
if l < 2 {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
if l == 2 {
|
||||||
|
if s[0] == s[1] {
|
||||||
|
return s[0:1]
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
found := make(map[string]bool, l)
|
||||||
|
j := 0
|
||||||
|
for i, x := range s {
|
||||||
|
h := x.Hash()
|
||||||
|
if !found[h] {
|
||||||
|
found[h] = true
|
||||||
|
s[j] = s[i]
|
||||||
|
j++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return s[:j]
|
||||||
|
}
|
||||||
|
|
||||||
// VerifyDependencies looks for missing dependencies in package list.
|
// VerifyDependencies looks for missing dependencies in package list.
|
||||||
//
|
//
|
||||||
// Analysis would be peformed for each architecture, in specified sources
|
// Analysis would be peformed for each architecture, in specified sources
|
||||||
@@ -189,6 +216,8 @@ func (l *PackageList) VerifyDependencies(options int, architectures []string, so
|
|||||||
return nil, fmt.Errorf("unable to process package %s: %s", p, err)
|
return nil, fmt.Errorf("unable to process package %s: %s", p, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variants = depSliceDeduplicate(variants)
|
||||||
|
|
||||||
variantsMissing := make([]Dependency, 0, len(variants))
|
variantsMissing := make([]Dependency, 0, len(variants))
|
||||||
missingCount := 0
|
missingCount := 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user