From 798ac60987edac803c9b059fe46e95beb6663d02 Mon Sep 17 00:00:00 2001 From: Marcin Krol Date: Wed, 18 Oct 2017 11:01:04 +0000 Subject: [PATCH] - from PLD with systemd stuff removed --- logrotate-man.patch | 29 +++++++ logrotate.conf | 39 +++++++++ logrotate.cron | 20 +++++ logrotate.crontab | 4 + logrotate.spec | 190 ++++++++++++++++++++++++++++++++++++++++++++ logrotate.sysconfig | 7 ++ tabooext.patch | 10 +++ 7 files changed, 299 insertions(+) create mode 100644 logrotate-man.patch create mode 100644 logrotate.conf create mode 100755 logrotate.cron create mode 100644 logrotate.crontab create mode 100644 logrotate.spec create mode 100644 logrotate.sysconfig create mode 100644 tabooext.patch diff --git a/logrotate-man.patch b/logrotate-man.patch new file mode 100644 index 0000000..8b2956d --- /dev/null +++ b/logrotate-man.patch @@ -0,0 +1,29 @@ +--- logrotate-3.12.3/logrotate.8.in~ 2017-07-02 20:26:48.000000000 +0300 ++++ logrotate-3.12.3/logrotate.8.in 2017-07-02 20:27:25.062722303 +0300 +@@ -104,7 +104,7 @@ + rotate 5 + weekly + postrotate +- /usr/bin/killall \-HUP syslogd ++ /bin/killall \-HUP syslogd + endscript + } + +@@ -114,7 +114,7 @@ + size 100k + sharedscripts + postrotate +- /usr/bin/killall \-HUP httpd ++ /bin/killall \-HUP httpd + endscript + } + +@@ -146,7 +146,7 @@ + \fI/var/log/messages\fR. The log will go through five weekly rotations before + being removed. After the log file has been rotated (but before the old + version of the log has been compressed), the command +-\fI/usr/bin/killall \-HUP syslogd\fR will be executed. ++\fI/bin/killall \-HUP syslogd\fR will be executed. + + The next section defines the parameters for both + \fI/var/log/httpd/access.log\fR and \fI/var/log/httpd/error.log\fR. diff --git a/logrotate.conf b/logrotate.conf new file mode 100644 index 0000000..cbe7508 --- /dev/null +++ b/logrotate.conf @@ -0,0 +1,39 @@ +# See "man logrotate" for details. +# Rotate log files weekly. +weekly + +# Keep 10 weeks worth of backlogs. +rotate 10 + +# Rotate logs when they grow bigger than 100kB +minsize 100k + +# Don't mail old log files to any address. +nomail + +# Create new (empty) log files after rotating old ones. +create 640 root logs + +# use date as a suffix of the rotated file +dateext + +# Uncomment this if you want your log files compressed. +compress + +# Postpone compression of the previous log file to the next rotation cycle. +nodelaycompress + +# If the log file is missing, go on to the next one without issuing +# an error message. +missingok + +# Logs are moved into directory for rotation. +olddir /var/log/archive + +# Do not rotate the log if it is empty. +notifempty + +# system-specific logs may be configured here + +# RPM packages drop log rotation information into this directory. +include /etc/logrotate.d diff --git a/logrotate.cron b/logrotate.cron new file mode 100755 index 0000000..daf244f --- /dev/null +++ b/logrotate.cron @@ -0,0 +1,20 @@ +#!/bin/sh +MAILTO="" +ARG="" + +if [ -e /etc/sysconfig/logrotate ]; then + . /etc/sysconfig/logrotate +fi + +# NOTE: DISABLE_LOGROTATE_CRON is not official option to tune, it's only here to handle migration from < 3.8.6-1 +[ "$DISABLE_LOGROTATE_CRON" = "yes" ] && exit 0 + +/usr/sbin/logrotate $ARG /etc/logrotate.conf "$@" +EXITVALUE=$? +if [ $EXITVALUE != 0 ]; then + /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]" + if [ -n "$MAILTO" ]; then + echo "ALERT exited abnormally with [$EXITVALUE]" | mail -s "logrotate exited abnormally" $MAILTO + fi +fi +exit 0 diff --git a/logrotate.crontab b/logrotate.crontab new file mode 100644 index 0000000..ad15e57 --- /dev/null +++ b/logrotate.crontab @@ -0,0 +1,4 @@ +MAILTO=root + +# logrotate to run daily +02 5 * * * root /usr/lib/logrotate diff --git a/logrotate.spec b/logrotate.spec new file mode 100644 index 0000000..89f7ca1 --- /dev/null +++ b/logrotate.spec @@ -0,0 +1,190 @@ +# TODO +# - bug: when logrotate.status is written truncated (due disk getting full) and +# the line is partial, it will complain erronously that the line is too long +# while it just doesn't have the second DATE column. and that error should be +# ignored as warning not fatal as error. +# +# Conditional build: +%bcond_without acl # build without ACLs support +%bcond_without selinux # build without SELinux support +%bcond_without tests # do not perform "make test" + +Summary: Rotates, compresses, removes and mails system log files +Summary(de.UTF-8): Rotiert, komprimiert und verschickt Systemlogs +Summary(es.UTF-8): Hace el rutado, comprime y envía mail de logs del sistema +Summary(fr.UTF-8): Fait tourner, compresse, et envoie par mail les connexions au système +Summary(pl.UTF-8): System rotacji i kompresowania logów +Summary(pt_BR.UTF-8): Rotaciona, comprime e envia mail de logs do sistema +Summary(ru.UTF-8): Ротирует, компрессирует, удаляет и отправляет по почте лог-файлы +Summary(tr.UTF-8): Sistem günlüklerini yönlendirir, sıkıştırır ve mektup olarak yollar +Summary(uk.UTF-8): Ротує, компресує, видаляє та відправляє поштою лог-файли +Name: logrotate +Version: 3.13.0 +Release: 1 +License: GPL v2+ +Group: Applications/System +Source0: https://github.com/logrotate/logrotate/releases/download/%{version}/%{name}-%{version}.tar.xz +# Source0-md5: 78ef24d6fddcc4df8e412dd75c551b4c +Source1: %{name}.conf +Source2: %{name}.sysconfig +Source3: %{name}.cron +Source4: %{name}.crontab +Patch0: tabooext.patch +Patch1: %{name}-man.patch +URL: https://github.com/logrotate/logrotate +%{?with_acl:BuildRequires: acl-devel} +BuildRequires: autoconf >= 2.50 +BuildRequires: automake >= 1:1.13 +%if %{with selinux} +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: cronjobs +Requires: filesystem >= 4.0-4 +Requires: gzip +Requires: setup >= 2.4.6 +Suggests: /bin/mail +BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) + +%define statdir /var/lib/misc +%define _libexecdir %{_prefix}/lib + +%description +The logrotate utility is designed to simplify the administration of +log files on a system which generates a lot of log files. Logrotate +allows for the automatic rotation compression, removal and mailing of +log files. Logrotate can be set to handle a log file daily, weekly, +monthly or when the log file gets to a certain size. Normally, +logrotate runs as a daily cron job. + +%description -l de.UTF-8 +Logrotate vereinfacht die Verwaltung von Systemen, die sehr viele +Log-Dateien erzeugen, indem es das automatische Rotieren, +Komprimieren, Entfernen, und Senden von Log-Dateien ermöglicht. Jede +Log-Datei kann täglich, wöchentlich oder monatlich verarbeitet werden, +wenn sie zu groß wird. + +%description -l es.UTF-8 +Logrotate fue proyectado para facilitar la administración de sistemas +que generan gran número de archivos de log. Permite automatización en +la rotación, compresión, remoción y envío de mail de archivos de logs. +Cada archivo de log puede ser tratado diariamente, semanalmente, +mensualmente o cuanto crezca demasiado. + +%description -l fr.UTF-8 +Logrotate est conçu pour faciliter l'administration de systèmes qui +générent un grand nombre de fichiers de \"log\". Il permet le +roulement, la suppréssion la compression et l'envoi automatiques de +ces fichiers. Chaque fichier de \"log\" peut être pris en charge de +manière quotidienne, hebdomadaire, mensuelle, ou quand il devient trop +volumineux. + +%description -l pl.UTF-8 +Logrotate jest przeznaczony do łatwej administracji plikami logów. +Program ten pozwala na automatyczną kompresję logów. Może kontrolować +logi raz dziennie, raz na miesiąc, raz na tydzień lub wtedy kiedy +pliki z logami systemowymi są już duże. + +%description -l pt_BR.UTF-8 +Logrotate foi projetado para facilitar a administração de sistemas que +geram grande número de arquivos de log. Permite automatização na +rotação, compressão, remoção e envio de mail de arquivos de logs. Cada +arquivo de log pode ser tratado diariamente, semanalmente, mensalmente +ou quanto crescer demais. + +%description -l ru.UTF-8 +Logrotate предназначен для облегчения администрирования системы, +которая генерирует большое количество файлов с логами. Он позволяет +автоматически ротировать, компрессировать, удалять и посылать файлы с +логами по e-mail. Каждый лог может обрабатываться ежедневно, +еженедельно, ежемесячно или по достижении определенного размера. + +%description -l tr.UTF-8 +logrotate çok fazla sayıda günlük dosyası üreten sistemlerin +yönetimini kolaylaştırmak için tasarlanmıştır. Kayıt dosyalarının +otomatik olarak yönlendirilmesini, sıkıştırılmasını, silinmesinı ve +mektup olarak yollanmasını sağlar. Her dosya günlük, haftalık, aylık +olarak ya da çok büyük boyutlara ulaştığında işlenebilir. + +%description -l uk.UTF-8 +Logrotate призначений для полегшення адміністрування системи, яка +генерує велику кількість файлів з логами. Він дозволяє автоматично +ротувати, компресувати, видаляти та посилати поштою лог-файли. Кожен +лог може оброблятися щоденно, щотижня, щомісяця або по досягненні +визначеного розміру. + +%prep +%setup -q +%patch0 -p1 +%patch1 -p1 + +%build +%{__aclocal} +%{__autoconf} +%{__automake} + +%configure \ + --disable-silent-rules \ + --with%{!?with_acl:out}-acl \ + --with%{!?with_selinux:out}-selinux \ + --with-state-file-path=%{statdir}/logrotate.status + +%{__make} + +%if %{with tests} +%{__make} test +%endif + +%install +rm -rf $RPM_BUILD_ROOT +install -d $RPM_BUILD_ROOT/etc/{cron.d,logrotate.d,sysconfig} \ + $RPM_BUILD_ROOT{%{_libexecdir},%{_mandir},%{statdir}} + +%{__make} install \ + DESTDIR=$RPM_BUILD_ROOT + +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} +> $RPM_BUILD_ROOT%{statdir}/%{name}.status + +%clean +rm -rf $RPM_BUILD_ROOT + +%triggerun -- %{name} < 3.8.6-1 +# if previous install had /etc/cron.daily/* files removed (missingok), disable the cronjob +if [ ! -e /etc/cron.daily/%{name} ]; then + echo DISABLE_LOGROTATE_CRON=yes >> /etc/sysconfig/%{name} +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/* || : + +%post +if [ -f /var/lib/logrotate.status ]; then + mv -f /var/lib/logrotate.status %{statdir}/logrotate.status +else + touch %{statdir}/logrotate.status + chmod 000 %{statdir}/logrotate.status + chown root:root %{statdir}/logrotate.status + chmod 640 %{statdir}/logrotate.status +fi + +%files +%defattr(644,root,root,755) +%doc README.md ChangeLog.md +%attr(755,root,root) %{_sbindir}/logrotate +%attr(755,root,root) %{_libexecdir}/logrotate +%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}.conf +%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name} +%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/cron.d/%{name} +%attr(640,root,root) %ghost %{statdir}/logrotate.status +%{_mandir}/man5/logrotate.conf.5* +%{_mandir}/man8/logrotate.8* diff --git a/logrotate.sysconfig b/logrotate.sysconfig new file mode 100644 index 0000000..4d5849e --- /dev/null +++ b/logrotate.sysconfig @@ -0,0 +1,7 @@ +# Customized settings for logrotate + +# send logrotate errors information by mail to +#MAILTO="root" + +# additional logrotate arguments +ARG="" diff --git a/tabooext.patch b/tabooext.patch new file mode 100644 index 0000000..3048d39 --- /dev/null +++ b/tabooext.patch @@ -0,0 +1,10 @@ +--- logrotate-3.12.3/config.c~ 2017-05-22 15:10:22.000000000 +0300 ++++ logrotate-3.12.3/config.c 2017-07-02 20:26:14.825924824 +0300 +@@ -129,6 +129,7 @@ + static const char *defTabooExts[] = { + ",v", + ".cfsaved", ++ ".cvsignore", + ".disabled", + ".dpkg-dist", + ".dpkg-new", -- 2.37.3