From 2fbfbc4de1e0a8c9c286a118dc6e5004e2b59e28 Mon Sep 17 00:00:00 2001 From: morganamilo Date: Thu, 1 Mar 2018 14:52:57 +0000 Subject: [PATCH] Fix duplicate packages when printing dependencies e01c4b396992f8505b1087691c13f918ba170ced made some bad assumptions. Removing the aliases caused packages to not installed when required only through provides and not their package name. This fixes that by re enabling the aliases and simply removing duplicates at the end. --- dependencies.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dependencies.go b/dependencies.go index 792ebd38..eeae7aea 100644 --- a/dependencies.go +++ b/dependencies.go @@ -99,6 +99,20 @@ func getDepCatagories(pkgs []string, dt *depTree) (*depCatagories, error) { }) } + dupes := make(map[*alpm.Package]struct{}) + filteredRepo := make([]*alpm.Package, 0) + + for _, pkg := range dc.Repo { + _, ok := dupes[pkg] + if ok { + continue + } + dupes[pkg] = struct{}{} + filteredRepo = append(filteredRepo, pkg) + } + + dc.Repo = filteredRepo + return dc, nil }