File amavisd-new.spec of Package amavisd-new

#
# spec file for package amavisd-new
#
# Copyright (c) 2024 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%define avspool        %{_localstatedir}/spool/amavis
%define avdb           %{_localstatedir}/spool/amavis/db
%define avquarantine   %{_localstatedir}/spool/amavis/virusmails
%define logmsg         logger -t %{name}/rpm

Name:           amavisd-new
Version:        2.12.2
Release:        0
Summary:        High-Performance E-Mail Virus Scanner
License:        GPL-2.0-or-later
Group:          Productivity/Networking/Security
URL:            https://gitlab.com/amavis/amavis/
Source0:        https://gitlab.com/amavis/amavis/-/archive/v%{version}/amavis-v%{version}.tar.bz2
Source1:        sysconfig.amavis
Source3:        amavisd-new-rpmlintrc
Source4:        README.qmail
Source5:        amavis.service
%if 0%{?suse_version} <= 1500
Source10:       system-user-vscan.conf
%endif
Patch1:         activate_virus_scanner.diff
# PATCH-FIX-UPSTREAM -- detect myhostname via Net::Domain::hostfqdn()
Patch2:         amavisd-new-2.10.1-myhostname.patch
# PATCH-FIX-OPENSUSE -- amavisd-new-no-berkeleydb.patch
Patch3:         amavisd-new-no-berkeleydb.patch
Patch4:         amavisd-qmqpqq-local.patch
%if 0%{?suse_version} > 1500
BuildRequires:  group(vscan)
BuildRequires:  user(vscan)
%else
BuildRequires:  sysuser-tools
%endif
BuildRequires:  sed
BuildArch:      noarch
BuildRequires:  systemd
BuildRequires:  util-linux-systemd
%{?systemd_requires}
BuildRequires:  clamav
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Amavisd-new is a high-performance interface between mailer (MTA) and
content checkers: virus scanners or SpamAssassin. It talks to the MTA
via (E)SMTP, LMTP. It works with the
following MTAs:

- postfix
- sendmail (sendmail-milter)
- exim

%package docs
Summary:        Documentation for the High-Performance E-Mail Virus Scanner
Group:          Documentation/Other
%if 0%{?fedora} == 0
Recommends:     %{name} = %{version}
%endif

%description docs
Amavisd-new is a high-performance interface between mailer (MTA) and
content checkers: virus scanners or SpamAssassin. It talks to the MTA
via (E)SMTP, LMTP.

This package contains the documentation and Release-Notes.

%package qmail
Summary:        AMAVIS virus scanner with qmail patch
Group:          Productivity/Networking/Security
Requires:       bzip2
Requires:       file
Requires:       smtp_daemon
Requires:       zoo
PreReq:         coreutils
PreReq:         net-tools
PreReq:         util-linux
Requires(pre):  pwdutils
Recommends:     %{name}-docs = %{version}
Recommends:     cabextract
Recommends:     clamav
Recommends:     lzop
Recommends:     netqmail-smtpd
Recommends:     p7zip
Recommends:     perl-Authen-SASL
Recommends:     perl-DBI
Recommends:     perl-File-LibMagic
Recommends:     perl-Mail-ClamAV
Recommends:     perl-ldap
Recommends:     unar
Recommends:     unarj
Recommends:     unrar
Conflicts:      amavisd-new
Requires(pre):  util-linux-systemd
Requires(post): util-linux-systemd
Requires(pre):  shadow
Requires(post): %fillup_prereq
Requires(post): grep
OrderWithRequires(post): /usr/bin/newaliases
BuildRequires:  systemd-rpm-macros
Requires:       perl(Archive::Zip) >= 1.14
Requires:       perl(Compress::Raw::Zlib) >= 2.017
Requires:       perl(Compress::Zlib) >= 1.35
Requires:       perl(Convert::BinHex)
Requires:       perl(Digest::MD5) >= 2.22
Requires:       perl(IO::Socket::SSL)
Requires:       perl(IO::Stringy)
Requires:       perl(MIME::Base64)
Requires:       perl(MIME::Parser)
Requires:       perl(Mail::DKIM) >= 0.31
Requires:       perl(Mail::Internet) >= 1.58
Requires:       perl(Net::Domain)
Requires:       perl(Net::LibIDN)
Requires:       perl(Net::Server) >= 2.0
Requires:       perl(Time::HiRes) >= 1.49
Requires:       perl(Unix::Syslog)
Requires(post): %fillup_prereq
Requires(post): %{_bindir}/newaliases
%if 0%{?suse_version} > 1500
Requires(pre):  group(vscan)
Requires(pre):  user(vscan)
%else
Requires(pre):  system-user-vscan
%endif
Recommends:     %{name}-docs = %{version}
Recommends:     arc
Recommends:     arj
Recommends:     bzip2
Recommends:     cabextract
Recommends:     clamav
Recommends:     cpio
Recommends:     gzip
Recommends:     lhasa
Recommends:     lzop
Recommends:     ncompress
Recommends:     p7zip
Recommends:     spax
Recommends:     tnef
Recommends:     unrar
Recommends:     zoo
Recommends:     perl(Mail::SpamAssassin)
Recommends:     perl(Net::LDAP)
Suggests:       perl(DBD::mysql)
Suggests:       perl(DBI)
BuildArch:      noarch
%{?systemd_ordering}

