File apcupsd.spec of Package apcupsd
#
# spec file for package apcupsd
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
%define _fillupdir %{_localstatedir}/adm/fillup-templates
%endif
Name: apcupsd
Version: 3.14.14
Release: 0
Summary: APC UPS Daemon (Powerful Daemon for APC UPSs)
License: GPL-2.0-only
Group: Hardware/UPS
Url: http://www.apcupsd.com/
Source: https://sourceforge.net/projects/apcupsd/files/apcupsd%%20-%%20Stable/%{version}/apcupsd-%{version}.tar.gz
Source2: README.SUSE
Source4: %{name}.hibernate
Source5: %{name}.sysconfig
Source6: %{name}.logrotate
Source7: apcupsd-httpd.conf
Source8: https://sourceforge.net/projects/apcupsd/files/apcupsd%%20-%%20Stable/%{version}/apcupsd-%{version}.tar.gz.sig
Source9: %{name}.keyring
Source10: %{name}.firewall
# PATCH-FIX-OPENSUSE apcupsd-suse.patch sbrabec@suse.cz -- Do not perform halt script alternation on install.
Patch0: apcupsd-suse.patch
# PATCH-FEATURE-OPENSUSE apcupsd-hibernate.patch sbrabec@suse.cz -- Support for hibernation on powerfail.
Patch2: apcupsd-hibernate.patch
# PATCH-FIX-OPENSUSE apcupsd-3.14.8-systemd.patch p.drouand@gmail.com -- systemd support
Patch11: apcupsd-3.14.8-systemd.patch
# PATCH-FIX-OPENSUSE apcupsd-3.14.9-fixgui.patch rhbz#578276 p.drouand@gmail.com -- fix crash in gui
Patch13: apcupsd-3.14.9-fixgui.patch
BuildRequires: apache-rpm-macros
BuildRequires: apache2-devel
BuildRequires: distribution-release
BuildRequires: dos2unix
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: libusb-devel
BuildRequires: mailx
BuildRequires: ncurses-devel
BuildRequires: pkgconfig
BuildRequires: systemd-rpm-macros
BuildRequires: systemd-sysvinit
BuildRequires: tcpd-devel
BuildRequires: update-desktop-files
BuildRequires: pkgconfig(gconf-2.0)
BuildRequires: pkgconfig(gdlib)
BuildRequires: pkgconfig(gnome-vfs-2.0)
BuildRequires: pkgconfig(gtk+-2.0)
BuildRequires: pkgconfig(systemd)
BuildRequires: pkgconfig(x11)
Requires: %{_bindir}/mail
Requires(post): %fillup_prereq
Requires(post): grep
Requires(post): sed
Recommends: logrotate
%{?systemd_requires}
%description
Controls and monitors the status of an APC UPS under Linux. Allows your
computer or server to run for a specified length of time on UPS power
then executes a controlled shutdown in the case of an extended power
failure. Find APC on the Internet at http://www.apc.com/.
APC also made their PowerChute plus available for download at
http://www.apc.com/tools/download/.
%package cgi
Summary: Web interface for apcupsd
Group: Hardware/UPS
Requires: %{name} = %{version}
%description cgi
A CGI interface to the APC UPS monitoring daemon.
%package gui
Summary: APC UPS Monitor GUI (for APC UPSs)
Group: Hardware/UPS
Requires: %{name} = %{version}
%description gui
Controls and monitors the status of an APC UPS under Linux. Allows your
computer or server to run for a specified length of time on UPS power
then executes a controlled shutdown in the case of an extended power
failure. Find APC on the Internet at http://www.apc.com/.
APC also made their PowerChute plus available for download at
http://www.apc.com/tools/download/.
%prep
%setup -q
cp -a %{SOURCE2} %{SOURCE4} .
%patch0
%patch2
%patch11 -p1
%patch13 -p1
%build
%configure \
--sysconfdir=%{_sysconfdir}/%{name} \
--with-libwrap \
--enable-all \
--with-lock-dir=%{_localstatedir}/lock \
--with-cgi-bin=%{apache_datadir}/cgi-bin \
--with-distname=$(grep ID_LIKE %{_sysconfdir}/os-release | cut -d = -f 2 | tr -d '"')
make %{?_smp_mflags}
%install
%make_install
install -m744 platforms/apccontrol \
%{buildroot}%{_sysconfdir}/%{name}/apccontrol
ln -sf %{_sbindir}/service %{buildroot}/%{_sbindir}/rc%{name}
%suse_update_desktop_file gapcmon
chmod 644 %{buildroot}/%{_datadir}/pixmaps/*.png
# Cleanup for later doc macro processing
chmod -x examples/*.c
rm examples/*.in
find examples users_guide -type f | xargs chmod 644
# fix end-of-line encoding
dos2unix -o examples/status/SmartUPS-vs-650.status examples/snoopdecode.c examples/rpt/Smart-UPS-1500.rpt \
examples/rpt/Back-UPS-ES-550.rpt examples/rpt/Back-UPS-CS-650.rpt examples/rpt/Back-UPS-BR-800.rpt
# hid-ups.rpt is duplicate by BackUPS.rpt
%fdupes -s examples/rpt/
rm -r %{buildroot}/%{_datadir}/hal
mkdir -p %{buildroot}%{_libexecdir}/systemd/system-sleep
sed "s:@PWRFAILDIR@:%{_sysconfdir}/%{name}:g" <%{name}.hibernate >%{buildroot}%{_libexecdir}/systemd/system-sleep/apcupsd.sh
chmod +x %{buildroot}%{_libexecdir}/systemd/system-sleep/apcupsd.sh
mkdir -p %{buildroot}%{_fillupdir}
cp %{SOURCE5} %{buildroot}%{_fillupdir}/sysconfig.%{name}
# systemd support and remove initd support for opensuse 12.2 and higher
install -p -D -m644 %{name}.service %{buildroot}%{_unitdir}/%{name}.service
install -p -D -m755 %{name}_shutdown %{buildroot}%{_libexecdir}/systemd/system-shutdown/%{name}_shutdown
rm %{buildroot}%{_initddir}/%{name}
install -d %{buildroot}%{_sysconfdir}/logrotate.d
install -m0644 %{SOURCE6} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
install -d %{buildroot}%{_sysconfdir}/apache2/conf.d/
install -m0644 %{SOURCE7} %{buildroot}%{_sysconfdir}/apache2/conf.d/%{name}.conf
# firewall config
install -m 644 -D %{SOURCE10} %{buildroot}/%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}
%pre
%service_add_pre %{name}.service
%post
%fillup_only
%service_add_post %{name}.service
# Remove HALT_POWERDOWN_INSERT, it is not needed with systemd (it was last time filled in 13.1).
# We need to handle only the last form, which was already used in SLE11.
if test -f etc/sysconfig/shutdown ; then
if usr/bin/grep -q '^HALT_POWERDOWN_INSERT=' etc/sysconfig/shutdown ; then
if ! usr/bin/grep -q '^HALT_POWERDOWN_INSERT=""' etc/sysconfig/shutdown ; then
if usr/bin/grep -q '^HALT_POWERDOWN_INSERT="%{_sysconfdir}/init\.d/apcupsd try-powerdown"' etc/sysconfig/shutdown ; then
usr/bin/sed -i 's:^\(HALT_POWERDOWN_INSERT="\)%{_sysconfdir}/init\.d/apcupsd try-powerdown":\1":' etc/sysconfig/shutdown
else
echo >&2 "apcupsd: WARNING: Unknown value of HALT_POWERDOWN_INSERT in %{_sysconfdir}/sysconfig/shutdown."
echo >&2 " Keeping unchanged. If it still exists, it should be:"
echo >&2 "HALT_POWERDOWN_INSERT=\"\""
fi
fi
fi
fi
# User installed file, by default in docdir. Not needed any more, and will never be.
rm -f etc/init.d/apcupsd-early-powerdown
%preun
%service_del_preun %{name}.service
%postun
%service_del_postun %{name}.service
%files
%license COPYING
%doc ChangeLog examples ReleaseNotes README.SUSE
%{_sbindir}/%{name}
%{_sbindir}/apcaccess
%{_sbindir}/apctest
%{_sbindir}/smtp
%{_sbindir}/rc%{name}
%{_unitdir}/%{name}.service
%{_libexecdir}/systemd/system-shutdown/%{name}_shutdown
%{_libexecdir}/systemd/system-sleep/%{name}.sh
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/changeme
%config(noreplace) %{_sysconfdir}/%{name}/commfailure
%config(noreplace) %{_sysconfdir}/%{name}/commok
%config(noreplace) %{_sysconfdir}/%{name}/onbattery
%config(noreplace) %{_sysconfdir}/%{name}/offbattery
%config(noreplace) %{_sysconfdir}/logrotate.d/apcupsd
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
%config(noreplace) %attr(0644,root,root) %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}
%attr(0755,root,root) %{_sysconfdir}/%{name}/apccontrol
%{_mandir}/man?/*.*
%{_fillupdir}/sysconfig.%{name}
%files gui
%{_bindir}/gapcmon
%{_datadir}/applications/gapcmon.desktop
%{_datadir}/pixmaps/*.png
%files cgi
%config(noreplace) %{_sysconfdir}/apache2/conf.d/%{name}.conf
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.css
%config(noreplace) %{_sysconfdir}/%{name}/hosts.conf
%config(noreplace) %{_sysconfdir}/%{name}/multimon.conf
%{apache_datadir}/cgi-bin/multimon.cgi
%{apache_datadir}/cgi-bin/upsfstats.cgi
%{apache_datadir}/cgi-bin/upsstats.cgi
%{apache_datadir}/cgi-bin/upsimage.cgi
%changelog