From 093a1fe493417e6857205aa74cd69d08400b6ae9 Mon Sep 17 00:00:00 2001 From: kennethso168 Date: Sun, 10 Mar 2024 11:51:48 +0800 Subject: [PATCH] apt_info.py: fix apt_upgrades_pending and apt_upgrades_held Signed-off-by: kennethso168 --- apt_info.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apt_info.py b/apt_info.py index c783227..b518f40 100755 --- a/apt_info.py +++ b/apt_info.py @@ -57,7 +57,7 @@ def _write_pending_upgrades(registry, cache): # 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_installed and p.is_upgradable } upgrade_list = _convert_candidates_to_upgrade_infos(candidates) @@ -69,7 +69,9 @@ 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: