Skip to content

apt_info.py: fix apt_upgrades_pending and apt_upgrades_held #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading