File rmilter.spec of Package rmilter

#
# spec file for package rmilter
#
# Copyright (c) 2016 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/
#

%if 0%{?suse_version} > 1230 || 0%{?rhel_version} > 600 || 0%{?centos_version} > 600 || 0%{?fedora_version} >= 20 || 0%{?el7}%{?fc20}%{?fc21}%{?fc22}%{?fc23}%{?fc24}%{?fc25}
%bcond_without systemd
%else
%bcond_with    systemd
%endif

%define rmilter_user      _rmilter
%define rmilter_group     adm
%if %{with systemd}
%define rmilter_home      /run/rmilter
%else
%define rmilter_home      %{_localstatedir}/run/rmilter
%endif

Name:           rmilter
Version:        1.10.0
Release:        0
License:        BSD-2-Clause
Summary:        Integrate rspamd and milter compatible MTA
Url:            http://github.com/vstakhov/rmilter
Group:          Productivity/Networking/Email/Utilities
Source:         %{name}-%{version}.tar.gz
Source1:        %{name}.tmpfiles.d
BuildRequires:  cmake
BuildRequires:  libmemcached-devel
BuildRequires:  libopenssl-devel
BuildRequires:  sendmail-devel
BuildRequires:  pcre-devel
BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  pkgconfig(glib-2.0)
BuildRequires:  opendkim-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if %{with systemd}
BuildRequires:  pkgconfig(systemd)
%{?systemd_requires}
%endif
Requires(pre):  shadow
Requires:       logrotate
%if 0%{?suse_version} && 0%{?suse_version} < 1500
Requires:       icu-data
%endif

%description
Rmilter is used to integrate rspamd and milter compatible MTA, for example
Postfix or Sendmail. It also performs other useful functions for email
filtering including:

- Virus scanning using Clamav
- Spam scanning using Rspamd
- Greylisting using redis storage
- Ratelimit using redis storage
- Replies check (whitelisting replies to sent messages)
- Passing certain messages to redis pub/sub channels
- DKIM signing

%prep
%setup -q

%build
%cmake \
  -DENABLE_MEMCACHED:BOOL=ON \
  -DENABLE_DKIM:BOOL=ON \
  %if %{with systemd}
  -DWANT_SYSTEMD_UNITS:BOOL=ON \
  %endif
  -DRMILTER_GROUP=%{rmilter_group} \
  -DRMILTER_USER=%{rmilter_user}

make %{?_smp_mflags}

%install
%cmake_install
mkdir -p %{buildroot}%{rmilter_home}

%if %{with systemd}
%{__ln_s} -f %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}

sed -e "s|/var/run/|/run/|g" -e "s|/usr/local/etc/|%{_sysconfdir}/%{name}/|g" -i rmilter.conf.sample

install -D -m 0644 %{S:1} %{buildroot}/usr/lib/tmpfiles.d/%{name}.conf
%endif

install -D -m 0644 rmilter.conf.sample %{buildroot}%{_sysconfdir}/%{name}/rmilter.conf

%pre
%{_sbindir}/groupadd -r %{rmilter_group} 2>/dev/null || :
%{_sbindir}/useradd -g %{rmilter_group} -c "Rmilter user" -s /bin/false -r %{rmilter_user} 2>/dev/null || :
%if 0%{?suse_version} && %{with systemd}
%service_add_pre %{name}.service

%post
systemd-tmpfiles --create /usr/lib/tmpfiles.d/%{name}.conf ||:
%service_add_post %{name}.service
%endif

%if 0%{?suse_version}
%preun
%if %{with systemd}
%service_del_preun %{name}.service
%else
%stop_on_removal %{name}
%endif
%endif

%if 0%{?suse_version}
%postun
%if %{with systemd}
%service_del_postun %{name}.service
%else
%restart_on_update %{name}
%insserv_cleanup
%endif
%endif

%files
%defattr(-,root,root)
%doc README.md ChangeLog rmilter.conf.sample  rmilter-grey.conf
%config(noreplace) %{_sysconfdir}/%{name}/
%{_sbindir}/rcrmilter
%{_sbindir}/rmilter
%if %{with systemd}
%{_unitdir}/rmilter.service
/usr/lib/tmpfiles.d/%{name}.conf
%ghost %dir %attr(750,%{rmilter_user},%{rmilter_group}) %{rmilter_home}
%else
%dir %attr(750,%{rmilter_user},%{rmilter_group}) %{rmilter_home}
%endif

%changelog
openSUSE Build Service is sponsored by