Blob Blame Raw
Name:		milter-regex
Version:	1.8
Release:	4%{?dist}
Summary:	Milter plug-in for regular expression filtering
Group:		System Environment/Daemons
License:	BSD
URL:		http://www.benzedrine.cx/milter-regex.html
Source0:	http://www.benzedrine.cx/milter-regex-%{version}.tar.gz
Source1:	milter-regex.service
Source2:	milter-regex-options
Source3:	milter-regex.conf
Patch0:		milter-regex-1.6-gcc.patch
Patch1:		milter-regex-1.8-strlcat.patch
Buildrequires:	sendmail-devel >= 8.13, byacc, groff
BuildRequires:	systemd-units

Requires(pre): shadow-utils
Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units
# This is actually needed for the %%triggerun script but Requires(triggerun)
# is not valid. We can use %%post because this particular %%triggerun script
# should fire just after this package is installed. This can be removed for
# Fedora 18 when there will be no supported Fedora release with the SysV
# initscript to upgrade from.
Requires(post): systemd-sysv

%description
Milter-regex is a milter based filter that makes it possible to filter
emails using regular expressions.

%prep
%setup -q
%patch0 -p1 -b .gcc
%patch1 -p0 -b .strlcat
sed -i -e	's|/etc/milter-regex\.conf|%{_sysconfdir}/mail/milter-regex.conf|;
		 s|_milter-regex|mregex|' milter-regex.[8c]
head -n +31 milter-regex.c > LICENSE

%build
make %{?_smp_mflags} -f Makefile.linux CFLAGS="%{optflags} -DYYMAXDEPTH=8192"

%install
mkdir -p \
	%{buildroot}%{_unitdir} \
	%{buildroot}%{_localstatedir}/spool/milter-regex \
	%{buildroot}%{_mandir}/man8 \
	%{buildroot}%{_sbindir} \
	%{buildroot}%{_sysconfdir}/{mail,sysconfig}
install -p -m 755 milter-regex %{buildroot}%{_sbindir}/
install -p -m 644 milter-regex.8 %{buildroot}%{_mandir}/man8/
install -p -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/milter-regex.service
install -p -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/milter-regex
install -p -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/mail/milter-regex.conf

# Create a ghost sock file so we can remove it on package deletion
: > %{buildroot}%{_localstatedir}/spool/milter-regex/sock

%pre
/usr/bin/getent group mregex >/dev/null || /usr/sbin/groupadd -r mregex
/usr/bin/getent passwd mregex >/dev/null || \
	/usr/sbin/useradd -r -g mregex -d %{_localstatedir}/spool/milter-regex \
		-s /sbin/nologin -c "Regex Milter" mregex
exit 0

%post
if [ $1 -eq 1 ]; then
	# Initial installation 
	/bin/systemctl daemon-reload &>/dev/null || :
fi

%preun
if [ $1 -eq 0 ]; then
	# Package removal, not upgrade
	/bin/systemctl --no-reload disable milter-regex.service &>/dev/null || :
	/bin/systemctl stop milter-regex.service &>/dev/null || :
fi

%postun
/bin/systemctl daemon-reload &>/dev/null || :
if [ $1 -ge 1 ]; then
	# Package upgrade, not uninstall
	/bin/systemctl try-restart milter-regex.service &>/dev/null || :
fi

# SysV to systemd migration
# See http://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Systemd
# This can be removed for Fedora 18 when there will be no supported Fedora
# release with the SysV initscript to upgrade from
%triggerun -- milter-regex < 1.8-3
/usr/bin/systemd-sysv-convert --save milter-regex &>/dev/null || :
/sbin/chkconfig --del milter-regex &>/dev/null || :
/bin/systemctl try-restart milter-regex.service &>/dev/null || :

%files
%doc LICENSE
%{_sbindir}/milter-regex
%{_unitdir}/milter-regex.service
%config(noreplace) %{_sysconfdir}/sysconfig/milter-regex
%config(noreplace) %{_sysconfdir}/mail/milter-regex.conf
%dir %attr(755,mregex,mregex) %{_localstatedir}/spool/milter-regex/
%ghost %{_localstatedir}/spool/milter-regex/sock
%{_mandir}/man8/milter-regex.8*

