[milter-greylist] Merge sysv/system packages back into main package

Paul Howarth pghmcfc at fedoraproject.org
Mon May 20 19:39:00 UTC 2013


commit 43ebc9d2f402d73035be8991d0a1809416c36e44
Author: Paul Howarth <paul at city-fan.org>
Date:   Mon May 20 19:56:21 2013 +0100

    Merge sysv/system packages back into main package
    
    - Merge sysv/system packages back into main package, configuring appropriate
      initscrit for target distribution
    - Move tmpfiles configuration from /etc to /usr/lib
    - Re-do scriptlets

 README.fedora                      |    4 +-
 milter-greylist-2.0.2-sysv.patch   |   16 --
 milter-greylist-4.4.2-config.patch |   31 ++++
 milter-greylist-4.4.2-utf8.patch   |   11 ++
 milter-greylist.spec               |  346 +++++++++++++++++------------------
 5 files changed, 212 insertions(+), 196 deletions(-)
---
diff --git a/README.fedora b/README.fedora
index 32f7f0c..20b5d5f 100644
--- a/README.fedora
+++ b/README.fedora
@@ -2,13 +2,13 @@ Upstream compatibility
 ======================
 
 The fedora package uses a FHS compliant directory layout and does NOT
-place files below /var/milter-greylist.  Instead of:
+place files below /var/milter-greylist.  Instead:
 
 * the database is located at /var/lib/milter-greylist/db
 * the sendmail socket is located at /var/run/milter-greylist/milter-greylist.sock
 * the pidfile is located at /var/run/milter-greylist.pid
 
-This might be incompatible with online documentation which refers to
+This might be incompatible with online documentation that refers to
 the original paths.  Hence, please use the documentation provided by
 this package where you should find actual paths.
 
diff --git a/milter-greylist-4.4.2-config.patch b/milter-greylist-4.4.2-config.patch
new file mode 100644
index 0000000..f97b97a
--- /dev/null
+++ b/milter-greylist-4.4.2-config.patch
@@ -0,0 +1,31 @@
+--- greylist.conf
++++ greylist.conf
+@@ -5,11 +5,12 @@
+ # $Id: greylist.conf,v 1.48 2010/04/15 07:51:29 manu Exp $
+ #
+ 
+-pidfile "/var/run/milter-greylist.pid"
++#pidfile "/var/run/milter-greylist.pid"
+ socket "/var/milter-greylist/milter-greylist.sock"
+ dumpfile "/var/milter-greylist/greylist.db" 600
++geoipdb "/usr/share/GeoIP/GeoIP.dat"
+ dumpfreq 1
+-user "smmsp"
++user "grmilter"
+ 
+ # Log milter-greylist activity to a file
+ #stat ">>/var/milter-greylist/greylist.log" \
+--- rc-redhat.sh.in
++++ rc-redhat.sh.in
+@@ -13,10 +13,9 @@
+ . /etc/init.d/functions
+ 
+ pidfile="/var/milter-greylist/milter-greylist.pid"
+-socket="/var/milter-greylist/milter-greylist.sock"
+ user="@USER@"
+ hardstopdelay=5
+-OPTIONS="-u $user -P $pidfile -p $socket"
++OPTIONS="-u $user -P $pidfile"
+ if [ -f /etc/sysconfig/milter-greylist ]
+ then
+     . /etc/sysconfig/milter-greylist
diff --git a/milter-greylist-4.4.2-utf8.patch b/milter-greylist-4.4.2-utf8.patch
new file mode 100644
index 0000000..12dd5e5
--- /dev/null
+++ b/milter-greylist-4.4.2-utf8.patch
@@ -0,0 +1,11 @@
+--- ChangeLog
++++ ChangeLog
+@@ -42,7 +42,7 @@
+ 	Fix milter-greylist.m4 for newer Sendmail (Joe Pruett)
+ 	Fix autoconf warning about --datarootdir (R P Herrold)
+ 	Add spamassassin toggling to the .spec file (Adam Katz)
+-	Fix DKIM (John Wood, Jörgen Lundman)
++	Fix DKIM (John Wood, Jörgen Lundman)
+ 4.3.8
+ 	Fix spamd hang if message contains NULL (Enrico Scholz)
+ 	Format string for SpamAssassin score
diff --git a/milter-greylist.spec b/milter-greylist.spec
index 7ca44b2..adc2872 100644
--- a/milter-greylist.spec
+++ b/milter-greylist.spec
@@ -1,85 +1,61 @@
-## Fedora Extras specific customization below...
-%bcond_without		noarch
-%bcond_with		sysv
-%bcond_without		systemd
-%bcond_with		libbind
-%bcond_without		tmpfiles
-##
-
-%global _hardened_build	1
-
-%{?with_noarch:%global noarch	BuildArch:	noarch}
-
-%global username	grmilter
-%global vardir		%_var/lib/%name
-%global dbdir		%vardir/db
-%global rundir		%_var/run/%name
-%global __chkconfig	/sbin/chkconfig
-
-%{!?_unitdir:%global _unitdir /lib/systemd/system}
-%{!?release_func:%global release_func() %%{?prerelease:0.}%1%%{?prerelease:.%%prerelease}%%{?dist}}
-%{!?apply:%global  apply(p:n:b:) %patch%%{-n:%%{-n*}} %%{-p:-p %%{-p*}} %%{-b:-b %%{-b*}} \
-%nil}
-%{!?systemd_reqs:%global systemd_reqs \
-Requires(post):		 /bin/systemctl\
-Requires(preun):	 /bin/systemctl\
-Requires(postun):	 /bin/systemctl\
-%nil}
-%{!?systemd_install:%global systemd_install()\
-%post %1\
-test "$1" != "1" || /bin/systemctl daemon-reload >/dev/null 2>&1 || :\
-%preun %1\
-test "$1" != "0" || /bin/systemctl --no-reload disable %2 >/dev/null 2>&1 || :\
-test "$1" != "0" || /bin/systemctl stop %2 >/dev/null 2>&1 || :\
-%postun %1\
-/bin/systemctl daemon-reload >/dev/null 2>&1 || :\
-test "$1" = "0" || /bin/systemctl try-restart %2 >/dev/null 2>&1 || :\
-%nil}
+# Use systemd from F-15 / EL-7, else sysvinit
+%if 0%{?fedora} > 14 || 0%{?rhel} > 6
+%global use_systemd 1
+%global rundir /run
+%else
+%global use_systemd 0
+%global rundir %{_localstatedir}/run
+%endif
+
+# rundir (/var/run or /run) is on tmpfs from F-15 / EL-7
+%if 0%{?fedora} > 14 || 0%{?rhel} > 6
+%global rundir_tmpfs 1
+%endif
 
