File sendmailanalyzer.spec of Package sendmailanalyzer

# spec file for package sendmailanalyzer
# Copyright (c) 2011 Stefan Jakobs <>
# 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

Name:           sendmailanalyzer
Version:        9.0
Release:        1
License:        GPL-3.0+
Summary:        A free Sendmail/Postfix log analyzer
Group:          System/Monitoring
Source:         %{name}-%{version}.tar.gz
Source1:        %{name}.init
Source2:        %{name}.httpd.conf
%if 0%{?suse_version} >= 01210
Source3:        %{name}.service
BuildRequires:  systemd
Source4:        sa_cache.3
Source5:        sa_cache.pod
Source7:        README.SUSE
BuildRequires:  perl
BuildRequires:  perl(MIME::Base64)
BuildRequires:  perl(MIME::QuotedPrint)
BuildRequires:  sed
PreReq:         %insserv_prereq
Requires:       perl(MIME::Base64)
Requires:       perl(MIME::QuotedPrint)
Requires:       perl = %{perl_version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

SendmailAnalyzer as is name suggest is a free Sendmail/Postfix log analyzer.
It process maillog files and generate dynamic statistics in HTML and graphical
output. The reports are generated in real time so that it let you know at any
moment what is going on your mail servers. It use time (hour, day, month and
year views) and cross-linked navigation for easy use.

SendmailAnalyzer is easy to install and highly configurable to match the
dozen of Sendmail possible configurations. It also support report for all the
major milter or sendmail filters like SpamAssassin, MailScanner, Clamav,
Amavis, RBL check, J-ChkMail, etc. SendmailAnalyzer is really helpful for
IT reporting.

Collected data are stored in flat files that are automatically archived or
delete to keep disk space. All reports before the current day are cached to
save system resources and are displayed in less than 1 second.

%package www
Summary:        Webserver Part for SendmailAnalyzer
Group:          System/Monitoring
PreReq:         apache2
Requires:       apache2-mod_perl
Requires:       %{name} = %{version}

%description www
This package includes the needed files to see the SendmailAnalyzer 
reports via an apache webserver with your browser.

%setup -q
install -m644 %{SOURCE7} .

sed -i 's/\(sendmailanalyzer.conf\).orig/\1/' Makefile.PL
perl Makefile.PL \
		INSTALLDIRS="vendor" \
		QUIET=1 \
		LOGFILE=%{_localstatedir}/log/mail \
		BINDIR=%{_sbindir} \
		CONFDIR=%{_sysconfdir} \
		PIDDIR=%{_localstatedir}/run \
		BASEDIR=%{_localstatedir}/lib/%{name} \
		HTMLDIR=/srv/www/%{name} \
		MANDIR=%{_mandir}/man3 \
		DOCDIR=%{_docdir}/%{name} \
make %{?_smp_mflags} OPTIMIZE="%{optflags}"

make test

make install
rm -rf %{buildroot}%{perl_archlib}/perllocal.pod %{buildroot}%{perl_vendorarch}/auto/%{name}/.packlist
if [ ! -d %{buildroot}/%{_localstatedir}/lib/%{name} ] ; then
  mkdir -p %{buildroot}/%{_localstatedir}/lib/%{name}
# install init and service files
install -Dm0755 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init.d/%{name}
ln -sf %{_sysconfdir}/init.d/%{name} %{buildroot}/%{_sbindir}/rc%{name}
%if 0%{?suse_version} >= 01210
install -Dm644 %{SOURCE3} %{buildroot}/%{_unitdir}/%{name}.service
# install apache configuration
mkdir -p %{buildroot}/%{_sysconfdir}/apache2/conf.d
sed -e "s|__webdir__|/srv/www/%{name}|g" %{SOURCE2} > %{buildroot}/%{_sysconfdir}/apache2/conf.d/%{name}.conf
# install missing manpage
install -m644 %{SOURCE4}  %{buildroot}%{_mandir}/man3/sa_cache.3
# make rpmlint happy: remove INSTALL file
rm %{buildroot}/%{_docdir}/%{name}/INSTALL

rm -rf %{buildroot}

%pre www
if [ "$1" = "1" ]; then
  # enable perl in apache config
  if [ -x %{_sbindir}/a2enmod ]; then
    if grep -q perl %{_sysconfdir}/sysconfig/apache2 1>&2 2>/dev/null; then
      %{_sbindir}/a2enmod perl >/dev/null || :
  if [ -x %{_sbindir}/a2enflag ]; then
    if grep -q SAREPORT %{_sysconfdir}/sysconfig/apache2 1>&2 2>/dev/null; then
      %{_sbindir}/a2enflag SAREPORT >/dev/null || :

%post www
%restart_on_update apache2

%postun www
%restart_on_update apache2

%if 0%{?suse_version} >= 1210
%service_add_pre %{name}.service

%service_add_post %{name}.service
%{fillup_and_insserv -f %{name}}

%service_del_preun %{name}.service
%stop_on_removal %{name}

%service_del_postun %{name}.service
%restart_on_update %{name}

%{fillup_and_insserv -f %{name}}

%stop_on_removal %{name}

%restart_on_update %{name}

%defattr(-, root, root, -)
%doc ChangeLog README* LICENSE
%doc %{_mandir}/man3/*.3*
%config(noreplace) %{_sysconfdir}/%{name}.conf
%dir /srv/www/%{name}
%dir %{_localstatedir}/lib/%{name}
%if 0%{?suse_version} >= 01210

%files www
%defattr(-, root, root, -)
%config(noreplace) %{_sysconfdir}/apache2/conf.d/%{name}.conf

openSUSE Build Service is sponsored by