From 2eef02f327e5dc313432d7ca8fa5afddaf2bac30 Mon Sep 17 00:00:00 2001 From: Jan Chaloupka Date: Fri, 2 Jan 2015 10:24:39 +0100 Subject: [PATCH] switching back to crontabs - resolves: #1177993 - resolves: #1171450 --- man-db.crondaily | 27 +++++++++++++++++++++++++++ man-db.service | 10 ---------- man-db.spec | 36 ++++++++++++++++++++---------------- man-db.sysconfig | 6 ++++++ man-db.timer | 10 ---------- 5 files changed, 53 insertions(+), 36 deletions(-) create mode 100644 man-db.crondaily delete mode 100644 man-db.service create mode 100644 man-db.sysconfig delete mode 100644 man-db.timer diff --git a/man-db.crondaily b/man-db.crondaily new file mode 100644 index 0000000..6e95c16 --- /dev/null +++ b/man-db.crondaily @@ -0,0 +1,27 @@ +#!/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 diff --git a/man-db.service b/man-db.service deleted file mode 100644 index 4adc297..0000000 --- a/man-db.service +++ /dev/null @@ -1,10 +0,0 @@ -[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 diff --git a/man-db.spec b/man-db.spec index e34e952..6800ce4 100644 --- a/man-db.spec +++ b/man-db.spec @@ -4,7 +4,7 @@ Summary: Tools for searching and reading man pages Name: man-db Version: 2.7.1 -Release: 2%{?dist} +Release: 3%{?dist} # GPLv2+ .. man-db # GPLv3+ .. gnulib License: GPLv2+ and GPLv3+ @@ -12,8 +12,8 @@ Group: System Environment/Base URL: http://www.nongnu.org/man-db/ Source0: http://download.savannah.gnu.org/releases/%{name}/%{name}-%{version}.tar.xz -Source1: man-db.service -Source2: man-db.timer +Source1: man-db.crondaily +Source2: man-db.sysconfig Patch0: 1151558-switch-man-and-root-in-init-systemd-man-db.conf.patch Patch1: 1161747-src-man.c-do_extern-Pass-the-l-option-through.patch @@ -23,9 +23,9 @@ Provides: man-pages-reader = %{version} # FPC exception for gnulib - copylib - https://fedorahosted.org/fpc/ticket/174 Provides: bundled(gnulib) = %{gnulib_ver} -Requires: coreutils, grep, groff-base, gzip, less, systemd +Requires: coreutils, grep, groff-base, gzip, less, crontabs BuildRequires: gdbm-devel, gettext, groff, less, libpipeline-devel, zlib-devel -BuildRequires: po4a, systemd +BuildRequires: po4a %description The man-db package includes five tools for browsing man-pages: @@ -63,10 +63,11 @@ rm $RPM_BUILD_ROOT%{_libdir}/man-db/*.la # install cache directory install -d -m 0755 $RPM_BUILD_ROOT%{cache} -# install systemd service and timer files for man-db creation/update -mkdir -p %{buildroot}%{_unitdir} -install -D -p -m 0644 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/%{name}.service -install -D -p -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_unitdir}/%{name}.timer +# install cron script for man-db creation/update +install -D -p -m 0755 %{SOURCE1} $RPM_BUILD_ROOT/etc/cron.daily/man-db.cron + +# config for cron script +install -D -p -m 0644 %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/man-db # config for tmpfiles.d install -D -p -m 0644 init/systemd/man-db.conf $RPM_BUILD_ROOT/usr/lib/tmpfiles.d/. @@ -77,13 +78,11 @@ install -D -p -m 0644 init/systemd/man-db.conf $RPM_BUILD_ROOT/usr/lib/tmpfiles. # clear the old cache %post %{__rm} -rf %{cache}/* -# enable and start timer -systemctl -q enable man-db.timer -systemctl start man-db.timer %preun -# stop and disable timer -if [ "$1" -eq 0 ]; then +# stop and disable timer from previous builds +rpm -q systemd > /dev/null +if [ "$?" -eq 0 ]; then systemctl stop man-db.timer systemctl -q disable man-db.timer fi @@ -93,8 +92,8 @@ fi %license docs/COPYING %doc README man-db-manual.txt man-db-manual.ps ChangeLog NEWS %config(noreplace) %{_sysconfdir}/man_db.conf -%{_unitdir}/man-db.service -%{_unitdir}/man-db.timer +%config(noreplace) %{_sysconfdir}/sysconfig/man-db +%config(noreplace) %{_sysconfdir}/cron.daily/man-db.cron %config(noreplace) /usr/lib/tmpfiles.d/man-db.conf %{_sbindir}/accessdb %{_bindir}/man @@ -135,6 +134,11 @@ fi %lang(zh_CN) %{_datadir}/man/zh_CN/man*/* %changelog +* Fri Jan 02 2015 jchaloup - 2.7.1-3 +- switching back to crontabs + resolves: #1177993 + resolves: #1171450 + * Thu Nov 13 2014 jchaloup - 2.7.1-2 - src/man.c (do_extern): Pass the -l option through resolves: #1161747 diff --git a/man-db.sysconfig b/man-db.sysconfig new file mode 100644 index 0000000..608446d --- /dev/null +++ b/man-db.sysconfig @@ -0,0 +1,6 @@ +# 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" diff --git a/man-db.timer b/man-db.timer deleted file mode 100644 index ce43df1..0000000 --- a/man-db.timer +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Daily man-db cache update - -[Timer] -OnCalendar=daily -AccuracySec=12h -Persistent=true - -[Install] -WantedBy=multi-user.target