%bcond_with systemd

Summary: Rotates, compresses, removes and mails system log files.
Summary(ja): システムのログファイルを圧縮/削除するプログラム
Name: logrotate
Version: 3.22.0
Release: 1%{?_dist_release}%{?with_systemd:.systemd}
Group: system
Vendor: Project Vine
Distribution: Vine Linux

License: GPL
Url: https://fedorahosted.org/logrotate/
Source: https://github.com/logrotate/logrotate/releases/download/%{version}/logrotate-%{version}.tar.xz

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: acl libacl-devel popt-devel
Requires: coreutils >= 5.92
Requires: popt

%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.

Install the logrotate package if you need a utility to deal with the
log files on your system.

%description -l ja
logrotate ユーティリティは，ログファイルを大量に生成するシステムでの
ログファイル管理を楽にする目的で作られています．
logrotate はログファイルを古いものから順にリネームしたり，
圧縮したり，メールで送ったりすることが出来ます．
logrotate の処理は，毎日/毎週/毎月といった単位でも設定出来ますし，
ログファイルが一定サイズに達した時に処理する様にすることも出来ます．
通常は logrotate は cron によって毎日実行される様になっています．

システム上のログファイルを管理するツールが必要なら
logrotate パッケージをインストールして下さい．


%debug_package


%prep
%setup -q

#perl -pi -e 's|/usr/sbin/logrotate|/usr/sbin/logrotate -l syslog|' examples/logrotate.cron


%build
./autogen.sh
%configure --with-state-file-path=/var/lib/logrotate/logrotate.status
make %{?_smp_mflags}


%check
make test


%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d
mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/logrotate

install -p -m 644 examples/logrotate.conf $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.conf
install -p -m 644 examples/{b,w}tmp $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/
touch $RPM_BUILD_ROOT/%{_localstatedir}/lib/logrotate/logrotate.status

%if %{with systemd}
mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
install -p -m 644 examples/logrotate.{service,timer} $RPM_BUILD_ROOT%{_unitdir}/
%else
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/cron.daily
install -p -m 755 examples/logrotate.cron $RPM_BUILD_ROOT/%{_sysconfdir}/cron.daily/logrotate
%endif


%clean
rm -rf $RPM_BUILD_ROOT


%pre
# If /var/lib/logrotate/logrotate.status does not exist, create it and copy
# the /var/lib/logrotate.status in it (if it exists). We have to do that in pre
# script, otherwise the /var/lib/logrotate/logrotate.status would not be there,
# because during the update, it is removed/renamed.
if [ ! -d %{_localstatedir}/lib/logrotate/ -a -f %{_localstatedir}/lib/logrotate.status ]; then
  mkdir -p %{_localstatedir}/lib/logrotate
  cp -a %{_localstatedir}/lib/logrotate.status %{_localstatedir}/lib/logrotate
fi

%post
chmod 0640 %{_localstatedir}/lib/logrotate/logrotate.status ||:
%if %{with systemd}
%systemd_post logrotate.{service,timer}
%endif

%if %{with systemd}
%preun
%systemd_preun logrotate.{service,timer}

%triggerin -- logrotate < %{version}-%{release}
if [ -e %{_sysconfdir}/crontab -o -e %{_sysconfdir}/anacrontab ]; then
  if [ -e %{_sysconfdir}/cron.daily/logrotate ]; then
    /bin/systemctl enable --now logrotate.timer &>/dev/null || :
  fi
fi
%endif


%files
%defattr(-,root,root)
%{!?_licensedir:%global license %%doc}
%license COPYING
%doc CHANGES
%attr(0755, root, root) %{_sbindir}/logrotate
%attr(0644, root, root) %{_mandir}/man8/logrotate.8*
%attr(0644, root, root) %{_mandir}/man5/logrotate.conf.5*
%attr(0644, root, root) %config(noreplace) %{_sysconfdir}/logrotate.conf
%attr(0755, root, root) %dir %{_sysconfdir}/logrotate.d
%attr(0644, root, root) %config(noreplace) %{_sysconfdir}/logrotate.d/{b,w}tmp
%attr(0640, root, root) %verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/logrotate/logrotate.status
%if %{with systemd}
%{_unitdir}/logrotate.*
%else
%attr(0755, root, root) %{_sysconfdir}/cron.daily/logrotate
%endif


%changelog
* Mon Jun 03 2024 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.22.0-1
- new upstream release.

* Wed Dec 14 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.21.0-1
- new upstream release.

* Fri May 27 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.20.1-2
- fixed permission.
- added systemd support (disabled as default).

* Thu May 26 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.20.1-1
- new upstream release.

* Fri Jan 14 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.19.0-1
- new upstream release.

* Fri Apr 10 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.16.0-1
- new upstream release.

* Sun Jun 19 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.9.2-2
- drop Patch0 (get the same effect by another way).

* Sat Jun 18 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.9.2-1
- new upstream release.
- changed location of Source0.
- imported Patch0 from rawhide.