+# EL-5 needs to use libbind apparently
+%if "%{?rhel}" == "5"
+%global use_libbind 1
+%endif
 
 Summary:		Milter for greylisting, the next step in the spam control war
 Name:			milter-greylist
 Version:		4.4.2
-Release:		%release_func 1902
+Release:		1902%{?dist}
 License:		BSD with advertising
 Group:			System Environment/Daemons
 URL:			http://hcpnet.free.fr/milter-greylist/
-Source0:		ftp://ftp.espci.fr/pub/milter-greylist/%name-%version%{?beta}.tgz
+Source0:		ftp://ftp.espci.fr/pub/milter-greylist/milter-greylist-%{version}.tgz
 Source1:		README.fedora
-Patch0:			milter-greylist-2.0.2-sysv.patch
+Source20:		milter-greylist.systemd.service
+Patch0:			milter-greylist-4.4.2-config.patch
+Patch1:			milter-greylist-4.4.2-utf8.patch
 Patch4:			ai_addrconfig.patch
 Patch7:			milter-greylist-dkim-reentrant.patch
-BuildRoot:		%_tmppath/%name-%version-%release-root
-Requires:		init(%name)
-BuildRequires:		bison flex m4
+BuildRoot:		%{_tmppath}/%{name}-%{version}-%{release}-root-%(id -nu)
+BuildRequires:		bison
+BuildRequires:		flex
+BuildRequires:		m4
+BuildRequires:		curl-devel
+BuildRequires:		GeoIP-devel
 BuildRequires:		sendmail-devel
-BuildRequires:		curl-devel GeoIP-devel
-%{?with_libbind:BuildRequires:	%_libdir/libbind.so}
+%if 0%{?use_libbind}
+BuildRequires:		%{_libdir}/libbind.so
+%endif
 Requires(pre):		shadow-utils
-
-
-# Remove me after EOL of RHEL5
-%package sysvinit
-Summary:		Sysv initscripts for %name
-Group:			System Environment/Daemons
-Provides:		init(%name) = sysvinit
-Requires(preun):	%name = %version-%release
-Requires(postun):	%name = %version-%release
+%if %{use_systemd}
+Requires(post):		/bin/systemctl
+Requires(preun):	/bin/systemctl
+Requires(postun):	/bin/systemctl
+Obsoletes:		milter-greylist-systemd < %{version}-%{release}
+Provides:		milter-greylist-systemd = %{version}-%{release}
+%else
+Requires(post):		/sbin/chkconfig
+Requires(preun):	/sbin/chkconfig
 Requires(preun):	initscripts
 Requires(postun):	initscripts
