[packages/logrotate] add systemd-cronjobs support

jajcus jajcus at pld-linux.org
Thu Mar 9 14:49:34 CET 2017


commit 5a7e1737dc8c5e70df3f7ecde39c2f448c94640e
Author: Jacek Konieczny <j.konieczny at eggsoft.pl>
Date:   Thu Mar 9 14:24:27 2017 +0100

    add systemd-cronjobs support

 cronjob-logrotate.service |  7 +++++++
 cronjob-logrotate.timer   | 11 +++++++++++
 logrotate.spec            | 25 ++++++++++++++++++++++---
 3 files changed, 40 insertions(+), 3 deletions(-)
---
diff --git a/logrotate.spec b/logrotate.spec
index 91033e7..0c98dc4 100644
--- a/logrotate.spec
+++ b/logrotate.spec
@@ -20,7 +20,7 @@ Summary(tr.UTF-8):	Sistem günlüklerini yönlendirir, sıkıştırır ve mektup
 Summary(uk.UTF-8):	Ротує, компресує, видаляє та відправляє поштою лог-файли
 Name:		logrotate
 Version:	3.11.0
-Release:	1
+Release:	1.1
 License:	GPL v2+
 Group:		Applications/System
 Source0:	https://github.com/logrotate/logrotate/releases/download/%{version}/%{name}-%{version}.tar.xz
@@ -29,6 +29,8 @@ Source1:	%{name}.conf
 Source2:	%{name}.sysconfig
 Source3:	%{name}.cron
 Source4:	%{name}.crontab
+Source5:	cronjob-%{name}.timer
+Source6:	cronjob-%{name}.service
 Patch0:		tabooext.patch
 Patch1:		%{name}-man.patch
 URL:		https://github.com/logrotate/logrotate
@@ -40,14 +42,16 @@ BuildRequires:	libselinux-devel
 %{?with_tests:BuildRequires:	libselinux-utils}
 %endif
 BuildRequires:	popt-devel >= 1.3
+BuildRequires:  rpmbuild(macros) >= 1.644
 BuildRequires:	tar >= 1:1.22
 BuildRequires:	xz
 Requires(post):	coreutils
 Requires:	coreutils
-Requires:	crondaemon
+Requires:	cronjobs
 Requires:	filesystem >= 4.0-4
 Requires:	gzip
 Requires:	setup >= 2.4.6
+Requires:       systemd-units >= 38
 Suggests:	/bin/mail
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
@@ -143,7 +147,8 @@ Logrotate призначений для полегшення адміністр
 %install
 rm -rf $RPM_BUILD_ROOT
 install -d $RPM_BUILD_ROOT/etc/{cron.d,logrotate.d,sysconfig} \
-	$RPM_BUILD_ROOT{%{_libexecdir},%{_mandir},%{statdir}}
+	$RPM_BUILD_ROOT{%{_libexecdir},%{_mandir},%{statdir}} \
+	$RPM_BUILD_ROOT%{systemdunitdir}
 
 %{__make} install \
 	DESTDIR=$RPM_BUILD_ROOT
@@ -152,6 +157,8 @@ cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.conf
 cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
 install -p %{SOURCE3} $RPM_BUILD_ROOT%{_libexecdir}/%{name}
 cp -p %{SOURCE4} $RPM_BUILD_ROOT/etc/cron.d/%{name}
+cp -p %{SOURCE5} $RPM_BUILD_ROOT%{systemdunitdir}
+cp -p %{SOURCE6} $RPM_BUILD_ROOT%{systemdunitdir}
 > $RPM_BUILD_ROOT%{statdir}/%{name}.status
 
 %clean
@@ -166,6 +173,9 @@ fi
 %triggerpostun -- %{name} < 3.7.8-4
 %{__sed} -i -e 's,olddir /var/log/archiv$,olddir /var/log/archive,' %{_sysconfdir}/%{name}.conf %{_sysconfdir}/logrotate.d/* || :
 
+%triggerpostun -- %{name} < 3.11.0-1.1
+%systemd_trigger %{name}.timer
+
 %post
 if [ -f /var/lib/logrotate.status ]; then
 	mv -f /var/lib/logrotate.status %{statdir}/logrotate.status
@@ -175,6 +185,13 @@ else
 	chown root:root %{statdir}/logrotate.status
 	chmod 640 %{statdir}/logrotate.status
 fi
+%systemd_post cronjob-logrotate.timer
+
+%preun
+%systemd_preun cronjob-logrotate.timer
+
+%postun
+%systemd_reload
 
 %files
 %defattr(644,root,root,755)
@@ -187,3 +204,5 @@ fi
 %attr(640,root,root) %ghost %{statdir}/logrotate.status
 %{_mandir}/man5/logrotate.conf.5*
 %{_mandir}/man8/logrotate.8*
+%{systemdunitdir}/cronjob-logrotate.service
+%{systemdunitdir}/cronjob-logrotate.timer
diff --git a/cronjob-logrotate.service b/cronjob-logrotate.service
new file mode 100644
index 0000000..8e3f9d3
--- /dev/null
+++ b/cronjob-logrotate.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=logrotate cron job
+
+[Service]
+ExecStart=/usr/lib/logrotate
+
+# vi: ft=systemd
diff --git a/cronjob-logrotate.timer b/cronjob-logrotate.timer
new file mode 100644
index 0000000..bfb2194
--- /dev/null
+++ b/cronjob-logrotate.timer
@@ -0,0 +1,11 @@
+[Unit]
+Description=logrotate cron job
+
+[Timer]
+OnCalendar=*-*-* 05:02:00
+Persistent=true
+
+[Install]
+WantedBy=cronjobs.target
+
+# vi: ft=systemd
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/logrotate.git/commitdiff/5a7e1737dc8c5e70df3f7ecde39c2f448c94640e



More information about the pld-cvs-commit mailing list