* Sun Jul 20 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.8.6-1
- rebuild with VineSeed environment

* Thu Oct 03 2013 Daisuke SUZUKI <daisuke@linux.or.jp> 3.8.6-1
- new upstream release

* Wed Apr 13 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 3.7.9-1
- new upstream release
- add Url
- add patches from fedora
  - fix #688520 - fixed CVE-2011-1154, CVE-2011-1155 and CVE-2011-1098
  - fix #671926 - fixed crash when tabooext is used in config file
  - fix #661181 - fixed SIGBUS when config file is empty or 4096 bytes
  - fix #666677 - preserve ACLs when rotating files
  - fix #644309 - mention all logrotate params in man page
  - fix #638629 - better size directive description
  - fixed AUTHORS in man page

* Sun Jun 15 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.7.7-1
- new upstream release
- spec in UTF-8

* Wed Jun  7 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.7.4-1vl1
- based on 3.7.4-1 from Rawhide
  * Wed May 17 2006 Peter Vrabec <pvrabec@redhat.com> 3.7.4-1
  - add new "minsize" option (#173088)
  * Tue Mar 28 2006 Peter Vrabec <pvrabec@redhat.com> 3.7.3-3
  - correct man page "extension" option description  (#185318)
  * Mon Nov 07 2005 Peter Vrabec <pvrabec@redhat.com> 3.7.2-11
  - man description for "nodateext" option (#171577)
  - remove not working "pattern" option (#171577)
  * Wed Sep 07 2005 Peter Vrabec <pvrabec@redhat.com> 3.7.2-3
  - even when sharedscript option used, do postrotate 
    script before compress (#167575)
  * Wed Aug 17 2005 Peter Vrabec <pvrabec@redhat.com> 3.7.2-2
  - allow yearly rotations(#134612)
  * Wed Jun 22 2005 Peter Vrabec <pvrabec@redhat.com> 3.7.1-12
  - enhance logrotate with "dateext", "maxage"

* Fri Apr 11 2003 Ryoichi INAGAKI <ryo1@ueda.info.waseda.ac.jp> 3.6.8-1vl1
- based on 3.6.8-1 from Rawhide
- add Requires, BuildRequires popt
  * Mon Jan 20 2003 Elliot Lee <sopwith@redhat.com> 3.6.8-1
  - Old patch from pm@debian.org
  * Tue Jan 14 2003 Elliot Lee <sopwith@redhat.com> 3.6.7-1
  - Fixes from bugzilla
  * Fri Nov 15 2002 Elliot Lee <sopwith@redhat.com> 3.6.6-1
  - Commit patch from Fidelis Assis <fidelis@embratel.net.br>
  * Thu Jun 20 2002 Elliot Lee <sopwith@redhat.com> 3.6.5-1
  - Commit fix for #65299
  * Mon Apr 15 2002 Elliot Lee <sopwith@redhat.com> 3.6.4-1
  - Commit fix for #62560
  * Wed Mar 13 2002 Elliot Lee <sopwith@redhat.com> 3.6.3-1
  - Apply various bugfix patches from the openwall people
  * Tue Jan 29 2002 Elliot Lee <sopwith@redhat.com> 3.6.2-1
  - Fix bug #55809 (include logrotate.status in %files)
  - Fix bug #58328 (incorrect error detection when reading state file)
  - Allow 'G' size specifier from bug #57242
  * Wed Nov 28 2001 Preston Brown <pbrown@redhat.com> 3.6-1
  - patch from Alexander Kourakos <awk@awks.org> to stop the shared
    postrotate/prerotate scripts from running if none of the log(s) need
    rotating.  All log files are now checked for rotation in one batch,
    rather than sequentially.
  - more fixes from Paul Martin <pm@debian.org>

* Thu Oct  4 2001 IWAI Masaharu <iwaim@cc.mbn.or.jp> 3.5.4-1vl2
- added noreplace flag (%%config file is not replaced)

* Sun Jan 14 2001 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 3.5.4-1vl1
- based on 3.5.4-1 from Rawhide
- use better macros (%%{_tmppath}, %%{_sbindir})
- added Japanese summary and description

* Thu Jan  4 2001 Bill Nottingham <notting@redhat.com>
- %defattr

* Wed Jan 03 2001 Preston Brown <pbrown@redhat.com>
- see CHANGES

* Tue Aug 15 2000 Erik Troan <ewt@redhat.com>
- see CHANGES

* Sun Jul 23 2000 Erik Troan <ewt@redhat.com>
- see CHANGES

* Tue Jul 11 2000 Erik Troan <ewt@redhat.com>
- support spaces in filenames
- added sharedscripts

* Sun Jun 18 2000 Matt Wilson <msw@redhat.com>
- use %%{_mandir} for man pages

* Thu Feb 24 2000 Erik Troan <ewt@redhat.com>
- don't rotate lastlog

* Thu Feb 03 2000 Erik Troan <ewt@redhat.com>
- gzipped manpages
