replacing cron with systemd.timer

- resolves: #1148559
adding zsoelim to {_libexecdir}/man-db/zsoelim
- related: #1145493
This commit is contained in:
Jan Chaloupka 2014-10-08 15:04:11 +02:00
parent 52a4b8a1c9
commit 3b21cf2846
5 changed files with 47 additions and 48 deletions

View File

@ -1,27 +0,0 @@
#!/bin/bash
if [ -e /etc/sysconfig/man-db ]; then
. /etc/sysconfig/man-db
fi
if [ "$CRON" = "no" ]; then
exit 0
fi
renice +19 -p $$ >/dev/null 2>&1
ionice -c3 -p $$ >/dev/null 2>&1
LOCKFILE=/var/lock/man-db.lock
# the lockfile is not meant to be perfect, it's just in case the
# two man-db cron scripts get run close to each other to keep
# them from stepping on each other's toes. The worst that will
# happen is that they will temporarily corrupt the database
[[ -f $LOCKFILE ]] && exit 0
trap "{ rm -f $LOCKFILE ; exit 0; }" EXIT
touch $LOCKFILE
# create/update the mandb database
mandb $OPTS
exit 0

10
man-db.service Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=Update man-db cache
RequiresMountsFor=/var/cache/man
[Service]
Type=oneshot
ExecStart=/usr/bin/mandb --quiet
Nice=19
IOSchedulingClass=best-effort
IOSchedulingPriority=7

View File