%description qmail
Amavisd-new is a high-performance interface between mailer (MTA) and
content checkers: virus scanners or SpamAssassin. It talks to the MTA
via (E)SMTP, LMTP.

This package contains a version of the daemon patched for use with (net)qmail
via qmqpc.

%prep
%setup -q -n amavis-v%{version}
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
tail -11 amavisd-new-qmqpqq.patch | patch -p0
for i in $(find -maxdepth 1 -name "amavisd*" | sed s#./##); do
    if [[ $i == *patch ]] ; then continue; fi
    if [[ $i == *patch ]] ; then continue; fi
    if [[ $i == *spec ]] ; then continue; fi
    echo "patching file $i"
    sed -i "s|^# \$MYHOME =.*|\$MYHOME = '%{avspool}';|g; \
            s|/var/amavis/db|%{avdb}|g; \
            s|/var/virusmails|%{avquarantine}|g; \
            s|/var/amavis/amavisd.sock|%{avspool}/amavisd.sock|g" $i
done
cp "%{S:4}" .

# ---------------------------------------------------------------------------

%build
# ---------------------------------------------------------------------------

%install
%if 0%{?suse_version} <= 1500
mkdir -p %{buildroot}%{_sysusersdir}
mkdir -p %{buildroot}%{avspool}
install -m 644 %{SOURCE10} %{buildroot}%{_sysusersdir}/system-user-vscan.conf
%endif
mkdir -p %{buildroot}%{avquarantine}
mkdir -p %{buildroot}%{avspool}/{tmp,var}
mkdir -p %{buildroot}%{avdb}
mkdir -p %{buildroot}%{_sbindir}
mkdir -p %{buildroot}%{_fillupdir}
mkdir -p %{buildroot}%{_sysconfdir}/openldap/schema
mkdir -p %{buildroot}%{perl_vendorlib}
install -m 644 $RPM_SOURCE_DIR/sysconfig.amavis %{buildroot}%{_fillupdir}
install -m 755 amavisd %{buildroot}/%{_sbindir}/amavisd
install -m 755 amavisd-agent %{buildroot}/%{_sbindir}/amavisd-agent
install -m 755 amavisd-nanny %{buildroot}/%{_sbindir}/amavisd-nanny
install -m 755 amavisd-release %{buildroot}/%{_sbindir}/amavisd-release
install -m 755 p0f-analyzer.pl %{buildroot}/%{_sbindir}/p0f-analyzer.pl
install -m 644 amavisd.conf %{buildroot}%{_sysconfdir}/amavisd.conf
install -m 644 LDAP.schema %{buildroot}%{_sysconfdir}/openldap/schema/amavisd-new.schema
install -m 644 JpegTester.pm %{buildroot}/%{perl_vendorlib}/JpegTester.pm
mkdir -p %{buildroot}%{_unitdir}
install -m 644 %{SOURCE5} %{buildroot}%{_unitdir}
ln -s service %{buildroot}/%{_sbindir}/rcamavis

%pre qmail
%service_add_pre amavis.service

%preun qmail
%service_del_preun amavis.service

%post qmail
%{fillup_only -n amavis}
# Only on install
if [ ${1:-0} -eq 1 ] && ! grep -q "^virusalert:" %{_sysconfdir}/aliases; then
  echo "virusalert:	root" >> %{_sysconfdir}/aliases
  %logmsg "Added alias for user virusalert to %{_sysconfdir}/aliases"
  if [ -x %{_bindir}/newaliases ]; then
    newaliases >/dev/null 2>&1 || :
  else
    %logmsg "Cannot execute newaliases. Please run it manually."
  fi
fi
%service_add_post amavis.service

%postun qmail
%service_del_postun amavis.service

%files qmail
%defattr(-,root,root)
%license LICENSE
%doc AAAREADME.first INSTALL README.qmail
%doc LDAP.ldif
%dir %{_sysconfdir}/openldap
%dir %{_sysconfdir}/openldap/schema
%config(noreplace) %{_sysconfdir}/amavisd.conf
%config(noreplace) %{_sysconfdir}/openldap/schema/amavisd-new.schema
%{_fillupdir}/sysconfig.amavis
%{_sbindir}/*
%{perl_vendorlib}/JpegTester.pm
%{_unitdir}/amavis.service
%if 0%{?suse_version} <= 1500
%{_sysusersdir}/system-user-vscan.conf
%endif
%defattr(0750,vscan,vscan, 0750)
%dir %{avspool}
%dir %{avspool}/tmp
%dir %{avspool}/db
%dir %{avspool}/var
%dir %{avquarantine}

%files docs
%defattr(0644,root,root,0755)
%doc RELEASE_NOTES
%doc README_FILES
%doc test-messages
%doc amavisd.conf-*
%doc MANIFEST TODO

%changelog
openSUSE Build Service is sponsored by