Skip to content

Commit

Permalink
apt_info.py: fix apt_upgrades_pending and apt_upgrades_held (#207)
Browse files Browse the repository at this point in the history
* apt_info.py: fix apt_upgrades_pending and apt_upgrades_held
* No need to test if package is installed for upgradable packages

Signed-off-by: kennethso168 <kennethso168@gmail.com>
  • Loading branch information
kennethso168 committed Apr 27, 2024
1 parent bfc8aa9 commit 1cb6223
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions apt_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,8 @@ def _convert_candidates_to_upgrade_infos(candidates):


def _write_pending_upgrades(registry, cache):
# Discount any changes that apply to packages that aren't installed (e.g.
# count an upgrade to package A that adds a new dependency on package B as
# only one upgrade, not two). See the following issue for more details:
# https://github.com/prometheus-community/node-exporter-textfile-collector-scripts/issues/85
candidates = {
p.candidate for p in cache.get_changes() if p.is_installed and p.marked_upgrade
p.candidate for p in cache if p.is_upgradable
}
upgrade_list = _convert_candidates_to_upgrade_infos(candidates)

Expand All @@ -69,7 +65,10 @@ def _write_pending_upgrades(registry, cache):


def _write_held_upgrades(registry, cache):
held_candidates = {p.candidate for p in cache if p.is_upgradable and p.marked_keep}
held_candidates = {
p.candidate for p in cache
if p.is_upgradable and p._pkg.selected_state == apt_pkg.SELSTATE_HOLD
}
upgrade_list = _convert_candidates_to_upgrade_infos(held_candidates)

if upgrade_list:
Expand Down

0 comments on commit 1cb6223

Please sign in to comment.