File opensmtpd.spec of Package opensmtpd
%define realname opensmtpd
%define realver 6.7.1
%define patchlevel p1
%define srcext tar.gz
%define extras 6.7.1
Name: %{realname}
Version: %{realver}%{?patchlevel}
Release: wiz%{?extraver:0.}1%{?dist}
Group: Productivity/Networking/Email/Servers
License: ISC and BSD-4-Clause and BSD-3-Clause and BSD-2-Clause
URL: https://www.opensmtpd.org/portable.html
Summary: FREE implementation of the server-side SMTP protocol
# Install-time parameters
Provides: smtp_daemon smtpdaemon
Conflicts: sendmail sendmail-tls postfix exim
Requires: logrotate
%if 0%{?suse_version}
PreReq: permissions
%endif
BuildRequires: autoconf automake libtool
BuildRequires: groff bison
BuildRequires: libasr-devel
BuildRequires: zlib-devel
BuildRequires: libressl-devel
BuildRequires: pam-devel
BuildRequires: mysql-devel
#BuildRequires: postgresql-devel postgresql-server-devel
BuildRequires: hiredis-devel
BuildRequires: sqlite-devel >= 3 libevent-devel
BuildRequires: openldap%{?suse_version:2}-devel
BuildRequires: python-devel
%if 0%{?suse_version}
BuildRequires: db-devel
%else
%if 0%{?rhel} >= 7
BuildRequires: libdb-devel
%else
BuildRequires: db4-devel
%endif
%endif
%if 0%{?suse_version} && 0%{?opensuse_bs}
BuildRequires: -post-build-checks
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source0: https://github.com/OpenSMTPD/OpenSMTPD/archive/%{realver}%{?patchlevel}.%{srcext}
Source1: https://www.opensmtpd.org/archives/opensmtpd-extras-%{extras}.%{srcext}
Source11: opensmtpd.init
Source12: opensmtpd.service
%description
OpenSMTPD is a FREE implementation of the server-side SMTP protocol as defined
by RFC 5321, with some additional standard extensions. It allows ordinary
machines to exchange e-mails with other systems speaking the SMTP protocol.
Started out of dissatisfaction with other implementations, OpenSMTPD nowadays
is a fairly complete SMTP implementation.
%package dnsbl
Group: Productivity/Networking/Email/Servers
Summary: DNS-based blacklist support for %{name}
Requires: %{name} = %{version}
%description dnsbl
Filter for OpenSMTPd which can be used to check new connections against
a DNS-based Blacklist (DNSBL).
%package ldap
Group: Productivity/Networking/Email/Servers
Summary: LDAP support for %{name}
Requires: %{name} = %{version}
%description ldap
LDAP table backend for %{name}
%package mysql
Group: Productivity/Networking/Email/Servers
Summary: MySQL support for %{name}
Requires: %{name} = %{version}
%description mysql
MySQL table backend for %{name}
%package postgres
Group: Productivity/Networking/Email/Servers
Summary: PostgreSQL support for %{name}
Requires: %{name} = %{version}
%description postgres
PostgreSQL table backend for %{name}
%package python
Group: Productivity/Networking/Email/Servers
Summary: Python support for %{name}
Requires: %{name} = %{version}
%description python
OpenSMTPd extensions using python: filter, queue, scheduler and table
%package redis
Group: Productivity/Networking/Email/Servers
Summary: Redis support for %{name}
Requires: %{name} = %{version}
%description redis
Redis table backend for %{name}
%package sqlite
Group: Productivity/Networking/Email/Servers
Summary: SQLite support for %{name}
Requires: %{name} = %{version}
%description sqlite
SQLite table backend for %{name}
%prep
%setup -q -n OpenSMTPD-%{realver}%{?patchlevel} -a1
if [ -x bootstrap ]
then
./bootstrap
else
autoreconf --force --install
fi
cd opensmtpd-extras-%{extras}
if [ -x bootstrap ]
then
./bootstrap
else
autoreconf --force --install
fi
cd -
%build
%configure \
--sysconfdir=%{_sysconfdir}/%{name} \
--libexecdir=%{_libdir} \
\
--disable-static \
\
--with-auth-pam \
--with-mantype=man \
--with-spooldir=%{_localstatedir}/spool/mail \
--with-cflags="%{optflags} %{?gcc_lto} -fPIE" \
--with-ldflags="-Wl,--as-needed -Wl,--strip-all %{?gcc_lto} -pie"
%{__make} %{?_smp_mflags}
cd opensmtpd-extras-%{extras}
%configure \
--sysconfdir=%{_sysconfdir}/%{name} \
--libexecdir=%{_libdir} \
\
--disable-static \
\
--with-privsep-user=mail \
--with-filter-clamav \
--with-filter-dkim-signer \
--with-filter-dnsbl \
--with-filter-monkey \
--with-filter-pause \
--with-filter-python \
--with-filter-regex \
--with-filter-spamassassin \
--with-filter-stub \
--with-filter-trace \
--with-filter-void \
--with-queue-null \
--with-queue-python \
--with-queue-ram \
--with-queue-stub \
--with-table-ldap \
--with-table-mysql \
--with-table-redis \
--with-table-socketmap \
--with-table-passwd \
--without-table-postgres \
--with-table-python \
--with-table-sqlite \
--with-table-stub \
--with-tool-stats \
--with-scheduler-ram \
--with-scheduler-stub \
--with-scheduler-python \
--with-cflags="%{optflags} %{?gcc_lto} -I`pg_config --includedir` -I%{_includedir}/hiredis" \
--with-ldflags="-Wl,--as-needed -Wl,--strip-all %{?gcc_lto} -L%{_libdir}/mysql"
%{__make} %{?_smp_mflags}
PERL_CPPFLAGS="-I`perl -MConfig -e 'print $Config{archlib}'`/CORE" \
PERL_LDFLAGS="-L`perl -MConfig -e 'print $Config{archlib}'`/CORE -lperl"
cd -
%install
%{__make} install DESTDIR=%{buildroot}
cd opensmtpd-extras-%{extras}
%{__make} install DESTDIR=%{buildroot}
cd -
test -d %{buildroot}/usr/lib || %{__install} -d -m755 %{buildroot}/usr/lib
%{__ln_s} ../sbin/smtpctl %{buildroot}/usr/lib/sendmail
%if 0%{?_unitdir:1}
%{__install} -D -m644 %{S:12} %{buildroot}%{_unitdir}/opensmtpd.service
%else
%{__install} -D -m755 %{S:11} %{buildroot}%{_initrddir}/opensmtpd
%if 0%{?suse_version}
test -f %{buildroot}%{_initrddir}/opensmtpd && %{__ln_s} %{_initrddir}/opensmtpd %{buildroot}%{_sbindir}/rcopensmtpd
%endif
%endif
%if 0%{?suse_version}
%{__install} -d -m0755 %{buildroot}/etc/permissions.d/
cat > %{buildroot}/etc/permissions.d/%{name} <<EOF
%{sbindir}/smtpctl root:root 2555
EOF
%endif
mkdir -p %{buildroot}%{_var}/lib/smtpd
mkdir -p %{buildroot}%{_var}/spool/smtpd/purge
%clean
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
%files
%defattr(-,root,root)
%doc LICENSE README.md
%config(noreplace) %{_sysconfdir}/%{name}/smtpd.conf
%if 0%{?_unitdir:1}
%{_unitdir}/opensmtpd.service
%else
%{_initrddir}/opensmtpd
%if 0%{?suse_version}
%{_sbindir}/rcopensmtpd
%endif
%endif
%if 0%{?suse_version}
%config /etc/permissions.d/%{name}
%verify(not mode) %attr(0555,root,root) %{_sbindir}/smtpctl
%else
%{_sbindir}/smtpctl
%endif
%{_sbindir}/smtpd
%{_bindir}/smtp
/usr/lib/sendmail
%dir %{_libdir}/opensmtpd
%{_libdir}/opensmtpd/*
%doc %{_mandir}/man1/*
%doc %{_mandir}/man5/*
%doc %{_mandir}/man8/*
%exclude %{_libdir}/opensmtpd/queue-python
%exclude %{_libdir}/opensmtpd/scheduler-python
%exclude %{_libdir}/opensmtpd/table-ldap
%exclude %{_libdir}/opensmtpd/table-mysql
#% exclude % {_libdir}/opensmtpd/table-postgres
%exclude %{_libdir}/opensmtpd/table-python
%exclude %{_libdir}/opensmtpd/table-redis
%exclude %{_libdir}/opensmtpd/table-sqlite
%dir %{_var}/lib/smtpd
%dir %attr(0711,root,root) %{_var}/spool/smtpd
%dir %attr(2750,_smtpq,root) %{_var}/spool/smtpd/purge
%files dnsbl
%defattr(-,root,root)
#{_libdir}/opensmtpd/filter-dnsbl
%files ldap
%defattr(-,root,root)
%{_libdir}/opensmtpd/table-ldap
%files mysql
%defattr(-,root,root)
%{_libdir}/opensmtpd/table-mysql
#% files postgres
#% defattr(-,root,root)
#% {_libdir}/opensmtpd/table-postgres
%files python
%defattr(-,root,root)
%{_libdir}/opensmtpd/*-python
%files redis
%defattr(-,root,root)
%{_libdir}/opensmtpd/table-redis
%files sqlite
%defattr(-,root,root)
%{_libdir}/opensmtpd/table-sqlite
%if %{expand:%_vendor == "suse"}
%verifyscript
%verify_permissions -e /usr/sbin/smtpctl
%verify_permissions -e /usr/lib64/opensmtpd/lockspool
%if 0%{?_unitdir:1}
%pre
/usr/sbin/groupadd -r _smtpd >/dev/null 2>&1 || :
/usr/sbin/groupadd -r _smtpq >/dev/null 2>&1 || :
/usr/sbin/useradd -g _smtpd -s /bin/false -r -c "User for SMTP Daemon" -d %{_var}/lib/smtpd _smtpd >/dev/null 2>&1 || :
/usr/sbin/useradd -g _smtpq -s /bin/false -r -c "User for SMTPD Queue" -d %{_var}/lib/smtpd _smtpq >/dev/null 2>&1 || :
%{service_add_pre %{name}.service}
%endif
%post
%set_permissions /usr/sbin/smtpctl
%set_permissions /usr/lib64/opensmtpd/lockspool
%if 0%{?_unitdir:1}
%{fillup_only %{name}}
%{service_add_post %{name}.service}
%else
%{fillup_and_insserv %{name}}
%endif
%preun
%if 0%{?_unitdir:1}
%{service_del_preun %{name}.service}
%else
%{stop_on_removal %{name}}
%endif
%postun
%if 0%{?_unitdir:1}
%{service_del_postun %{name}.service}
%else
%{restart_on_update %{name}}
%endif
%{insserv_cleanup}
%endif
%changelog