-Requires(post):		%__chkconfig
-Requires(preun):	%__chkconfig
-%{?noarch}
-
-%package systemd
-Summary:		Systemd initscripts for %name
-Group:			System Environment/Daemons
-Provides:		init(%name) = systemd
-Requires:		%name = %version-%release
-Source20:		%name.systemd.service
-%{?systemd_reqs}
-%{?noarch}
-
+Obsoletes:		milter-greylist-sysv < %{version}-%{release}
+Provides:		milter-greylist-sysv = %{version}-%{release}
+%endif
 
 %description
 Greylisting is a new method of blocking significant amounts of spam at
@@ -90,163 +66,177 @@ traffic and processor load on your mailserver.
 
 This package provides a greylist filter for sendmail's milter API.
 
+%prep
+%setup -q -n milter-greylist-%{version}
 
-%description sysvinit
-Greylisting is a new method of blocking significant amounts of spam at
-the mailserver level, but without resorting to heavyweight statistical
-analysis or other heuristical (and error-prone) approaches. Consequently,
-implementations are fairly lightweight, and may even decrease network
-traffic and processor load on your mailserver.
-
-This package provides the SysV initscripts for the %name package.
+# Customize config for Fedora / EPEL
+# * Specify pidfile in initscript rather than config file
+# * Specify socket in config file rather than initscript
+# * Specify grmilter as the user to run the dæmon as
+# * Specify the GeoIP database location
+%patch0
 
+# Rec-code docs as UTF8
+%patch1
 
-%description systemd
-Greylisting is a new method of blocking significant amounts of spam at
-the mailserver level, but without resorting to heavyweight statistical
-analysis or other heuristical (and error-prone) approaches. Consequently,
-implementations are fairly lightweight, and may even decrease network
-traffic and processor load on your mailserver.
+# Work around issues with ISC libbind and AI_ADDRCONFIG
+# http://tech.groups.yahoo.com/group/milter-greylist/message/5048
+%patch4 -p1
 
-This package provides the systemd initscripts for the %name package.
+# Lock DKIM calls
+%patch7 -p1
 
+# README.fedora
+install -p -m 644 %{SOURCE1} .
 
-%prep
-%setup -q %{?beta:-n %name-%version%beta}
-%apply -n0 -p1
-%apply -n4 -p1
-%apply -n7 -p1
-
-install -p -m0644 %SOURCE1 .
-
+# Don't let the configure script find libresolv
 sed -i -e 's!/libresolv.a!/../../../no-such-lib.a!g' configure
-sed -i -e 's!^\#\?user .*!user "%username"!;
-	   s!^\#socket !socket !;
-	   s!^pidfile .*!\#\0!;
-	   /^dumpfile/a\' \
-	-e 'geoipdb "%_datadir/GeoIP/GeoIP.dat"' greylist.conf
 
+# Set socket/db/pidfile to be in FHS-compliant places
 for i in `find -type f`; do
-    sed -e 's!/var/milter-greylist/milter-greylist.sock!%rundir/milter-greylist.sock!g;
-	    s!/var/milter-greylist/greylist.db!%dbdir/greylist.db!g;
-	    s!/var/milter-greylist/milter-greylist.pid!%_var/run/milter-greylist.pid!g;
+    sed -e 's|/var/milter-greylist/milter-greylist.sock|%{rundir}/milter-greylist/milter-greylist.sock|g;
+	    s|/var/milter-greylist/greylist.db|%{_localstatedir}/lib/milter-greylist/db/greylist.db|g;
+	    s|/var/milter-greylist/milter-greylist.pid|%{rundir}/milter-greylist.pid|g;
 	   ' "$i" >"$i.tmp"
     cmp -s "$i" "$i.tmp" || cat "$i.tmp" >"$i"
     rm -f "$i".tmp
 done
 
 
-%global makeflags TEST=false BINDIR=%_sbindir
 %build
