File mailgraph.spec of Package mailgraph

#
# spec file for package mailgraph
#
# Copyright (c) 2017 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 /var/adm/fillup-templates
%endif

%define serverroot %(/usr/sbin/apxs2 -q datadir 2>/dev/null || /usr/sbin/apxs2 -q PREFIX)
%define cgi_dir %{serverroot}/cgi-bin
%define css_dir %{serverroot}/htdocs/css

Name:           mailgraph
Version:        1.14
Release:        0
Summary:        Very simple mail statistics RRDtool frontend for Postfix
License:        GPL-2.0+
Group:          Productivity/Networking/Diagnostic
Url:            http://mailgraph.schweikert.ch/
Source0:        %{name}-%{version}.tar.bz2
Source1:        %{name}.init
Source2:        %{name}.logrotate
Source3:        %{name}.sysconfig
# PATCH-FIX-openSUSE -- adapt pathnames for daemon_logfile and daemon_rrd_dir to openSUSE
Patch0:         %{name}-1.14-pl.patch
# PATCH-FIX-openSUSE -- adapt/enhance css usage and skip $uri in ref
Patch1:         %{name}-1.14-cgi.patch
# PATCH-FIX-UPSTREAM -- fix font for a tag
Patch2:         %{name}-1.14-css.patch
# PATCH-FIX-openSUSE -- integrate patch from nagios-plugins-mailgraph
Patch3:         mailgraph_for_nagios-plugins-mailgraph.patch
BuildRequires:  apache2-devel
PreReq:         coreutils
PreReq:         diffutils
PreReq:         fillup
PreReq:         grep
PreReq:         sed
PreReq:         %insserv_prereq
Requires:       apache2-mod_perl
Requires:       logrotate
Requires:       postfix
Requires:       rrdtool
Requires:       perl(File::Tail)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
%if 0%{?suse_version} > 1100
Provides:       %{css_dir}
%endif

%description
Mailgraph is a very simple mail statistics RRDtool frontend for Postfix
that produces daily, weekly, monthly and yearly graphs of received/sent
and bounced/rejected mail (SMTP traffic).

%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1

%build

%install
%{__install} -d -m 755 %{buildroot}%{_bindir} %{buildroot}%{_sbindir}
%{__install} -d -m 755 %{buildroot}%{_fillupdir}
%{__install} -d -m 755 %{buildroot}%{_localstatedir}/lib/%{name}/img
%{__install} -d -m 755 %{buildroot}%{_localstatedir}/log/%{name}
%{__install} -d -m 755 %{buildroot}%{_sysconfdir}/init.d
%{__install} -d -m 755 %{buildroot}%{_sysconfdir}/logrotate.d
%{__install} -d -m 755 %{buildroot}%{cgi_dir}
%{__install} -d -m 755 %{buildroot}%{css_dir}

%{__install} -m 755 %{name}.pl %{buildroot}%{_bindir}/
%{__install} -m 755 %{name}.cgi %{buildroot}%{cgi_dir}/
%{__install} -m 644 %{name}.css %{buildroot}%{css_dir}/
%{__install} -m 755 %{S:1} %{buildroot}%{_sysconfdir}/init.d/%{name}
%{__install} -m 644 %{S:2} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
%{__install} -m 644 %{S:3} %{buildroot}%{_fillupdir}/sysconfig.%{name}
%{__ln_s} -f ../../etc/init.d/%{name} %{buildroot}%{_sbindir}/rc%{name}

%post
%{fillup_and_insserv mailgraph}

%preun
%stop_on_removal mailgraph

%postun
%restart_on_update mailgraph
%{insserv_cleanup}

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-,root,root)
%doc CHANGES COPYING README
%dir %{_localstatedir}/lib/%{name}
%attr(755,wwwrun,www) %dir %{_localstatedir}/lib/%{name}/img
%dir %{_localstatedir}/log/%{name}
%{_bindir}/%{name}.pl
%{_sbindir}/rc%{name}
%{cgi_dir}/%{name}.cgi
%{css_dir}/%{name}.css
%{_sysconfdir}/init.d/%{name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%{_fillupdir}/sysconfig.%{name}

%changelog
openSUSE Build Service is sponsored by