diff --git a/man-db-2.10.0-fix-override-dir-handling.patch b/man-db-2.10.0-fix-override-dir-handling.patch new file mode 100644 index 0000000000000000000000000000000000000000..aee2f9c567f62e692bd6de9b3c666b04c363bfbe --- /dev/null +++ b/man-db-2.10.0-fix-override-dir-handling.patch @@ -0,0 +1,202 @@ +From b8483c4db97f6f879fe5e532a2ec66e9363033c9 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Nikola=20Forr=C3=B3?= +Date: Tue, 27 Aug 2019 17:53:03 +0200 +Subject: [PATCH] man(1): Fix override dir handling +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Previously, override dir was affecting only some cases +of manpath determination. + +Apply it only when all paths has been gathered instead. +(Depending on the definition of when the override dir applies, +this might not be correct). + +Also look for override dir when sorting candidates. + +Fixes src/tests/man-9 failing when --with-override-dir=od +is passed to ./configure. + +Reported-by: Nikola Forró +Tested-by: Nikola Forró +--- + src/man.c | 33 +++++++++++++++++++++++++++++++++ + src/manp.c | 52 ++++++++++++++++++++-------------------------------- + 2 files changed, 53 insertions(+), 32 deletions(-) + +diff --git a/src/man.c b/src/man.c +index f16fae8..29c8671 100644 +--- a/src/man.c ++++ b/src/man.c +@@ -2728,6 +2728,32 @@ static bool duplicate_candidates (struct candidate *left, + return ret; + } + ++static int cand1_differs_by_override_dir (const struct candidate *left, ++ const struct candidate *right) ++{ ++ size_t ov_len, pre_ov_len; ++ ++ ov_len = strlen (OVERRIDE_DIR); ++ if (!ov_len) ++ return 0; ++ ++ if (!STREQ (left->source->name, right->source->name)) ++ return 0; ++ ++ pre_ov_len = strlen(right->path); ++ if (!STRNEQ (left->path, right->path, pre_ov_len)) ++ return 0; ++ ++ if (left->path[pre_ov_len] != '/') ++ return 0; ++ pre_ov_len++; ++ ++ if (STREQ (left->path + pre_ov_len, OVERRIDE_DIR)) ++ return 1; ++ ++ return 0; ++} ++ + static int compare_candidates (const struct candidate *left, + const struct candidate *right) + { +@@ -2817,6 +2843,13 @@ static int compare_candidates (const struct candidate *left, + if (cmp) + return cmp; + ++ /* Sort override dir first ++ */ ++ if (cand1_differs_by_override_dir(left, right)) ++ return -1; ++ if (cand1_differs_by_override_dir(right, left)) ++ return 1; ++ + /* Try comparing based on language. We used to prefer to display a + * page in the user's preferred language than a page from a better + * section, but that attracted objections, so now we prefer to get +diff --git a/src/manp.c b/src/manp.c +index 80b309a..4e3bff0 100644 +--- a/src/manp.c ++++ b/src/manp.c +@@ -911,23 +911,6 @@ static char *def_path (enum config_flag flag) + return manpath; + } + +-/* +- * If specified with configure, append OVERRIDE_DIR to dir param and add it +- * to list. +- */ +-static void insert_override_dir (gl_list_t list, const char *dir) +-{ +- char *override_dir = NULL; +- +- if (!strlen (OVERRIDE_DIR)) +- return; +- +- if ((override_dir = xasprintf ("%s/%s", dir, OVERRIDE_DIR))) { +- add_dir_to_list (list, override_dir); +- free (override_dir); +- } +-} +- + /* + * For each directory in the user's path, see if it is one of the + * directories listed in the man_db.config file. If so, and it is +@@ -976,7 +959,6 @@ char *get_manpath_from_path (const char *path, int mandatory) + if (!manpath_map_found) + debug ("is in the config file\n"); + manpath_map_found = true; +- insert_override_dir (tmplist, config_item->cont); + add_dir_to_list (tmplist, config_item->cont); + } + +@@ -998,8 +980,6 @@ char *get_manpath_from_path (const char *path, int mandatory) + + GL_LIST_FOREACH (config, config_item) { + if (config_item->flag == MANDATORY) { +- insert_override_dir (tmplist, +- config_item->key); + add_dir_to_list (tmplist, config_item->key); + } + } +@@ -1084,7 +1064,6 @@ static void add_man_subdirs (gl_list_t list, const char *path) + if (subdir) { + newpath = xasprintf ("%.*s/man", (int) (subdir - path), path); + if (is_directory (newpath) == 1) { +- insert_override_dir (list, newpath); + add_dir_to_list (list, newpath); + } + free (newpath); +@@ -1092,7 +1071,6 @@ static void add_man_subdirs (gl_list_t list, const char *path) + + newpath = xasprintf ("%s/man", path); + if (is_directory (newpath) == 1) { +- insert_override_dir (list, newpath); + add_dir_to_list (list, newpath); + } + free (newpath); +@@ -1101,7 +1079,6 @@ static void add_man_subdirs (gl_list_t list, const char *path) + newpath = xasprintf ("%.*s/share/man", + (int) (subdir - path), path); + if (is_directory (newpath) == 1) { +- insert_override_dir (list, newpath); + add_dir_to_list (list, newpath); + } + free (newpath); +@@ -1109,7 +1086,6 @@ static void add_man_subdirs (gl_list_t list, const char *path) + + newpath = xasprintf ("%s/share/man", path); + if (is_directory (newpath) == 1) { +- insert_override_dir (list, newpath); + add_dir_to_list (list, newpath); + } + free (newpath); +@@ -1205,7 +1181,9 @@ gl_list_t create_pathlist (const char *manp) + const struct canonicalized_path *cp; + + /* Expand the manpath into a list of (path, canonicalized path) +- * pairs for easier handling. add_dir_to_path_list only adds items ++ * pairs for easier handling. For each entry, add corresponding ++ * OVERRIDE_DIR. ++ * add_dir_to_path_list only adds items + * if they do not have the same canonicalized path as an existing + * item, thereby eliminating duplicates due to symlinks. + */ +@@ -1214,15 +1192,25 @@ gl_list_t create_pathlist (const char *manp) + (GL_LINKEDHASH_LIST, canonicalized_path_equals, + canonicalized_path_hash, canonicalized_path_free, false); + for (p = manp;; p = end + 1) { ++ char *element, *element_override; ++ ssize_t p_len; ++ + end = strchr (p, ':'); +- if (end) { +- char *element = xstrndup (p, end - p); +- add_dir_to_path_list (canonicalized_list, element); +- free (element); +- } else { +- add_dir_to_path_list (canonicalized_list, p); +- break; ++ p_len = end ? end - p : (ssize_t)strlen(p); ++ ++ element = xstrndup (p, p_len); ++ ++ if (strlen(OVERRIDE_DIR)) { ++ element_override = xasprintf("%s/%s", element, OVERRIDE_DIR); ++ add_dir_to_path_list (canonicalized_list, element_override); ++ free (element_override); + } ++ ++ add_dir_to_path_list (canonicalized_list, element); ++ free (element); ++ ++ if (!end) ++ break; + } + + list = new_string_list (GL_ARRAY_LIST, false); +-- +2.34.1 + diff --git a/man-db-2.10.1.tar.xz b/man-db-2.10.1.tar.xz new file mode 100644 index 0000000000000000000000000000000000000000..fc732b936a5906bd1636b6acc40ced7ce766cb85 Binary files /dev/null and b/man-db-2.10.1.tar.xz differ diff --git a/man-db-cache-update.service b/man-db-cache-update.service new file mode 100644 index 0000000000000000000000000000000000000000..fdf08d7dce4e9a9d6c401f8a7244adf183ce60d3 --- /dev/null +++ b/man-db-cache-update.service @@ -0,0 +1,11 @@ +[Unit] +After=local-fs.target + +[Service] +Type=oneshot +Environment=MAN_NO_LOCALE_WARNING=1 +EnvironmentFile=/etc/sysconfig/man-db +ExecStart=/bin/sh -c '[ "$SERVICE" != "no" ] && /usr/bin/mandb $OPTS || true' +ExecStopPost=/bin/sh -c '[ "$SERVICE_RESULT" == "signal" ] && /usr/bin/systemctl enable man-db-restart-cache-update.service || true' +Nice=19 +IOWeight=20 diff --git a/man-db-restart-cache-update.service b/man-db-restart-cache-update.service new file mode 100644 index 0000000000000000000000000000000000000000..1d0d6ef6a012b42153b726cca7700170d87653ad --- /dev/null +++ b/man-db-restart-cache-update.service @@ -0,0 +1,11 @@ +[Unit] +Before=multi-user.target + +[Service] +Type=oneshot +ExecStartPre=/usr/bin/rm -rf /var/cache/man/* +ExecStart=/usr/bin/systemd-run /usr/bin/systemctl start man-db-cache-update.service +ExecStartPost=/usr/bin/systemctl disable man-db-restart-cache-update.service + +[Install] +WantedBy=multi-user.target diff --git a/man-db.crondaily b/man-db.crondaily new file mode 100644 index 0000000000000000000000000000000000000000..6e95c1623a4737a659a8bda750644d6c8348e51c --- /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.spec b/man-db.spec new file mode 100644 index 0000000000000000000000000000000000000000..c2426de263933ae10063741013216b0f9753ef5b --- /dev/null +++ b/man-db.spec @@ -0,0 +1,235 @@ +%define anolis_release 1 +%global cache /var/cache/man +%global gnulib_ver 20140202 + +Summary: Tools for searching and reading man pages +Name: man-db +Version: 2.10.1 +Release: %{anolis_release}%{?dist} +# GPLv2+ .. man-db +# GPLv3+ .. gnulib +License: GPLv2+ and GPLv3+ +URL: http://www.nongnu.org/man-db/ + +Source0: http://download.savannah.gnu.org/releases/%{name}/%{name}-%{version}.tar.xz +Source1: man-db.crondaily +Source2: man-db.sysconfig +Source3: man-db-cache-update.service +Source4: man-db-restart-cache-update.service + +# fix testsuite fail for man-db 2.10.1 +# http://lists.nongnu.org/archive/html/man-db-devel/2017-01/msg00013.html +Patch0: man-db-2.10.0-fix-override-dir-handling.patch + +Obsoletes: man < 2.0 +Provides: man = %{version} +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 +BuildRequires: make +BuildRequires: gcc +BuildRequires: systemd +BuildRequires: gdbm-devel, gettext, groff, less, libpipeline-devel, zlib-devel +BuildRequires: po4a, perl-interpreter, perl-version + +Requires(post): %{_sbindir}/update-alternatives +Requires(postun): %{_sbindir}/update-alternatives +Requires(preun): %{_sbindir}/update-alternatives + +%description +The man-db package includes five tools for browsing man-pages: +man, whatis, apropos, manpath and lexgrog. man formats and displays +manual pages. whatis searches the manual page names. apropos searches the +manual page names and descriptions. manpath determines search path +for manual pages. lexgrog directly reads header information in +manual pages. + +%package cron +Summary: Periodic update of man-db cache + +Requires: %{name} = %{version}-%{release} +Requires: crontabs + +BuildArch: noarch + +%description cron +This package provides periodic update of man-db cache. + +%prep +%autosetup -p1 + +%build +%configure \ + --with-sections="1 1p 8 2 3 3p 3pm 4 5 6 7 9 0p n l p o 1x 2x 3x 4x 5x 6x 7x 8x" \ + --disable-setuid --disable-cache-owner \ + --with-systemdsystemunitdir=no \ + --with-browser=elinks --with-lzip=lzip \ + --with-override-dir=overrides +%make_build CC="%{__cc} %{optflags}" + +%check +make check + +%install +%make_install prefix=%{_prefix} + +# rename files for alternative usage +for f in man apropos whatis; do + mv %{buildroot}%{_bindir}/$f %{buildroot}%{_bindir}/$f.%{name} + touch %{buildroot}%{_bindir}/$f + mv %{buildroot}%{_mandir}/man1/$f.1 %{buildroot}%{_mandir}/man1/$f.%{name}.1 + touch %{buildroot}%{_mandir}/man1/$f.1 +done + +# move the documentation to the relevant place +mv $RPM_BUILD_ROOT%{_datadir}/doc/man-db/* ./ + +# remove zsoelim man page - part of groff package +rm $RPM_BUILD_ROOT%{_datadir}/man/man1/zsoelim.1 + +# remove libtool archives +rm $RPM_BUILD_ROOT%{_libdir}/man-db/*.la + +# install cache directory +install -d -m 0755 $RPM_BUILD_ROOT%{cache} + +# install cron script for man-db creation/update +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/cron.daily +install -D -p -m 0755 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/cron.daily/man-db.cron + +# config for cron script +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig +install -D -p -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/man-db + +# config for tmpfiles.d +install -D -p -m 0644 init/systemd/man-db.conf $RPM_BUILD_ROOT/usr/lib/tmpfiles.d/. + +# man-db-cache-update.service and man-db-restart-cache-update.service +install -D -p -m 0644 %{SOURCE3} $RPM_BUILD_ROOT%{_unitdir}/man-db-cache-update.service +install -D -p -m 0644 %{SOURCE4} $RPM_BUILD_ROOT%{_unitdir}/man-db-restart-cache-update.service + +%find_lang %{name} +%find_lang %{name}-gnulib + +%pre +# remove alternativized files if they are not symlinks +for f in man apropos whatis; do + [ -L %{_bindir}/$f ] || %{__rm} -f %{_bindir}/$f >/dev/null 2>&1 || : + [ -L %{_mandir}/man1/$f.1.gz ] || %{__rm} -f %{_mandir}/man1/$f.1.gz >/dev/null 2>&1 || : +done + +# stop and disable timer from previous builds +if [ -e /usr/lib/systemd/system/mandb.timer ]; then + if test -d /run/systemd; then + systemctl stop man-db.timer >/dev/null 2>&1 || : + systemctl -q disable man-db.timer >/dev/null 2>&1 || : + fi +fi + +%post +# set up the alternatives files +%{_sbindir}/update-alternatives --install %{_bindir}/man man %{_bindir}/man.%{name} 300 \ + --slave %{_bindir}/apropos apropos %{_bindir}/apropos.%{name} \ + --slave %{_bindir}/whatis whatis %{_bindir}/whatis.%{name} \ + --slave %{_mandir}/man1/man.1.gz man.1.gz %{_mandir}/man1/man.%{name}.1.gz \ + --slave %{_mandir}/man1/apropos.1.gz apropos.1.gz %{_mandir}/man1/apropos.%{name}.1.gz \ + --slave %{_mandir}/man1/whatis.1.gz whatis.1.gz %{_mandir}/man1/whatis.%{name}.1.gz \ + >/dev/null 2>&1 || : + +# clear the old cache +%{__rm} -rf %{cache}/* >/dev/null 2>&1 || : + +%preun +if [ $1 -eq 0 ]; then + %{_sbindir}/update-alternatives --remove man %{_bindir}/man.%{name} >/dev/null 2>&1 || : +fi + +%postun +if [ $1 -ge 1 ]; then + if [ "$(readlink %{_sysconfdir}/alternatives/man)" == "%{_bindir}/man.%{name}" ]; then + %{_sbindir}/update-alternatives --set man %{_bindir}/man.%{name} >/dev/null 2>&1 || : + fi +fi + +%transfiletriggerin -- %{_mandir} +# update cache +if [ -x /usr/bin/systemd-run -a -x /usr/bin/systemctl ]; then + /usr/bin/systemd-run /usr/bin/systemctl start man-db-cache-update >/dev/null 2>&1 || : +fi + +%transfiletriggerpostun -- %{_mandir} +# update cache +if [ -x /usr/bin/systemd-run -a -x /usr/bin/systemctl ]; then + /usr/bin/systemd-run /usr/bin/systemctl start man-db-cache-update >/dev/null 2>&1 || : +fi + +%files -f %{name}.lang -f %{name}-gnulib.lang +%{!?_licensedir:%global license %%doc} +%license COPYING +%doc README.md man-db-manual.txt man-db-manual.ps ChangeLog NEWS.md +%config(noreplace) %{_sysconfdir}/man_db.conf +%config(noreplace) %{_sysconfdir}/sysconfig/man-db +%config(noreplace) %{_tmpfilesdir}/man-db.conf +%{_unitdir}/man-db-cache-update.service +%{_unitdir}/man-db-restart-cache-update.service +%{_sbindir}/accessdb +%ghost %{_bindir}/man +%ghost %{_bindir}/apropos +%ghost %{_bindir}/whatis +%{_bindir}/man.%{name} +%{_bindir}/apropos.%{name} +%{_bindir}/whatis.%{name} +%{_bindir}/man-recode +%{_bindir}/manpath +%{_bindir}/lexgrog +%{_bindir}/catman +%{_bindir}/mandb +%dir %{_libdir}/man-db +%{_libdir}/man-db/*.so +%dir %{_libexecdir}/man-db +%{_libexecdir}/man-db/globbing +%{_libexecdir}/man-db/manconv +%{_libexecdir}/man-db/zsoelim +%verify(not mtime) %dir %{cache} +# documentation and translation +%ghost %{_mandir}/man1/man.1* +%ghost %{_mandir}/man1/apropos.1* +%ghost %{_mandir}/man1/whatis.1* +%{_mandir}/man1/man.%{name}.1* +%{_mandir}/man1/apropos.%{name}.1* +%{_mandir}/man1/whatis.%{name}.1* +%{_mandir}/man1/man-recode.1* +%{_mandir}/man1/lexgrog.1* +%{_mandir}/man1/manconv.1* +%{_mandir}/man1/manpath.1* +%{_mandir}/man5/manpath.5* +%{_mandir}/man8/accessdb.8* +%{_mandir}/man8/catman.8* +%{_mandir}/man8/mandb.8* +%lang(da) %{_datadir}/man/da/man*/* +%lang(de) %{_datadir}/man/de/man*/* +%lang(es) %{_datadir}/man/es/man*/* +%lang(fr) %{_datadir}/man/fr/man*/* +%lang(id) %{_datadir}/man/id/man*/* +%lang(it) %{_datadir}/man/it/man*/* +%lang(ja) %{_datadir}/man/ja/man*/* +%lang(nl) %{_datadir}/man/nl/man*/* +%lang(pl) %{_datadir}/man/pl/man*/* +%lang(pt) %{_datadir}/man/pt/man*/* +%lang(pt_BR) %{_datadir}/man/pt_BR/man*/* +%lang(ro) %{_datadir}/man/ro/man*/* +%lang(ru) %{_datadir}/man/ru/man*/* +%lang(sr) %{_datadir}/man/sr/man*/* +%lang(sv) %{_datadir}/man/sv/man*/* +%lang(tr) %{_datadir}/man/tr/man*/* +%lang(zh_CN) %{_datadir}/man/zh_CN/man*/* + +%files cron +%config(noreplace) %{_sysconfdir}/cron.daily/man-db.cron + +%changelog +* Fri Mar 04 2022 mgb01105731 - 2.10.1-1 +- Init from upstream version 2.10.1 + diff --git a/man-db.sysconfig b/man-db.sysconfig new file mode 100644 index 0000000000000000000000000000000000000000..e7449df5e72d9fd71ce5bbd2f3e984ea60420fd7 --- /dev/null +++ b/man-db.sysconfig @@ -0,0 +1,10 @@ +# Set this to "no" to disable man-db update triggered by installation +# of any package containing manual pages +SERVICE="yes" + +# Set this to "no" to disable daily man-db update run by +# /etc/cron.daily/man-db.cron +CRON="yes" + +# Options used by mandb, we use "-q" as default, too much noise without it +OPTS="-q"