~rbn/packagetools

ca8c917f0f916bf0d56ee5ff492999ffd5c4f0d8 — Ruben Schuller 6 months ago 4686bbf
fix duplicate package upgrade lines

it is common practice to have multiple kernel-* packages installed to
have a fallback version. while upgrading, we only need to 'upgrade'
_one_ of the installed packages of the same name.

nb: it may be worth a thought to rewrite the whole package upgrading, but
it is fast enough for now, so that the double loop isn't too painful for
now.
1 files changed, 9 insertions(+), 2 deletions(-)

M packagetools.go
M packagetools.go => packagetools.go +9 -2
@@ 61,7 61,7 @@ func upgrade(repo string, prefixes []string, local string) ([]upgradeInfo, error
		return nil, err
	}

	out := []upgradeInfo{}
	upgrades := make(map[string]upgradeInfo)
	for _, localPkg := range localPkgs {
		match := upgradeInfo{}
		for _, repoPkg := range repoPkgs {


@@ 77,7 77,14 @@ func upgrade(repo string, prefixes []string, local string) ([]upgradeInfo, error
			continue
		}

		out = append(out, match)
		upgrades[localPkg.Name] = match
	}

	out := make([]upgradeInfo, len(upgrades))
	i := 0
	for _, v := range upgrades {
		out[i] = v
		i++
	}

	sort.Sort(upgradeInfoByName(out))