mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-30 23:17:51 -04:00
sysupdate: collapse dnf rows duplicated across repos (#3524)
dnf prints one row per (package, repo), so a package offered at the same version by two enabled repos is listed twice and inflates the pending count. Key the parse on (name.arch, version) and keep the first row.
This commit is contained in:
2 files changed
+33
No files matched your search
@@ -115,6 +115,7 @@ func parseDnfList(text, backendID string, installed map[string]string) []Package
|
||||
return nil
|
||||
}
|
||||
var pkgs []Package
|
||||
seen := make(map[string]struct{})
|
||||
for line := range strings.SplitSeq(text, "\n") {
|
||||
fields := strings.Fields(line)
|
||||
if len(fields) < 2 {
|
||||
@@ -129,6 +130,12 @@ func parseDnfList(text, backendID string, installed map[string]string) []Package
|
||||
if !looksLikeRpmVersion(version) {
|
||||
continue
|
||||
}
|
||||
// dnf prints one row per (package, repo), so one version in two repos appears twice
|
||||
key := nameArch + "\t" + version
|
||||
if _, dup := seen[key]; dup {
|
||||
continue
|
||||
}
|
||||
seen[key] = struct{}{}
|
||||
name := nameArch[:dot]
|
||||
pkgs = append(pkgs, Package{
|
||||
Name: nameArch,
|
||||
|
||||
@@ -55,6 +55,32 @@ bash.x86_64 5.2.40-1.fc41 updates`,
|
||||
backendID: "dnf",
|
||||
want: nil,
|
||||
},
|
||||
{
|
||||
name: "one package offered by two repos is reported once",
|
||||
input: `dms-greeter.x86_64 1.5.1-1.fc44 copr:copr.fedorainfracloud.org:avengemedia:danklinux
|
||||
dms-greeter.x86_64 1.5.1-1.fc44 coprdep:copr.fedorainfracloud.org:avengemedia:danklinux`,
|
||||
backendID: "dnf5",
|
||||
installed: map[string]string{"dms-greeter": "1.5.0-1.fc44"},
|
||||
want: []Package{
|
||||
{Name: "dms-greeter.x86_64", Repo: RepoSystem, Backend: "dnf5", FromVersion: "1.5.0-1.fc44", ToVersion: "1.5.1-1.fc44"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "duplicate rows do not suppress other packages or differing versions",
|
||||
input: `bash.x86_64 5.2.40-1.fc41 updates
|
||||
bash.x86_64 5.2.40-1.fc41 fedora
|
||||
bash.i686 5.2.40-1.fc41 updates
|
||||
kernel.x86_64 6.14.2-1.fc41 updates
|
||||
kernel.x86_64 6.14.3-1.fc41 updates`,
|
||||
backendID: "dnf5",
|
||||
installed: map[string]string{"bash": "5.2.39-1.fc41", "kernel": "6.14.1-1.fc41"},
|
||||
want: []Package{
|
||||
{Name: "bash.x86_64", Repo: RepoSystem, Backend: "dnf5", FromVersion: "5.2.39-1.fc41", ToVersion: "5.2.40-1.fc41"},
|
||||
{Name: "bash.i686", Repo: RepoSystem, Backend: "dnf5", FromVersion: "5.2.39-1.fc41", ToVersion: "5.2.40-1.fc41"},
|
||||
{Name: "kernel.x86_64", Repo: RepoSystem, Backend: "dnf5", FromVersion: "6.14.1-1.fc41", ToVersion: "6.14.2-1.fc41"},
|
||||
{Name: "kernel.x86_64", Repo: RepoSystem, Backend: "dnf5", FromVersion: "6.14.1-1.fc41", ToVersion: "6.14.3-1.fc41"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "skips dnf5 banner / column header lines",
|
||||
input: `Updates available
|
||||
|
||||
Reference in new issue
Block a user