[packages/apcupsd] add fedora patches; including systemd support
glen
glen at pld-linux.org
Fri Jan 31 00:53:35 CET 2014
commit 76fc63052038d9c802ba1d7e911445cef4cda381
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Fri Jan 31 01:52:55 2014 +0200
add fedora patches; including systemd support
apcupsd.spec | 29 +++++++++--
cxxld.patch | 19 +++++++
fixgui.patch | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nodbg.patch | 28 ++++++++++
shutdown.patch | 14 +++++
systemd.patch | 28 ++++++++++
6 files changed, 276 insertions(+), 3 deletions(-)
---
diff --git a/apcupsd.spec b/apcupsd.spec
index 450ba29..976780f 100644
--- a/apcupsd.spec
+++ b/apcupsd.spec
@@ -11,7 +11,7 @@ Summary: Power management software for APC UPS hardware
Summary(pl.UTF-8): Oprogramowanie do zarządzania energią dla UPS-ów APC
Name: apcupsd
Version: 3.14.10
-Release: 3
+Release: 4
License: GPL v2
Group: Networking/Daemons
Source0: http://downloads.sourceforge.net/apcupsd/%{name}-%{version}.tar.gz
@@ -22,6 +22,11 @@ Source3: %{name}.sysconfig
Patch0: %{name}-configure.patch
Patch1: %{name}-pcnet-seconds.patch
Patch2: format-security.patch
+Patch3: shutdown.patch
+Patch4: cxxld.patch
+Patch5: systemd.patch
+Patch6: fixgui.patch
+Patch7: nodbg.patch
URL: http://www.apcupsd.com/
%{?with_gapcmon:BuildRequires: GConf2-devel >= 2.0}
BuildRequires: autoconf
@@ -31,11 +36,13 @@ BuildRequires: gd-devel
BuildRequires: man-db
%{?with_snmp:BuildRequires: net-snmp-devel}
BuildRequires: pkgconfig
-BuildRequires: rpmbuild(macros) >= 1.268
+BuildRequires: rpmbuild(macros) >= 1.647
BuildRequires: util-linux
+Requires: systemd-units >= 0.38
+Requires: rc-scripts
Requires(post): fileutils
Requires(post,preun): /sbin/chkconfig
-Requires: rc-scripts
+Requires(post,preun,postun): systemd-units >= 38
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%define _sysconfdir /etc/apcupsd
@@ -91,6 +98,11 @@ serwera NIS. Status każdego UPS-a przedstawia ikona.
%patch0 -p1
%patch1 -p1
%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+%patch7 -p1
%build
for i in configure.in aclocal.m4 config.h.in; do install autoconf/$i .;done
@@ -130,6 +142,10 @@ install -p %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/apcupsd
cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/logrotate.d/apcupsd
cp -p %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/apcupsd
+# systemd support
+install -p -D apcupsd.service $RPM_BUILD_ROOT%{systemdunitdir}/apcupsd.service
+install -p -D apcupsd_shutdown $RPM_BUILD_ROOT%{systemdunitdir}-shutdown/apcupsd_shutdown
+
touch $RPM_BUILD_ROOT/var/log/apcupsd.events
touch $RPM_BUILD_ROOT/var/lib/apcupsd/apcupsd.status
@@ -147,12 +163,17 @@ rm -rf $RPM_BUILD_ROOT
%post
/sbin/chkconfig --add apcupsd
%service apcupsd restart "apcupsd daemon"
+%systemd_post %{name}.service
%preun
if [ "$1" = "0" ]; then
%service apcupsd stop
/sbin/chkconfig --del apcupsd
fi
+%systemd_preun %{name}.service
+
+%postun
+%systemd_reload
%files
%defattr(644,root,root,755)
@@ -177,6 +198,8 @@ fi
%endif
%attr(754,root,root) /etc/rc.d/init.d/apcupsd
%attr(754,root,root) /etc/rc.d/init.d/halt
+%{systemdunitdir}/%{name}.service
+%attr(755,root,root) %{systemdunitdir}-shutdown/apcupsd_shutdown
%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/logrotate.d/apcupsd
%dir %{_sysconfdir}
%dir /var/lib/apcupsd
diff --git a/cxxld.patch b/cxxld.patch
new file mode 100644
index 0000000..d9a2544
--- /dev/null
+++ b/cxxld.patch
@@ -0,0 +1,19 @@
+fix FTBFS, c++ linking needs -lstdc++ explicitly
+https://bugzilla.redhat.com/show_bug.cgi?id=631288
+
+diff -up apcupsd-3.14.8/src/Makefile.cxxld apcupsd-3.14.8/src/Makefile
+--- apcupsd-3.14.8/src/Makefile.cxxld 2009-09-30 01:20:45.000000000 +0200
++++ apcupsd-3.14.8/src/Makefile 2010-09-22 11:18:03.550601657 +0200
+@@ -26,10 +26,10 @@ SRCS = $(common_srcs) $(apcupsd_srcs) $(
+ all-targets: apcupsd apcaccess apctest smtp
+
+ apcupsd: $(common_obj) $(apcupsd_obj) $(APCDRVLIBS) $(APCLIBS)
+- $(LINK) $(DRVLIBS)
++ $(LINK) -lstdc++ $(DRVLIBS)
+
+ apctest: $(common_obj) $(apctest_obj) $(APCDRVLIBS) $(APCLIBS)
+- $(LINK) $(DRVLIBS)
++ $(LINK) -lstdc++ $(DRVLIBS)
+
+ apcaccess: $(apcaccess_obj) $(APCLIBS)
+ $(LINK)
diff --git a/fixgui.patch b/fixgui.patch
new file mode 100644
index 0000000..dc256df
--- /dev/null
+++ b/fixgui.patch
@@ -0,0 +1,161 @@
+fix crash in gui, rhbz#578276
+https://bugzilla.redhat.com/show_bug.cgi?id=578276
+
+--- apcupsd-3.14.9/src/gapcmon/gapcmon.c.timeout 2008-09-16 06:58:20.000000000 +0200
++++ apcupsd-3.14.9/src/gapcmon/gapcmon.c 2011-10-12 20:10:52.986362156 +0200
+@@ -179,6 +179,54 @@ struct hostent * gethostname_re
+ */
+ static gboolean lg_graph_debug = FALSE;
+
++static GSList *timeout_list = NULL;
++
++static inline timeout_t * new_timeout(guint id, timeout_type_t type, void *data) {
++ timeout_t *timeout = (timeout_t *) malloc(sizeof(timeout_t));
++
++ timeout->id = id;
++ timeout->type = type;
++ timeout->data = data;
++ return timeout;
++}
++
++/* callback will check if timeout is associated with window
++ * which is about to be destroyed and it will call g_source_remove
++ * in order to prevent the callback associated with timeout to be executed
++ */
++static void remove_timeout(gpointer tmo, gpointer data) {
++ timeout_t * timeout = (timeout_t *) tmo;
++ PGAPC_MONITOR monitor = (PGAPC_MONITOR) data;
++ int delete_timeout = 0;
++
++ if (timeout == NULL) {
++ return;
++ }
++
++ switch (timeout->type) {
++ case GRAPH:
++ if (timeout->data == (void *) monitor->phs.plg) {
++ delete_timeout = 1;
++ }
++ break;
++ case MONITOR:
++ if (timeout->data == (void *) monitor) {
++ delete_timeout = 1;
++ }
++ break;
++
++ case HISTORY:
++ if (timeout->data == (void *) &(monitor->phs)) {
++ delete_timeout = 1;
++ }
++ break;
++ }
++
++ if (delete_timeout) {
++ g_source_remove(timeout->id);
++ timeout_list = g_slist_remove(timeout_list, (gconstpointer) timeout);
++ }
++}
+
+ /* ************************************************************************* */
+
+@@ -1376,8 +1424,8 @@ static gint lg_graph_configure_event_cb
+ plg->x_range.i_minor_inc = plg->plot_box.width / plg->x_range.i_num_minor;
+ plg->x_range.i_major_inc = plg->plot_box.width / plg->x_range.i_num_major;
+
+- g_timeout_add (250, (GSourceFunc) lg_graph_draw, plg);
+-
++ guint tid = g_timeout_add (250, (GSourceFunc) lg_graph_draw, plg);
++ timeout_list = g_slist_append(timeout_list, new_timeout(tid, GRAPH, (void *) plg));
+ return TRUE;
+ }
+
+@@ -1745,7 +1793,8 @@ static gboolean cb_monitor_automatic_ref
+ return FALSE; /* stop timers */
+
+ if (pm->b_timer_control) {
+- g_timeout_add(100, (GSourceFunc) cb_monitor_refresh_control, pm);
++ guint tid = g_timeout_add(100, (GSourceFunc) cb_monitor_refresh_control, pm);
++ timeout_list = g_slist_append(timeout_list, new_timeout(tid, MONITOR, (void *) pm));
+ return FALSE;
+ }
+
+@@ -4543,9 +4592,9 @@ static void cb_monitor_interface_button_
+ }
+
+ g_async_queue_push(pm->q_network, pm);
+- g_timeout_add(GAPC_REFRESH_FACTOR_ONE_TIME,
++ guint tid = g_timeout_add(GAPC_REFRESH_FACTOR_ONE_TIME,
+ (GSourceFunc) cb_monitor_dedicated_one_time_refresh, pm);
+-
++ timeout_list = g_slist_append(timeout_list, new_timeout(tid, MONITOR, (void *) pm));
+ return;
+ }
+
+@@ -5174,6 +5223,9 @@ static void cb_monitor_interface_destroy
+ g_source_remove(pm->tid_automatic_refresh);
+ }
+
++ /* iterate through list of timers and remove all timers associated with this monitor */
++ g_slist_foreach(timeout_list, remove_timeout, (gpointer) pm);
++
+ if (pm->tid_thread_qwork != NULL) {
+ pm->b_thread_stop = TRUE;
+ g_async_queue_push(pm->q_network, pm);
+@@ -5537,9 +5589,9 @@ static gint gapc_monitor_history_page(PG
+
+ /* collect one right away */
+ pphs->b_startup = TRUE;
+- g_timeout_add((guint) (pm->d_refresh * GAPC_REFRESH_FACTOR_1K + 75),
++ guint tid = g_timeout_add((guint) (pm->d_refresh * GAPC_REFRESH_FACTOR_1K + 75),
+ (GSourceFunc) cb_util_line_chart_refresh, pphs);
+-
++ timeout_list = g_slist_append(timeout_list, new_timeout(tid, HISTORY, (void *) pphs));
+ return i_page;
+ }
+
+@@ -5565,7 +5617,8 @@ static gboolean cb_util_line_chart_refre
+ return FALSE;
+
+ if (pm->b_graph_control) {
+- g_timeout_add(100, (GSourceFunc) cb_util_line_chart_refresh_control, pm);
++ guint tid = g_timeout_add(100, (GSourceFunc) cb_util_line_chart_refresh_control, pm);
++ timeout_list = g_slist_append(timeout_list, new_timeout(tid, MONITOR, (void *) pm));
+ return FALSE;
+ }
+
+@@ -6392,6 +6445,7 @@ extern int main(int argc, char *argv[])
+ PGAPC_CONFIG pcfg = NULL;
+ GtkWidget *window = NULL;
+
++ timeout_list = g_slist_alloc();
+ /*
+ * Initialize GLib thread support, and GTK
+ */
+@@ -6435,5 +6489,6 @@ extern int main(int argc, char *argv[])
+ gdk_flush();
+ gdk_threads_leave();
+
++ g_slist_free(timeout_list);
+ return (0);
+ }
+--- apcupsd-3.14.9/src/gapcmon/gapcmon.h 2011-10-12 20:12:54.584317583 +0200
++++ apcupsd-3.14.9/src/gapcmon/gapcmon.h.timeout 2011-10-12 20:14:10.965669911 +0200
+@@ -403,6 +403,18 @@ typedef struct _System_Control_Data {
+
+ } GAPC_CONFIG, *PGAPC_CONFIG;
+
++typedef enum {
++ GRAPH,
++ MONITOR,
++ HISTORY
++} timeout_type_t;
++
++typedef struct {
++ guint id;
++ timeout_type_t type;
++ void *data;
++} timeout_t;
++
+ /* ************************************************************************* */
+
+ #define GAPC_GLOSSARY "<span size=\"xx-large\"><b>GAPCMON</b></span>\n \
diff --git a/nodbg.patch b/nodbg.patch
new file mode 100644
index 0000000..1241bef
--- /dev/null
+++ b/nodbg.patch
@@ -0,0 +1,28 @@
+https://bugzilla.redhat.com/show_bug.cgi?id=1053324
+
+diff -up apcupsd-3.14.10/src/drivers/snmplite/asn.cpp.nodbg apcupsd-3.14.10/src/drivers/snmplite/asn.cpp
+--- apcupsd-3.14.10/src/drivers/snmplite/asn.cpp.nodbg 2010-09-07 17:35:13.000000000 +0200
++++ apcupsd-3.14.10/src/drivers/snmplite/asn.cpp 2014-01-21 17:07:27.603049214 +0100
+@@ -26,10 +26,13 @@
+ #include <stdlib.h>
+ #include <stdio.h>
+
++extern int debug_level;
++
+ using namespace Asn;
+
+ void debug(const char *foo, int indent)
+ {
++ if (!debug_level) return;
+ while (indent--)
+ printf(" ");
+ printf("%s\n", foo);
+@@ -86,7 +89,7 @@ Object *Object::Demarshal(unsigned char
+ obj = new Sequence(type);
+ break;
+ default:
+- printf("UNKNOWN ASN type=0x%02x\n", type);
++ if (debug_level) printf("UNKNOWN ASN type=0x%02x\n", type);
+ debug("UNKNOWN", indent);
+ obj = NULL;
+ break;
diff --git a/shutdown.patch b/shutdown.patch
new file mode 100644
index 0000000..9cfb595
--- /dev/null
+++ b/shutdown.patch
@@ -0,0 +1,14 @@
+https://bugzilla.redhat.com/show_bug.cgi?id=348701
+
+diff -up apcupsd-3.14.4/platforms/apccontrol.in.shutdown apcupsd-3.14.4/platforms/apccontrol.in
+--- apcupsd-3.14.4/platforms/apccontrol.in.shutdown 2008-05-28 09:15:47.000000000 +0200
++++ apcupsd-3.14.4/platforms/apccontrol.in 2008-05-28 09:16:04.000000000 +0200
+@@ -104,7 +104,7 @@ case "$1" in
+ ;;
+ doshutdown)
+ echo "UPS ${2} initiated Shutdown Sequence" | ${WALL}
+- ${SHUTDOWN} -h now "apcupsd UPS ${2} initiated shutdown"
++ ${SHUTDOWN} -h -H now "apcupsd UPS ${2} initiated shutdown"
+ ;;
+ annoyme)
+ echo "Power problems with UPS ${2}. Please logoff." | ${WALL}
diff --git a/systemd.patch b/systemd.patch
new file mode 100644
index 0000000..755fff2
--- /dev/null
+++ b/systemd.patch
@@ -0,0 +1,28 @@
+diff -up apcupsd-3.14.8/apcupsd.service.systemd apcupsd-3.14.8/apcupsd.service
+--- apcupsd-3.14.8/apcupsd.service.systemd 2011-06-16 10:33:02.335889489 +0200
++++ apcupsd-3.14.8/apcupsd.service 2011-06-16 09:59:02.616138047 +0200
+@@ -0,0 +1,11 @@
++[Unit]
++Description=APC UPS Power Control Daemon for Linux
++After=syslog.target
++After=network.target
++
++[Service]
++ExecStartPre=-/bin/rm -f /etc/apcupsd/powerfail
++ExecStart=/usr/sbin/apcupsd -b -f /etc/apcupsd/apcupsd.conf
++
++[Install]
++WantedBy=multi-user.target
+diff -up apcupsd-3.14.8/apcupsd_shutdown.systemd apcupsd-3.14.8/apcupsd_shutdown
+--- apcupsd-3.14.8/apcupsd_shutdown.systemd 2011-06-16 10:33:08.831934420 +0200
++++ apcupsd-3.14.8/apcupsd_shutdown 2011-06-16 10:10:20.948796784 +0200
+@@ -0,0 +1,9 @@
++#!/bin/sh
++
++# See if this is a powerfail situation.
++if [ -f /etc/apcupsd/powerfail ]; then
++ echo
++ echo "APCUPSD will now power off the UPS"
++ echo
++ /etc/apcupsd/apccontrol killpower
++fi
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/apcupsd.git/commitdiff/76fc63052038d9c802ba1d7e911445cef4cda381
More information about the pld-cvs-commit
mailing list