-_comps="%{?with_libbind:libbind} libcurl"
-export CPPFLAGS="-DUSE_CURL -DUSE_GEOIP -D_GNU_SOURCE -D_REENTRANT $(pkg-config --cflags-only-I $_comps)"
-export LDFLAGS="-Wl,--as-needed $(pkg-config --libs $_comps) -lGeoIP"
-
+greylist_comps="%{?use_libbind:libbind} libcurl"
+export CPPFLAGS="-DUSE_CURL -DUSE_GEOIP -D_GNU_SOURCE -D_REENTRANT $(pkg-config --cflags-only-I $greylist_comps)"
+export LDLIBS="$(pkg-config --libs $greylist_comps) -lGeoIP"
+# Harden the build if supported
+%if 0%{?fedora} > 15 || 0%{?rhel} > 6
+%global _hardened_build 1
+export CFLAGS="%{__global_cflags} -fno-strict-aliasing"
+export LDFLAGS="-Wl,-z,now -Wl,-z,relro %{__global_ldflags} -Wl,--as-needed $LDLIBS"
+%else
+export CFLAGS="%{optflags} -fno-strict-aliasing"
+export LDFLAGS="-Wl,--as-needed $LDLIBS"
+%endif
 %configure \
+	--disable-drac				\
 	--disable-rpath				\
-	--with-user=%username			\
+	--with-user=grmilter			\
 	--enable-dnsrbl				\
 	--enable-spamassassin			\
 	--enable-p0f				\
-	--disable-drac				\
-	--with-drac-db=%vardir/drac/drac.db
+	--with-drac-db=%{_localstatedir}/lib/milter-greylist/drac/drac.db
 
 ## is not SMP safe :(
-%__make %makeflags
-
+make BINDIR=%{_sbindir}
 
 %install
-rm -rf $RPM_BUILD_ROOT
-
-%__install -d -m755 $RPM_BUILD_ROOT{%rundir,%dbdir,%_var/run,%_sysconfdir/tmpfiles.d}
-%__make DESTDIR=$RPM_BUILD_ROOT install %makeflags USER="$(id -u)"
-
-install -D -p -m 0755 rc-redhat.sh	$RPM_BUILD_ROOT%_initrddir/%name
-install -D -p -m 0644 %SOURCE20		$RPM_BUILD_ROOT%_unitdir/%name.service
+rm -rf %{buildroot}
+install -d -m 755 %{buildroot}{%{rundir}/milter-greylist,%{_localstatedir}/lib/milter-greylist/db}
+make install \
+	DESTDIR=%{buildroot} \
+	BINDIR=%{_sbindir} \
+	TEST=false \
+	USER="$(id -u)"
+
+# Create a dummy socket so we can %%ghost it and remove it on uninstall
+touch %{buildroot}%{rundir}/milter-greylist/milter-greylist.sock
+
+# Initscript
+%if %{use_systemd}
+install -D -p -m 0644 %{SOURCE20} %{buildroot}%{_unitdir}/milter-greylist.service
+%else
+install -D -p -m 755 rc-redhat.sh %{buildroot}%{_initrddir}/milter-greylist
+touch %{buildroot}%{rundir}/milter-greylist.pid
+%endif
 
-cat << EOF > $RPM_BUILD_ROOT%_sysconfdir/tmpfiles.d/%name.conf
-d %rundir 0710 %username mail
+# Make sure /run/milter-greylist is re-created at boot time if /run is on tmpfs
+%if 0%{?rundir_tmpfs}
+install -d -m 755 %{buildroot}%{_prefix}/lib/tmpfiles.d
+cat << EOF > %{buildroot}%{_prefix}/lib/tmpfiles.d/milter-greylist.conf
+d %{rundir}/milter-greylist 0710 grmilter mail
 EOF
+%endif
 
-# create temporary files
-touch $RPM_BUILD_ROOT%rundir/milter-greylist.sock
-touch $RPM_BUILD_ROOT%_var/run/milter-greylist.pid
-
-## Remove the unwanted init-methods
-%{!?with_sysv:		rm -rf $RPM_BUILD_ROOT%_initrddir}
-%{!?with_sysv:		rm -rf $RPM_BUILD_ROOT%_var/run/milter-greylist.pid}
-%{!?with_systemd:	rm -rf $RPM_BUILD_ROOT%_unitdir}
-%{!?with_tmpfiles:	rm -rf $RPM_BUILD_ROOT%_sysconfdir/tmpfiles.d}
-
+%clean
+rm -rf %{buildroot}
 
 %pre
-getent group %{username} >/dev/null || groupadd -r %{username} -g 7
-getent passwd %{username} >/dev/null || \
-	useradd -r -g %{username} -d %{vardir} -s /sbin/nologin -u 7 \
-	-c "Greylist-milter user" %{username}
+# Create account for milter-greylist to run as
+getent group grmilter >/dev/null || groupadd -r grmilter
+getent passwd grmilter >/dev/null || \
+	useradd -r -g grmilter -d %{_localstatedir}/lib/milter-greylist -s /sbin/nologin \
+	 -c "Greylist-milter user" grmilter
 exit 0
 
