From 89ca1eea99b91c1b612e6c5b0df01abaf79dc875 Mon Sep 17 00:00:00 2001 From: Germano Massullo Date: Wed, 9 Apr 2025 12:38:58 +0200 Subject: [PATCH] Adds 99-apcupsd-xfer-glitch.patch --- 99-apcupsd-xfer-glitch.patch | 61 ++++++++++++++++++++++++++++++++++++ apcupsd.spec | 11 +++++-- 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 99-apcupsd-xfer-glitch.patch diff --git a/99-apcupsd-xfer-glitch.patch b/99-apcupsd-xfer-glitch.patch new file mode 100644 index 0000000..2b2898d --- /dev/null +++ b/99-apcupsd-xfer-glitch.patch @@ -0,0 +1,61 @@ +diff -aruN apcupsd-3.14.14.orig/src/drivers/usb/usb.c apcupsd-3.14.14/src/drivers/usb/usb.c +--- apcupsd-3.14.14.orig/src/drivers/usb/usb.c 2024-02-24 20:22:42.007641242 +0100 ++++ apcupsd-3.14.14/src/drivers/usb/usb.c 2024-02-24 20:23:03.824987965 +0100 +@@ -42,7 +42,9 @@ + UpsDriver(ups), + _quirk_old_backups_pro(false), + _prev_time((struct timeval){0}), +- _bpcnt(0) ++ _bpcnt(0), ++ _bacnt(0), ++ _brcnt(0) + { + } + +@@ -410,8 +412,13 @@ + break; + + case CI_NeedReplacement: +- if (uval->iValue) +- _ups->set_replacebatt(uval->iValue); ++ if (uval->iValue) { ++ if (_brcnt++) { ++ _ups->set_replacebatt(uval->iValue); ++ } ++ } else { ++ _brcnt = 0; ++ } + Dmsg(200, "ReplaceBatt=%d\n", uval->iValue); + break; + +@@ -569,11 +576,15 @@ + * delayed. C'est la vie. + */ + if (uval->iValue) { +- if (_bpcnt++) ++ if (_bpcnt++) { ++ _bacnt = 0; + _ups->set_battpresent(); ++ } + } else { +- _bpcnt = 0; +- _ups->clear_battpresent(); ++ if (_bacnt++) { ++ _bpcnt = 0; ++ _ups->clear_battpresent(); ++ } + } + Dmsg(200, "BatteryPresent=%d\n", uval->iValue); + break; +diff -aruN apcupsd-3.14.14.orig/src/drivers/usb/usb.h apcupsd-3.14.14/src/drivers/usb/usb.h +--- apcupsd-3.14.14.orig/src/drivers/usb/usb.h 2024-02-24 20:22:42.007641242 +0100 ++++ apcupsd-3.14.14/src/drivers/usb/usb.h 2024-02-24 20:23:01.754956355 +0100 +@@ -86,6 +86,8 @@ + bool _quirk_old_backups_pro; + struct timeval _prev_time; + int _bpcnt; ++ int _bacnt; ++ int _brcnt; + }; + + /* Max rate to update volatile data */ diff --git a/apcupsd.spec b/apcupsd.spec index 46448cb..ae63fd3 100644 --- a/apcupsd.spec +++ b/apcupsd.spec @@ -4,7 +4,7 @@ Name: apcupsd Version: 3.14.14 -Release: 34%{?dist} +Release: 35%{?dist} Summary: APC UPS Power Control Daemon License: GPL-2.0-only @@ -23,7 +23,11 @@ Patch1: apcupsd-3.14.4-shutdown.patch # Fix format-security error so we can enable the checks Patch2: patch-format-security Patch3: disable_nologin.patch - +# fixes "increasing NUMXFERS" bug: +# https://sourceforge.net/p/apcupsd/mailman/apcupsd-users/thread/ad9afb27-30f9-443f-a9fb-982c41ad1325%40okazoo.eu/ +# https://www.reddit.com/r/homelab/comments/1c3eo9n/apcupsd_and_proxmox_frequent_battery_disconnected/ +# patch source: https://sourceforge.net/p/apcupsd/mailman/message/58741334/ +Patch4: 99-apcupsd-xfer-glitch.patch BuildRequires: gcc-c++ BuildRequires: glibc-devel, gd-devel @@ -173,6 +177,9 @@ rm examples/*.in %changelog +* Wed Apr 09 2025 Germano Massullo - 3.14.14-35 +- Adds 99-apcupsd-xfer-glitch.patch + * Thu Jan 16 2025 Fedora Release Engineering - 3.14.14-34 - Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild