[milter-greylist] added systemd initscripts and obsolete the old sysvinit ones

ensc ensc at fedoraproject.org
Fri Dec 10 09:08:12 UTC 2010


commit 0febe49c1dd1ac426a964451a552c8ba16b154b1
Author: Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de>
Date:   Fri Dec 10 10:07:23 2010 +0100

    added systemd initscripts and obsolete the old sysvinit ones

 milter-greylist.spec            |  106 +++++++++++++++++++++++++++++++++------
 milter-greylist.systemd.service |   13 +++++
 2 files changed, 103 insertions(+), 16 deletions(-)
---
diff --git a/milter-greylist.spec b/milter-greylist.spec
index ee4292b..8c37eaa 100644
--- a/milter-greylist.spec
+++ b/milter-greylist.spec
@@ -4,9 +4,12 @@
 ## Fedora Extras specific customization below...
 %bcond_without		fedora
 %bcond_without		noarch
+%bcond_with		sysv
 %bcond_without		upstart
+%bcond_without		systemd
 %bcond_with		spf
 %bcond_with		libbind
+%bcond_without		tmpfiles
 ##
 
 %{?with_noarch:%global noarch	BuildArch:	noarch}
@@ -17,6 +20,7 @@
 %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}
@@ -24,7 +28,7 @@
 Summary:	Milter for greylisting, the next step in the spam control war
 Name:		milter-greylist
 Version:	4.2.6
-Release:	%release_func 1400
+Release:	%release_func 1401
 License:	BSD with advertising
 Group:		System Environment/Daemons
 URL:		http://hcpnet.free.fr/milter-greylist/
@@ -48,19 +52,23 @@ BuildRequires:		curl-devel GeoIP-devel
 %{?with_libbind:BuildRequires:	%_libdir/libbind.so}
 %{?FE_USERADD_REQ}
 
+
+# Remove me after EOL of RHEL5
 %package sysvinit
-Summary:	Sysv initscripts for %name
-Group:		System Environment/Daemons
-Provides:	init(%name) = sysvinit
+Summary:		Sysv initscripts for %name
+Group:			System Environment/Daemons
+Provides:		init(%name) = sysvinit
 Requires(preun):	%name = %version-%release
 Requires(postun):	%name = %version-%release
 Requires(preun):	initscripts
 Requires(postun):	initscripts
 Requires(post):		%__chkconfig
 Requires(preun):	%__chkconfig
+%{?noarch}
+
+# Remove me after F17
 Provides:		%name-sysv = %version-%release
 Obsoletes:		%name-sysv < %version-%release
-%{?noarch}
 
 %package upstart
 Summary:		upstart initscripts for %name
@@ -73,6 +81,24 @@ Requires(post):		/usr/bin/killall
 Requires(postun):	/sbin/initctl
 %{?noarch}
 
+%package systemd
+Summary:		Systemd initscripts for %name
+Group:			System Environment/Daemons
+Provides:		init(%name) = systemd
+Source20:		%name.systemd.service
+Requires(post):		/bin/systemctl
+Requires(preun):	/bin/systemctl
+Requires(postun):	/bin/systemctl
+%{?noarch}
+
+# Remove me after F17
+%if 0%{!?with_sysv:1}
+Provides:	%name-sysvinit = %version-%release
+Obsoletes:	%name-sysvinit < %version-%release
+Provides:	%name-sysv = %version-%release
+Obsoletes:	%name-sysv < %version-%release
+%endif
+
 
 %description
 Greylisting is a new method of blocking significant amounts of spam at
@@ -104,6 +130,16 @@ traffic and processor load on your mailserver.
 This package provides the upstart initscripts for the %name package.
 
 
+%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.
+
+This package provides the systemd initscripts for the %name package.
+
+
 %prep
 %setup -q %{?beta:-n %name-%version%beta}
 %patch0 -p1 -b .sysv
@@ -131,7 +167,7 @@ for i in `find -type f`; do
 done
 
 
-%define makeflags	TEST=false BINDIR=%_sbindir
+%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)"
@@ -154,18 +190,27 @@ export LDFLAGS="-Wl,--as-needed $(pkg-config --libs $_comps) -lGeoIP"
 %install
 rm -rf $RPM_BUILD_ROOT
 
-%__install -d -m755 $RPM_BUILD_ROOT{%_initrddir,%rundir,%dbdir,%_var/run}
+%__install -d -m755 $RPM_BUILD_ROOT{%rundir,%dbdir,%_var/run,%_sysconfdir/tmpfiles.d}
 %__make DESTDIR=$RPM_BUILD_ROOT install %makeflags USER="$(id -u)"
