Control: severity -1 important
Control: tag -1 patch

Christoph Anton Mitterer <[email protected]> writes:

> The version in Debian stable suffers from:
> https://github.com/prometheus-community/node-exporter-textfile-collector-scripts/issues/193
> which causes upgrades no to appear in apt_upgrades_pending but only in
> apt_upgrades_held.
>
> This was fixed with upstream PR:
> https://github.com/prometheus-community/node-exporter-textfile-collector-scripts/pull/207


I noticed this for quite a while myself, and have missed a number of
security updates because of this bug. For this reason, I took the
liberty of marking this bug as "important".

Please consider the following patch that backports the change above:

diff --git a/debian/changelog b/debian/changelog
index 3233700..681c02b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+prometheus-node-exporter-collectors (0.0~git20230203.6f710f8-1+deb12u3) 
unstable; urgency=medium
+
+  * Non Maintainer Upload
+  * apt_info.py: fix apt_upgrades_pending and apt_upgrades_held, Closes: 
#1077694
+
+ -- Reinhard Tartler <[email protected]>  Sat, 02 Nov 2024 08:22:11 -0400
+
 prometheus-node-exporter-collectors (0.0~git20230203.6f710f8-1+deb12u2) 
bookworm; urgency=medium
 
   * Team upload
diff --git 
a/debian/patches/0001-apt_info.py-fix-apt_upgrades_pending-and-apt_upgrade.patch
 
b/debian/patches/0001-apt_info.py-fix-apt_upgrades_pending-and-apt_upgrade.patch
new file mode 100644
index 0000000..6af357f
--- /dev/null
+++ 
b/debian/patches/0001-apt_info.py-fix-apt_upgrades_pending-and-apt_upgrade.patch
@@ -0,0 +1,35 @@
+From: Reinhard Tartler <[email protected]>
+Date: Sat, 2 Nov 2024 08:20:41 -0400
+Subject: apt_info.py: fix apt_upgrades_pending and apt_upgrades_held
+
+Backported from
+https://github.com/prometheus-community/node-exporter-textfile-collector-scripts/pull/207
+---
+ apt_info.py | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/apt_info.py b/apt_info.py
+index 82ea4e5..804f89c 100755
+--- a/apt_info.py
++++ b/apt_info.py
+@@ -57,7 +57,7 @@ def _write_pending_upgrades(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_upgradable
+     }
+     _write_upgrade_info("apt_upgrades_pending", candidates)
+ 
+@@ -66,7 +66,10 @@ def _write_held_upgrades(cache):
+     print("# HELP apt_upgrades_held Apt packages pending updates but held 
back.")
+     print("# TYPE apt_upgrades_held gauge")
+ 
+-    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
++    }
+     _write_upgrade_info("apt_upgrades_held", held_candidates)
+ 
+ 
diff --git a/debian/patches/series b/debian/patches/series
index f5329fc..8ee1d54 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
 0001-do-not-run-apt-update-or-simulate-apt-dist-upgrade.patch
 0001-report-the-apt-cache-timestamp.patch
 0001-use-a-better-heuristic-for-the-apt-update-last-run-t.patch
+0001-apt_info.py-fix-apt_upgrades_pending-and-apt_upgrade.patch


Would you consider this NMU for a stable update?

Reply via email to