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.service b/apcupsd.service index 614fec2..2e199ff 100644 --- a/apcupsd.service +++ b/apcupsd.service @@ -5,7 +5,7 @@ After=network-online.target [Service] ExecStartPre=-/bin/rm -f /etc/apcupsd/powerfail -ExecStart=/sbin/apcupsd -b -f /etc/apcupsd/apcupsd.conf +ExecStart=/usr/bin/apcupsd -b -f /etc/apcupsd/apcupsd.conf KillMode=process [Install] diff --git a/apcupsd.spec b/apcupsd.spec index 5767004..dde0ac9 100644 --- a/apcupsd.spec +++ b/apcupsd.spec @@ -4,10 +4,10 @@ Name: apcupsd Version: 3.14.14 -Release: 27%{?dist} +Release: 40%{?dist} Summary: APC UPS Power Control Daemon -License: GPLv2 +License: GPL-2.0-only URL: http://www.apcupsd.com Source0: https://downloads.sourceforge.net/apcupsd/apcupsd-%version.tar.gz Source1: apcupsd.service @@ -22,11 +22,22 @@ Patch0: apcupsd-3.14.9-fixgui.patch 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 -BuildRequires: net-snmp-devel, libusb-compat-0.1-devel +%if %{defined fedora} || (%{defined rhel} && 0%{?rhel} > 9) +BuildRequires: libusb-compat-0.1-devel +%endif +%if (%{defined rhel} && 0%{?rhel} <= 9) +BuildRequires: libusb-devel +%endif +BuildRequires: net-snmp-devel, BuildRequires: gtk2-devel, GConf2-devel, desktop-file-utils # /sbin/shutdown is required to be present when building # Somehow in F36 systemd is installed in mock but not in koji @@ -76,7 +87,7 @@ printf 'install:\n\techo skipped\n' > platforms/redhat/Makefile %configure \ --sysconfdir="/etc/apcupsd" \ --with-cgi-bin="/var/www/apcupsd" \ - --sbindir=/sbin \ + --sbindir=%{_bindir} \ --enable-cgi \ --enable-pthreads \ --enable-net \ @@ -133,7 +144,11 @@ rm examples/*.in %config(noreplace) /etc/apcupsd/onbattery %config(noreplace) /etc/logrotate.d/apcupsd /usr/share/hal/fdi/policy/20thirdparty/80-apcupsd-ups-policy.fdi -%attr(0755,root,root) /sbin/* +%{_bindir}/apcaccess +%{_bindir}/apctest +%{_bindir}/apcupsd +%exclude %{_bindir}/smtp + %{_mandir}/*/* %files cgi @@ -166,6 +181,46 @@ rm examples/*.in %changelog +* Fri Jan 16 2026 Fedora Release Engineering - 3.14.14-40 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild + +* Wed Jul 23 2025 Fedora Release Engineering - 3.14.14-39 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + +* Thu May 22 2025 Gwyn Ciesla - 3.14.14-38 +- Don't ship /usr/bin/smtp, not used, conflicts with opensmtpd. + +* Fri May 09 2025 Gwyn Ciesla - 3.14.14-37 +- Move binaries from sbin to bin, 2365293. + +* Wed Apr 23 2025 Davide Cavalca - 3.14.14-36 +- Fix libusb conditional to make it build on EPEL 10 + Fixes: RHBZ#2337139 + +* 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 + +* Fri Nov 08 2024 Germano Massullo - 3.14.14-33 +- Adds distinction between Fedora and EL <= 9 for BuildRequires: libusb + +* Fri Nov 08 2024 Germano Massullo - 3.14.14-32 +- release bump + +* Fri Nov 08 2024 Germano Massullo - 3.14.14-31 +- Adds disable_nologin.patch + +* Sun Jan 07 2024 Germano Massullo - 3.14.14-30 +- disables apcupsd-3.14.4-shutdown.patch + +* Wed Jul 19 2023 Fedora Release Engineering - 3.14.14-29 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Wed Jan 18 2023 Fedora Release Engineering - 3.14.14-28 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + * Tue Aug 02 2022 Jason L Tibbitts III - 3.14.14-27 - Depend on libusb-compat-0.1-devel to avoid build breakage. diff --git a/disable_nologin.patch b/disable_nologin.patch new file mode 100644 index 0000000..81fefc7 --- /dev/null +++ b/disable_nologin.patch @@ -0,0 +1,18 @@ +diff -urNr apcupsd-3.14.14-orig/src/action.c apcupsd-3.14.14/src/action.c +--- apcupsd-3.14.14-orig/src/action.c 2015-03-20 04:59:41.000000000 +0100 ++++ apcupsd-3.14.14/src/action.c 2024-11-08 16:48:46.095910557 +0100 +@@ -189,13 +189,7 @@ + + static void prohibit_logins(UPSINFO *ups) + { +- if (ups->nologin_file) +- return; /* already done */ +- +- logonfail(ups, 0); +- ups->nologin_file = true; +- +- log_event(ups, LOG_ALERT, "User logins prohibited"); ++ return; + } + + static void do_shutdown(UPSINFO *ups, int cmdtype)