@ -4,7 +4,7 @@
Summary: Tools for searching and reading man pages Summary: Tools for searching and reading man pages
Name: man-db Name: man-db
Version: 2.7.0.2 Version: 2.7.0.2
Release: 1%{?dist} Release: 2%{?dist}
# GPLv2+ .. man-db # GPLv2+ .. man-db
# GPLv3+ .. gnulib # GPLv3+ .. gnulib
License: GPLv2+ and GPLv3+ License: GPLv2+ and GPLv3+
@ -12,8 +12,8 @@ Group: System Environment/Base
URL: http://www.nongnu.org/man-db/ URL: http://www.nongnu.org/man-db/
Source0: http://download.savannah.gnu.org/releases/%{name}/%{name}-%{version}.tar.xz Source0: http://download.savannah.gnu.org/releases/%{name}/%{name}-%{version}.tar.xz
Source1: man-db.crondaily Source1: man-db.service
Source2: man-db.sysconfig Source2: man-db.timer
Obsoletes: man < 2.0 Obsoletes: man < 2.0
Provides: man = %{version} Provides: man = %{version}
@ -21,9 +21,9 @@ Provides: man-pages-reader = %{version}
# FPC exception for gnulib - copylib - https://fedorahosted.org/fpc/ticket/174 # FPC exception for gnulib - copylib - https://fedorahosted.org/fpc/ticket/174
Provides: bundled(gnulib) = %{gnulib_ver} Provides: bundled(gnulib) = %{gnulib_ver}
Requires: coreutils, grep, groff-base, gzip, less, crontabs Requires: coreutils, grep, groff-base, gzip, less, systemd
BuildRequires: gdbm-devel, gettext, groff, less, libpipeline-devel, zlib-devel BuildRequires: gdbm-devel, gettext, groff, less, libpipeline-devel, zlib-devel
BuildRequires: po4a BuildRequires: po4a, systemd
%description %description
The man-db package includes five tools for browsing man-pages: The man-db package includes five tools for browsing man-pages:
@ -52,9 +52,7 @@ make install DESTDIR=$RPM_BUILD_ROOT prefix=%{_prefix} INSTALL='install -p'
# move the documentation to the relevant place # move the documentation to the relevant place
mv $RPM_BUILD_ROOT%{_datadir}/doc/man-db/* ./ mv $RPM_BUILD_ROOT%{_datadir}/doc/man-db/* ./
# remove zsoelim - part of groff package # remove zsoelim man page - part of groff package
#rm $RPM_BUILD_ROOT%{_bindir}/zsoelim
rm $RPM_BUILD_ROOT%{_libexecdir}/%{name}/zsoelim
rm $RPM_BUILD_ROOT%{_datadir}/man/man1/zsoelim.1 rm $RPM_BUILD_ROOT%{_datadir}/man/man1/zsoelim.1
# remove libtool archives # remove libtool archives
@ -63,11 +61,10 @@ rm $RPM_BUILD_ROOT%{_libdir}/man-db/*.la
# install cache directory # install cache directory
install -d -m 0755 $RPM_BUILD_ROOT%{cache} install -d -m 0755 $RPM_BUILD_ROOT%{cache}
# install cron script for man-db creation/update # install systemd service and timer files for man-db creation/update
install -D -p -m 0755 %{SOURCE1} $RPM_BUILD_ROOT/etc/cron.daily/man-db.cron mkdir -p %{buildroot}%{_unitdir}
install -D -p -m 0755 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/%{name}.service
# config for cron script install -D -p -m 0755 %{SOURCE2} $RPM_BUILD_ROOT%{_unitdir}/%{name}.timer
install -D -p -m 0644 %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/man-db
# config for tmpfiles.d # config for tmpfiles.d
install -D -p -m 0644 init/systemd/man-db.conf $RPM_BUILD_ROOT/usr/lib/tmpfiles.d/. install -D -p -m 0644 init/systemd/man-db.conf $RPM_BUILD_ROOT/usr/lib/tmpfiles.d/.
@ -78,14 +75,22 @@ install -D -p -m 0644 init/systemd/man-db.conf $RPM_BUILD_ROOT/usr/lib/tmpfiles.
# clear the old cache # clear the old cache
%post %post
%{__rm} -rf %{cache}/* %{__rm} -rf %{cache}/*
# enable and start timer
systemctl -q enable man-db.timer
systemctl start man-db.timer
%preun
# stop and disable timer
systemctl stop man-db.timer
systemctl -q disable man-db.timer
%files -f %{name}.lang -f %{name}-gnulib.lang %files -f %{name}.lang -f %{name}-gnulib.lang
%{!?_licensedir:%global license %%doc} %{!?_licensedir:%global license %%doc}
%license docs/COPYING %license docs/COPYING
%doc README man-db-manual.txt man-db-manual.ps ChangeLog NEWS %doc README man-db-manual.txt man-db-manual.ps ChangeLog NEWS
%config(noreplace) %{_sysconfdir}/man_db.conf %config(noreplace) %{_sysconfdir}/man_db.conf
%config(noreplace) %{_sysconfdir}/sysconfig/man-db %{_unitdir}/man-db.service
%config(noreplace) %{_sysconfdir}/cron.daily/man-db.cron %{_unitdir}/man-db.timer
%config(noreplace) /usr/lib/tmpfiles.d/man-db.conf %config(noreplace) /usr/lib/tmpfiles.d/man-db.conf
%{_sbindir}/accessdb %{_sbindir}/accessdb
%{_bindir}/man %{_bindir}/man
@ -100,6 +105,7 @@ install -D -p -m 0644 init/systemd/man-db.conf $RPM_BUILD_ROOT/usr/lib/tmpfiles.
%dir %{_libexecdir}/man-db %dir %{_libexecdir}/man-db
%{_libexecdir}/man-db/globbing %{_libexecdir}/man-db/globbing
%{_libexecdir}/man-db/manconv %{_libexecdir}/man-db/manconv
%{_libexecdir}/man-db/zsoelim
%attr(0755,root,root) %dir %{cache} %attr(0755,root,root) %dir %{cache}
# documentation and translation # documentation and translation
%{_mandir}/man1/apropos.1* %{_mandir}/man1/apropos.1*
@ -125,6 +131,12 @@ install -D -p -m 0644 init/systemd/man-db.conf $RPM_BUILD_ROOT/usr/lib/tmpfiles.
%lang(zh_CN) %{_datadir}/man/zh_CN/man*/* %lang(zh_CN) %{_datadir}/man/zh_CN/man*/*
%changelog %changelog
* Wed Oct 08 2014 jchaloup <jchaloup@redhat.com> - 2.7.0.2-2
- replacing cron with systemd.timer
resolves: #1148559
- adding zsoelim to {_libexecdir}/man-db/zsoelim
related: #1145493
* Wed Oct 08 2014 jchaloup <jchaloup@redhat.com> - 2.7.0.2-1 * Wed Oct 08 2014 jchaloup <jchaloup@redhat.com> - 2.7.0.2-1
- Update to 2.7.0.2 - Update to 2.7.0.2
resolves: #1145493 resolves: #1145493

View File

@ -1,6 +0,0 @@
# Set to no to disable daily man-db update by /etc/cron.daily/man-db.cron
CRON="yes"
# Options used by mandb in /etc/cron.daily/man-db.cron,
# we use -q as default, too much noise without.
OPTS="-q"

10
man-db.timer Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=Daily man-db cache update
[Timer]
OnCalendar=daily
AccuracySec=12h
Persistent=true
[Install]
WantedBy=multi-user.target