Skip to content

Commit

Permalink
pkgInfo: Filter out apt packages without a candidate, they're
Browse files Browse the repository at this point in the history
broken to mintinstall/mintcommon.

apt pkginfo: Check for a package candidate before accessing it.

This second change isn't currently necessary if we're filtering
these candidate-less packages now, but we're currently missing
runtime updating of un-cached (recently installed and/or foreign)
apt packages. We do this with flatpaks already, we should for debs
as well.
  • Loading branch information
mtwebster committed Jul 17, 2024
1 parent c34809f commit d093830
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
23 changes: 12 additions & 11 deletions usr/lib/python3/dist-packages/mintcommon/installer/_apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def process_full_apt_cache(cache):
continue
if name == "pepperflashplugin-nonfree": # formerly marked broken, it's now a dummy and has no dependents (and only exists in Mint 20).
continue
if pkg.candidate is None:
continue
if ":" in name and name.split(":")[0] in keys:
continue
try:
Expand All @@ -109,19 +111,18 @@ def process_full_apt_cache(cache):

pkg_hash = make_pkg_hash(pkg)

if pkg.candidate:
section_string = pkg.candidate.section
section_string = pkg.candidate.section

if "/" in section_string:
section = section_string.split("/")[1]
else:
section = section_string
if "/" in section_string:
section = section_string.split("/")[1]
else:
section = section_string

try:
sections[section].append(pkg_hash)
except Exception:
sections[section] = []
sections[section].append(pkg_hash)
try:
sections[section].append(pkg_hash)
except Exception:
sections[section] = []
sections[section].append(pkg_hash)

cache[pkg_hash] = AptPkgInfo(pkg_hash, pkg)

Expand Down
6 changes: 4 additions & 2 deletions usr/lib/python3/dist-packages/mintcommon/installer/pkgInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ def get_version(self, apt_pkg=None):
if apt_pkg.is_installed:
self.version = apt_pkg.installed.version
else:
self.version = apt_pkg.candidate.version
if apt_pkg.candidate is not None:
self.version = apt_pkg.candidate.version

if self.version is None:
self.version = ""
Expand All @@ -233,7 +234,8 @@ def get_homepage_url(self, apt_pkg=None):
if apt_pkg.is_installed:
self.homepage_url = apt_pkg.installed.homepage
else:
self.homepage_url = apt_pkg.candidate.homepage
if apt_pkg.candidate is not None:
self.homepage_url = apt_pkg.candidate.homepage

if self.homepage_url is None:
self.homepage_url = ""
Expand Down

0 comments on commit d093830

Please sign in to comment.