File lucheck-spp.spec of Package lucheck-spp
%define QMAIL_DIR /var/lib/qmail
Summary: A plugin for qmail-smtpd for checking if recipients can be delivered locally
Name: lucheck-spp
Version: 1.0.1
Release: 1
License: GPL
URL: https://github.com/pmconrad/lucheck-spp
Group: Productivity/Networking/Email/Servers
Source: https://github.com/pmconrad/lucheck-spp/archive/refs/tags/%{version}.tar.gz
Requires: netqmail-smtpd
BuildRequires: netqmail-smtpd
%if 0%{?suse_version} >= 1100 && 0%{?suse_version} < 1150
BuildRequires: licenses
Requires: licenses
%endif
%if 0%{?fedora} > 0
# Resolve stupid ambiguous dependency
BuildRequires: cronie-anacron
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
This package implements a plugin for D. J. Bernstein's "qmail" MTA
(http://qmail.org/ ). It requires qmail to be compiled with the
smtp-plugin-patch (https://qmail-spp.sourceforge.net/ ), hence the name.
The plugin will perform a configurable number of checks on every envelope
recipient of every incoming email. These checks are currently implemented:
- matching against local users (via getpwnam())
- matching against local aliases in ~alias/.qmail-<alias>
- matching against a fastforward-style aliases database (optional)
%prep
%setup
%build
echo >cdb-0.75/readwrite.h
make CFLAGS="%{optflags} -I\$(CDB) -include sys/types.h -include unistd.h -include stdio.h" \
LDFLAGS="%{optflags}"
lic="`md5sum LICENSE | cut -d' ' -f 1`"
if [ -r "/usr/share/doc/licenses/md5/$lic" ]; then
ln -sf /usr/share/doc/licenses/md5/"$lic" LICENSE
fi
%install
mkdir -p "%{buildroot}%{_libexecdir}/qmail/plugins"
install -m 0755 ",,build/src/%{name}" "%{buildroot}%{_libexecdir}/qmail/plugins"
mkdir -p "%{buildroot}%{_sysconfdir}/qmail/env"
echo "%{QMAIL_DIR}/alias" >"%{buildroot}%{_sysconfdir}/qmail/env/LUCHECK_ALIASDIR"
%__debug_install_post
%post
cd "%{QMAIL_DIR}/control"
if [ "$1" -ge 1 -a `grep -c plugins/%{name} smtpplugins` -eq 0 ]; then
echo "Trying to insert plugin into %{QMAIL_DIR}/control/smtpplugins..."
if grep '^\[rcpt\]$' smtpplugins >/dev/null; then
i=1
while [ `head -$i smtpplugins | grep -c '^\[rcpt\]$'` -lt 1 ]; do
i=$(($i + 1))
done
head -$i smtpplugins >smtpplugins.new
echo "plugins/%{name}" >>smtpplugins.new
tail +$(($i + 1)) smtpplugins >>smtpplugins.new && \
mv smtpplugins.new smtpplugins
else
echo "[rcpt]" >>smtpplugins
echo "plugins/%{name}" >>smtpplugins
fi
echo "Don't forget to set the required environment variables"
echo "when invoking qmail-smtpd."
fi
%preun
if [ "$1" = 0 ]; then
echo "Trying to remove %{name} from %{QMAIL_DIR}/control/smtpplugins..."
cd "%{QMAIL_DIR}/control"
grep -v '^plugins/%{name}$' smtpplugins >smtpplugins.new && \
mv smtpplugins.new smtpplugins
fi
%clean
[ "%{buildroot}" = "/" ] || rm -rf "%{buildroot}"
%files
%defattr(-,root,mail,-)
%doc doc/* README.md LICENSE
%config(noreplace) %{_sysconfdir}/qmail/env/LUCHECK_ALIASDIR
%{_libexecdir}/qmail/plugins/%{name}
%changelog