From 992c58140e3d9372397f8b1366c1a452cdf4c549fa9bcd2acfc33b42647ba8ee Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Sun, 10 Nov 2013 10:08:03 +0000 Subject: [PATCH] Accepting request 204925 from home:posophe:branches:server:mail - Add systemd support for openSUSE >= 12.3 OBS-URL: https://build.opensuse.org/request/show/204925 OBS-URL: https://build.opensuse.org/package/show/server:mail/fetchmail?expand=0&rev=52 --- fetchmail.changes | 5 +++++ fetchmail.service | 11 +++++++++++ fetchmail.spec | 43 +++++++++++++++++++++++++++++++++---------- fetchmail.tmpfiles | 1 + 4 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 fetchmail.service create mode 100644 fetchmail.tmpfiles diff --git a/fetchmail.changes b/fetchmail.changes index 81c6328..7423e45 100644 --- a/fetchmail.changes +++ b/fetchmail.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Sun Oct 27 18:18:54 UTC 2013 - p.drouand@gmail.com + +- Add systemd support for openSUSE >= 12.3 + ------------------------------------------------------------------- Mon Apr 29 12:45:09 UTC 2013 - vcizek@suse.com diff --git a/fetchmail.service b/fetchmail.service new file mode 100644 index 0000000..1bc85fa --- /dev/null +++ b/fetchmail.service @@ -0,0 +1,11 @@ +[Unit] +Description=A remote-mail retrieval utility +After=network.target + +[Service] +User=fetchmail +ExecStart=/usr/bin/fetchmail -d 900 -f /etc/fetchmailrc +RestartSec=1 + +[Install] +WantedBy=multi-user.target diff --git a/fetchmail.spec b/fetchmail.spec index 7290786..f44b320 100644 --- a/fetchmail.spec +++ b/fetchmail.spec @@ -24,12 +24,7 @@ BuildRequires: postfix BuildRequires: procmail BuildRequires: pwdutils BuildRequires: python-devel -%if 0%{?suse_version} > 1000 -%define with_krb5 1 -%endif -%if 0%{?with_krb5} BuildRequires: krb5-devel -%endif %if 0%{?suse_version} > 1220 BuildRequires: gpg-offline %endif @@ -48,11 +43,18 @@ Source2: %{name}.logrotate Source3: sysconfig.%{name} Source4: http://sourceforge.net/projects/fetchmail/files/branch_6.3/%{name}-%{version}.tar.xz.asc Source5: %{name}.keyring +Source6: %{name}.service +Source7: %{name}.tmpfiles Patch0: fetchmail-6.3.8-smtp_errors.patch -PreReq: %fillup_prereq -PreReq: %insserv_prereq -PreReq: coreutils -PreReq: pwdutils +%if 0%{?suse_version} >=1230 +BuildRequires: pkgconfig(systemd) +%{?systemd_requires} +%else +Requires(pre): %insserv_prereq +%endif +Requires(pre): %fillup_prereq +Requires(pre): coreutils +Requires(pre): pwdutils BuildRequires: xz Requires: logrotate Suggests: smtp_daemon @@ -116,11 +118,18 @@ make %{?_smp_mflags} ln -sf fetchmail.1.gz %{buildroot}/%{_mandir}/man1/fetchmailconf.1.gz mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d cp fetchmail.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/fetchmail -mkdir -p %{buildroot}%{_sysconfdir}/init.d mkdir -p %{buildroot}/sbin +%if 0%{?suse_version} >=1230 +mkdir -p $RPM_BUILD_ROOT/%{_unitdir} +mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}/tmpfiles.d +install -m 755 %{S:6} $RPM_BUILD_ROOT/%{_unitdir}/%{name}.service +install -m 644 %{S:7} $RPM_BUILD_ROOT/%{_libexecdir}/tmpfiles.d/%{name}.conf +%else +mkdir -p %{buildroot}%{_sysconfdir}/init.d cp fetchmail.init %{buildroot}%{_initddir}/fetchmail chmod +x %{buildroot}%{_initddir}/fetchmail ln -s ../etc/init.d/fetchmail %{buildroot}/sbin/rcfetchmail +%endif touch %{buildroot}%{_sysconfdir}/fetchmailrc mkdir -p %{buildroot}%{_localstatedir}/adm/fillup-templates cp sysconfig.%{name} %{buildroot}%{_localstatedir}/adm/fillup-templates @@ -137,14 +146,23 @@ usr/sbin/useradd -r -g daemon -s /bin/false \ -c "mail retrieval daemon" -d /var/lib/fetchmail fetchmail 2>/dev/null || : %post +%if 0%{?suse_version} >=1230 +%{fillup_only} +%service_add_post %{name}.service +%else %{fillup_and_insserv} +%endif # Ensure that all files are readable by fetchmail with non-root UID. touch var/log/fetchmail chown fetchmail var/log/fetchmail chmod 0600 var/log/fetchmail %postun +%if 0%{?suse_version} >=1230 +%service_del_postun %{name}.service +%else %{insserv_cleanup} +%endif if [ $1 == 0 ]; then rm -rf var/lib/fetchmail fi @@ -158,8 +176,13 @@ fi %doc COPYING FAQ FEATURES NEWS NOTES OLDNEWS README README.NTLM README.SSL README.SSL-SERVER TODO contrib *.html *.txt *.pdf %ghost %config(noreplace) %attr(0600, fetchmail, root) %{_sysconfdir}/fetchmailrc %config(noreplace) %{_sysconfdir}/logrotate.d/fetchmail +%if 0%{?suse_version} >=1230 +%{_unitdir}/%{name}.service +%{_libexecdir}/tmpfiles.d/%{name}.conf +%else %{_sysconfdir}/init.d/fetchmail /sbin/rcfetchmail +%endif %{_localstatedir}/adm/fillup-templates/sysconfig.%{name} %files -n fetchmailconf diff --git a/fetchmail.tmpfiles b/fetchmail.tmpfiles new file mode 100644 index 0000000..3edf268 --- /dev/null +++ b/fetchmail.tmpfiles @@ -0,0 +1 @@ +d /run/fetchmail 700 fetchmail nobody