%changelog
* Mon Jul 25 2011 Paul Howarth <paul@city-fan.org> - 1.8-4
- Requires(post): systemd-sysv for sysv-to-systemd migration

* Sat Jul 16 2011 Paul Howarth <paul@city-fan.org> - 1.8-3
- switch from SysV initscript to systemd unit file
- clean up for modern rpmbuild
- drop Sendmail references as the milter should work with Postfix too
- nobody else likes macros for commands

* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.8-2
- rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Fri Aug 13 2010 Paul Howarth <paul@city-fan.org> - 1.8-1
- update to 1.8 (log symbolic host name together with numeric IP address)
- add missing function strlcat from openbsd libc
- fix %%postun to restart the milter properly on package upgrades
- use %%{_initddir} rather than the deprecated %%{_initrddir} where possible

* Sat Jul 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.7-6
- rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.7-5
- rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Fri Feb 13 2009 Paul Howarth <paul@city-fan.org> - 1.7-4
- rebuild for shared libmilter in Fedora 11 development

* Mon Feb 18 2008 Paul Howarth <paul@city-fan.org> - 1.7-3
- support config files with more than 507 rules (#304071)

* Wed Aug 22 2007 Paul Howarth <paul@city-fan.org> - 1.7-2
- rebuild for BuildID inclusion
  (http://fedoraproject.org/wiki/Releases/FeatureBuildId)

* Mon Aug  6 2007 Paul Howarth <paul@city-fan.org> - 1.7-1
- update to 1.7 (sendmail macro filtering support added)
- tarball now includes a versioned directory name
- split milter-regex.conf out from being a here document in the spec and have
  it as a separate source file instead
- unexpand tabs 
- use the standard scriptlet for user/group creation in %%pre
- use %%{_initrddir} rather than %%{_sysconfdir}/rc.d/init.d for initscript
- use %%{__install} rather than %%{__cp} in %%install
- drop scriptlet dependencies on /sbin/service by calling initscript directly
- LSB-ize initscript (#246983)

* Wed Apr 18 2007 Paul Howarth <paul@city-fan.org> - 1.6-7
- add patch for compile errors on Fedora 7
- use sed rather than perl for quick scripted edits

* Tue Aug 29 2006 Paul Howarth <paul@city-fan.org> - 1.6-6
- rebuild for dynamic linking speedups (FE6)

* Thu May 25 2006 Paul Howarth <paul@city-fan.org> - 1.6-5
- Address issues raised in review (#189611)
  - Add sendmail dependency
  - Honor %%{optflags}

* Fri Apr 21 2006 Paul Howarth <paul@city-fan.org> - 1.6-4
- Minor cosmetic changes for resubmission for Fedora Extras

* Fri Nov 18 2005 Paul Howarth <paul@city-fan.org> - 1.6-3
- Remove redundant ver_ and rel_ macros
- Don't include package name in the summary
- Use macros consistently
- Generate LICENSE file in %%prep rather than %%install
- Don't strip binary, so debuginfo package is useful
- Combine groupadd+useradd into a single useradd command
- Use /sbin/nologin for mregex shell instead of non-existent /bin/nologin
- Don't delete user+group on package removal (see
  http://www.redhat.com/archives/fedora-extras-commits/2005-June/msg00271.html)
- Install initscript in %%{_sysconfdir} rather than /etc/init.d
- Don't enable service by default on installation
- Add scriptlet dependencies
- Add buildreq groff
- Use full URL for source
- Edit username in man page as well as in code
- Use install rather than cp to install %%{SOURCE1} and %%{SOURCE2} so
  that permissions don't need to be set in SRPM
- Ghost the socket for clean package removal
- Buildreq sendmail-devel >= 8.13.0 because of the use of SMFIF_QUARANTINE
- Use dist tag

* Tue Jan 25 2005 Victor Ramirez <vramirez@gmail.com> - 1.6-2 
- Initial rpm release
- Modified user and configuration file location.