File qmailmrtg.spec of Package qmailmrtg

#
# spec file for package qmailmrtg
#
# Copyright (c) 2013 SUSE LINUX Products 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/
#


Name:           qmailmrtg
Summary:        Multi Router Traffic Grapher for Qmail
License:        GPL-2.0
%if 0%{?suse_version}
Group:          Productivity/Networking/Email/Servers
%else
Group:          Networking/Other
%endif
Version:        4.2
Release:        0
Url:            http://www.inter7.com/index.php?page=qmailmrtg7
Source0:        qmailmrtg7-%{version}.tar.bz2
Source1:        qmailmrtg-html.tar.bz2
Source2:        qmailmrtg.cfg
Source3:        qmailmrtg.cron
Source4:        qmailmrtg.conf
Patch0:         qmailmrtg7-modernizer.diff
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Obsoletes:      qmailmrtg-toaster < %{version}
Provides:       qmailmrtg-toaster = %{version}
Conflicts:      qmailmrtg7

BuildRequires:  qmail-skel-devel
Requires:       mrtg
Requires:       qmail

%define		qmailtools_share_dir %{_datadir}/qmailtools
%define		package_share_dir %{qmailtools_share_dir}/%{name}
%define		package_var_dir /var/lib/qmailmrtg

%if 0%{?suse_version}
Requires:       apache2
Requires:       cron
BuildRequires:  apache2
BuildRequires:  cron
%define			apache_confd	%{_sysconfdir}/apache2/conf.d
%else
Requires:       crontabs
Requires:       vixie-cron
BuildRequires:  crontabs
%define			apache_confd	%{_sysconfdir}/httpd/conf.d
%endif

%if 0%{?rhel_version} || 0%{?centos_version} || 0%{?fedora_version}
Requires:       httpd
BuildRequires:  httpd
%endif

%if 0%{?mandriva_version}
Requires:       apache-base
BuildRequires:  apache-base
%endif

%description
qmailmrtg7 uses qmail's excellent and extensive logging via multilog, 
tcpserver and qmail-send. qmailmrtg7 takes the pop3 smtp and qmail 
transaction logs and sends them to 9 different mrtg graphs, each graph 
with 4 historical time series. 

%prep
%setup -q -n qmailmrtg7-%{version}
%setup -a 1 -n qmailmrtg7-%{version}
%patch0 -p1

%build
%{__cc} checkq.c -o checkq $RPM_OPT_FLAGS
./checkq
%{__cc} -s -O qmailmrtg7.c -o qmailmrtg $RPM_OPT_FLAGS

%install
%{__mkdir_p} \
	%{buildroot}%{_sysconfdir}/cron.d \
	%{buildroot}%{_bindir} \
	%{buildroot}%{package_var_dir}/htdocs

install -m755 qmailmrtg %{buildroot}%{_bindir}/qmailmrtg
install -m644 index.php %{buildroot}%{package_var_dir}/htdocs
install -m644 kl-qmail-w.gif %{buildroot}%{package_var_dir}/htdocs
install -m644 background.gif %{buildroot}%{package_var_dir}/htdocs
install -m644 %{SOURCE2} %{buildroot}%{_sysconfdir}
%{__ln_s} ../../../%{_sysconfdir}/qmailmrtg.cfg %{buildroot}%{package_var_dir}

%{__mkdir_p} %{buildroot}%{_sysconfdir}/cron.d
install -m644 %{SOURCE3} %{buildroot}%{_sysconfdir}/cron.d/qmailmrtg

%{__mkdir_p} %{buildroot}/%{apache_confd}
install -m644 %{SOURCE4} %{buildroot}/%{apache_confd}/%{name}.conf

%pre
if [ -e /var/lib/qmailtools/qmailmrtg ] ; then
	mv /var/lib/qmailtools/qmailmrtg %{package_var_dir}
fi

%clean
[ -d %{buildroot} ] && %{__rm} -rf %{buildroot}

%files
%defattr(0755,root,root)
%{_bindir}/qmailmrtg

%defattr(0644,root,root,0755)
%dir %{package_var_dir}
%config(noreplace) %{_sysconfdir}/cron.d/qmailmrtg
%config(noreplace) %{_sysconfdir}/qmailmrtg.cfg
%config(noreplace) %{apache_confd}/%{name}.conf
%{package_var_dir}/qmailmrtg.cfg
%{package_var_dir}/htdocs

%changelog
openSUSE Build Service is sponsored by