-%__install -p -m755 rc-redhat.sh $RPM_BUILD_ROOT%_initrddir/%name
-%__install -pD -m 0644 %SOURCE10 $RPM_BUILD_ROOT/etc/init/milter-greylist.conf
+
+install -D -p -m 0755 rc-redhat.sh $RPM_BUILD_ROOT%_initrddir/%name
+install -D -p -m 0644 %SOURCE10    $RPM_BUILD_ROOT%_sysconfdir/init/milter-greylist.conf
+install -D -p -m 0644 %SOURCE20    $RPM_BUILD_ROOT%_unitdir/%name.service
+
+cat << EOF > $RPM_BUILD_ROOT%_sysconfdir/tmpfiles.d/%name.conf
+-d %rundir 0710 %username mail
+EOF
 
 # 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
-%{?_without_sysv:  rm -rf $RPM_BUILD_ROOT%_initrddir}
-%{!?with_upstart:  rm -rf $RPM_BUILD_ROOT/etc/init}
+%{!?with_sysv:     rm -rf $RPM_BUILD_ROOT%_initrddir}
+%{!?with_sysv:     rm -rf $RPM_BUILD_ROOT%_var/run/milter-greylist.pid}
+%{!?with_upstart:  rm -rf $RPM_BUILD_ROOT%_sysconfdir/init}
+%{!?with_systemd:  rm -rf $RPM_BUILD_ROOT%_unitdir}
+%{!?with_tmpfiles: rm -rf $RPM_BUILD_ROOT%_sysconfdir/tmpfiles.d}
 
 
 %pre
@@ -198,6 +243,18 @@ test "$1"  = 0 || %_initrddir/%name condrestart >/dev/null || :
 test "$1" != "0" || /sbin/initctl -q stop milter-greylist || :
 
 
+%post systemd
+test "$1" -ne 1 || /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+
+%preun systemd
+test "$1" -ne 1 || /bin/systemctl disable %name.service > /dev/null 2>&1 || :
+test "$1" -ne 1 || /bin/systemctl stop    %name.service > /dev/null 2>&1 || :
+
+%postun systemd
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+test "$1" -eq 1 || /bin/systemctl try-restart %name.service >/dev/null 2>&1 || :
+
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
@@ -208,27 +265,44 @@ rm -rf $RPM_BUILD_ROOT
 %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
-%dir %attr(0710,%username,mail) %rundir
 %_sbindir/*
 
+%if 0%{?with_tmpfiles:1}
+  %_sysconfdir/tmpfiles.d/%name.conf
+  %ghost %dir %attr(0710,%username,mail) %rundir
+%endif
+
+%if 0%{!?with_tmpfiles:1}
+  %dir %attr(0710,%username,mail) %rundir
+%endif
+
 %ghost %rundir/milter-greylist.sock
-%ghost %_var/run/milter-greylist.pid
 
 
-%if 0%{!?_without_sysv:1}
+%if 0%{?with_sysv:1}
 %files sysvinit
   %defattr(-,root,root,-)
   %config %_initrddir/*
+  %ghost %_var/run/milter-greylist.pid
 %endif
 
 %if 0%{?with_upstart:1}
 %files upstart
-%defattr(-,root,root,-)
-%config(noreplace) /etc/init/*
+  %defattr(-,root,root,-)
+  %config(noreplace) %_sysconfdir/init/*
+%endif
+
+%if 0%{?with_systemd:1}
+%files systemd
+  %defattr(-,root,root,-)
+  %_unitdir/%name.service
 %endif
 
 
 %changelog
+* Fri Dec 10 2010 Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de> - 4.2.6-1401
+- added systemd initscripts and obsolete the old sysvinit ones
+
 * Wed Jul 14 2010 Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de> - 4.2.6-1400
 - updated to 4.2.6
 
diff --git a/milter-greylist.systemd.service b/milter-greylist.systemd.service
new file mode 100644
index 0000000..23c7993
--- /dev/null
+++ b/milter-greylist.systemd.service
@@ -0,0 +1,13 @@
+[Unit]
+Description = Grey listing filter for sendmail
+After = syslog.target
+Before = sendmail
+Before = postfix
+
+[Service]
+Type = simple
+ExecStart = /usr/sbin/milter-greylist -D
+Restart = on-failure
+
+[Install]
+WantedBy = multi-user.target


More information about the scm-commits mailing list