-
-%{?with_tmpfiles:
 %post
-%{?with_systemd:/bin/systemd-tmpfiles --create %_sysconfdir/tmpfiles.d/%name.conf || :}}
-
-
-%post sysvinit
-%__chkconfig --add %name
-
-%preun sysvinit
-test "$1" != 0 || %__chkconfig --del %name
-test "$1" != 0 || %_initrddir/%name stop >/dev/null || :
-
-%postun sysvinit
-test "$1"  = 0 || %_initrddir/%name condrestart >/dev/null || :
-
-
-%systemd_install systemd %name.service
-
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%files
-%doc ChangeLog README README.fedora
-%_mandir/man*/*
-%attr(0640,root,%username) %verify(not mtime) %config(noreplace) %_sysconfdir/mail/greylist.conf
-%dir %attr(0751,%username,%username) %vardir
-%dir %attr(0770,root,%username) %dbdir
-%_sbindir/*
-
-%if 0%{?with_tmpfiles:1}
-%_sysconfdir/tmpfiles.d/%name.conf
-%ghost %dir %attr(0710,%username,mail) %rundir
+%if %{use_systemd}
+/bin/systemctl daemon-reload >/dev/null || 2>&1 :
 %endif
-
-%if 0%{!?with_tmpfiles:1}
-%dir %attr(0710,%username,mail) %rundir
+if [ $1 -eq 1 ]; then
+	# Initial installation
+%if ! %{use_systemd}
+	/sbin/chkconfig --add milter-greylist || :
 %endif
-
-%ghost %rundir/milter-greylist.sock
-
-
-%if 0%{?with_sysv:1}
-%files sysvinit
-%config %_initrddir/*
-%ghost %_var/run/milter-greylist.pid
+%if 0%{?fedora} >= 18
+	/bin/systemctl preset milter-greylist.service >/dev/null 2>&1 || :
+%endif
+fi
+
+%preun
+if [ $1 -eq 0 ]; then
+	# Package removal, not upgrade
+%if %{use_systemd}
+	/bin/systemctl --no-reload disable milter-greylist.service >/dev/null 2>&1 || :
+	/bin/systemctl stop milter-greylist.service >/dev/null 2>&1 || :
+%else
+	%{_initrddir}/milter-greylist stop >/dev/null || :
+	/sbin/chkconfig --del milter-greylist || :
 %endif
+fi
 
+%postun
+%if %{use_systemd}
+/bin/systemctl daemon-reload >/dev/null || 2>&1 :
+%endif
+if [ $1 -ge 1 ]; then
+	# Package upgrade, not uninstall
+%if %{use_systemd}
+	/bin/systemctl try-restart milter-greylist.service >/dev/null || :
+%else
+	%{_initrddir}/milter-greylist condrestart >/dev/null || :
+%endif
+fi
 
-%if 0%{?with_systemd:1}
-%files systemd
-%_unitdir/%name.service
+%files
+%doc ChangeLog README README.fedora
+%{_sbindir}/milter-greylist
+%attr(0640,root,grmilter) %verify(not mtime) %config(noreplace) %{_sysconfdir}/mail/greylist.conf
+%dir %attr(0751,grmilter,grmilter) %{_localstatedir}/lib/milter-greylist/
+%dir %attr(0770,root,grmilter) %{_localstatedir}/lib/milter-greylist/db/
+%dir %attr(0710,grmilter,mail) %{rundir}/milter-greylist/
+%{_mandir}/man5/greylist.conf.5*
+%{_mandir}/man8/milter-greylist.8*
+%ghost %{rundir}/milter-greylist/milter-greylist.sock
+
+%if 0%{?rundir_tmpfs}
+%{_prefix}/lib/tmpfiles.d/milter-greylist.conf
 %endif
 
+%if %{use_systemd}
+%{_unitdir}/milter-greylist.service
+%else
+%{_initrddir}/milter-greylist
+%ghost %{rundir}/milter-greylist.pid
+%endif
 
 %changelog
 * Thu Apr 11 2013 Paul Howarth <paul at city-fan.org> - 4.4.2-1902
 - Drop unused upstart support
 - Drop unused libspf support
 - Drop %%defattr, redundant since rpm 4.4
+- Merge sysv/system packages back into main package, configuring appropriate
+  initscrit for target distribution
+- Move tmpfiles configuration from /etc to /usr/lib
+- Re-do scriptlets
 
 * Wed Apr 10 2013 Jon Ciesla <limburgher at gmail.com> - 4.4.2-1901
 - Migrate from fedora-usermgmt to guideline scriptlets


More information about the scm-commits mailing list