sys-devel/bmake installs catpage in place of a manpage, which makes sys-apps/man-db add newlines to it.
Either ebuild or man could be patched.
>From fffd911719c854b5411f9d6348da7757b364fad6 Mon Sep 17 00:00:00 2001 From: Mihail Konev <k....@ya.ru> Date: Mon, 31 Oct 2016 05:43:56 +0500 Subject: [PATCH] sys-devel/bmake: fix manpage source Previously, a catpage was installed in place of a manpage, which was leading to sys-apps/man-db displaying them with additional newlines. Install a manpage instead. Do not bother installing catpage, as they are for perfomance only. --- sys-devel/bmake/bmake-20160315.ebuild | 2 +- sys-devel/bmake/bmake-20160606.ebuild | 2 +- sys-devel/bmake/bmake-20160818.ebuild | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys-devel/bmake/bmake-20160315.ebuild b/sys-devel/bmake/bmake-20160315.ebuild index 69d93cf20964..bfc247267f22 100644 --- a/sys-devel/bmake/bmake-20160315.ebuild +++ b/sys-devel/bmake/bmake-20160315.ebuild @@ -48,7 +48,7 @@ src_test() { src_install() { dobin ${PN} - newman ${PN}.cat1 ${PN}.1 + doman ${PN}.1 FORCE_BSD_MK=1 SYS_MK_DIR=. \ sh ../mk/install-mk -v -m 644 "${ED}"/usr/share/mk/${PN} \ || die "failed to install mk files" diff --git a/sys-devel/bmake/bmake-20160606.ebuild b/sys-devel/bmake/bmake-20160606.ebuild index cce8dfffd9a7..0decbb3da166 100644 --- a/sys-devel/bmake/bmake-20160606.ebuild +++ b/sys-devel/bmake/bmake-20160606.ebuild @@ -48,7 +48,7 @@ src_test() { src_install() { dobin ${PN} - newman ${PN}.cat1 ${PN}.1 + doman ${PN}.1 FORCE_BSD_MK=1 SYS_MK_DIR=. \ sh ../mk/install-mk -v -m 644 "${ED}"/usr/share/mk/${PN} \ || die "failed to install mk files" diff --git a/sys-devel/bmake/bmake-20160818.ebuild b/sys-devel/bmake/bmake-20160818.ebuild index cce8dfffd9a7..0decbb3da166 100644 --- a/sys-devel/bmake/bmake-20160818.ebuild +++ b/sys-devel/bmake/bmake-20160818.ebuild @@ -48,7 +48,7 @@ src_test() { src_install() { dobin ${PN} - newman ${PN}.cat1 ${PN}.1 + doman ${PN}.1 FORCE_BSD_MK=1 SYS_MK_DIR=. \ sh ../mk/install-mk -v -m 644 "${ED}"/usr/share/mk/${PN} \ || die "failed to install mk files" -- 2.9.2
>From 9050cb9f5335eb28a99a6d38ba32d1eccf200608 Mon Sep 17 00:00:00 2001 From: Mihail Konev <k....@ya.ru> Date: Sat, 29 Oct 2016 08:26:15 +0500 Subject: [PATCH] man(1): Do not roff pages w/o macros This fixes display of manpages that really are catpages. --- configure.ac | 1 + man/replace.sin.in | 1 + src/Makefile.am | 2 ++ src/man.c | 22 +++++++++++++++++++-- src/roff_maybe | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+), 2 deletions(-) create mode 100755 src/roff_maybe diff --git a/configure.ac b/configure.ac index c8339f378a4a..1e30c4777be7 100644 --- a/configure.ac +++ b/configure.ac @@ -440,6 +440,7 @@ MAN_TRANS_SUBST([man]) MAN_TRANS_SUBST([manconv]) MAN_TRANS_SUBST([mandb]) MAN_TRANS_SUBST([manpath]) +MAN_TRANS_SUBST([roff_maybe]) MAN_TRANS_SUBST([whatis]) MAN_TRANS_SUBST([zsoelim]) diff --git a/man/replace.sin.in b/man/replace.sin.in index 72a7e09835f9..5da9f275bd29 100644 --- a/man/replace.sin.in +++ b/man/replace.sin.in @@ -11,6 +11,7 @@ s,%catman%,@TRANS_CATMAN@,g s,%apropos%,@TRANS_APROPOS@,g s,%whatis%,@TRANS_WHATIS@,g s,%manconv%,@TRANS_MANCONV@,g +s,%roff_maybe%,@TRANS_ROFF_MAYBE@,g s,%thzsoelim%,@TRANS_ZSOELIM_UPPER@,g s,%thman%,@TRANS_MAN_UPPER@,g s,%thmandb%,@TRANS_MANDB_UPPER@,g diff --git a/src/Makefile.am b/src/Makefile.am index d485ef42a72f..86072f377aeb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,6 +33,7 @@ bin_PROGRAMS = \ whatis sbin_PROGRAMS = accessdb pkglibexec_PROGRAMS = globbing manconv zsoelim +pkglibexec_SCRIPTS = roff_maybe noinst_DATA = man_db.conf EXTRA_DIST = lexgrog.c zsoelim.c @@ -49,6 +50,7 @@ AM_CPPFLAGS = \ -DMAN=\"$(bindir)/$(TRANS_MAN)\" \ -DMANCONV=\"$(pkglibexecdir)/$(TRANS_MANCONV)\" \ -DMANDB=\"$(bindir)/$(TRANS_MANDB)\" \ + -DROFF_MAYBE=\"$(pkglibexecdir)/$(TRANS_ROFF_MAYBE)\" \ -DWHATIS=\"$(bindir)/$(TRANS_WHATIS)\" \ -DZSOELIM=\"$(pkglibexecdir)/$(TRANS_ZSOELIM)\" AM_CFLAGS = \ diff --git a/src/man.c b/src/man.c index ebb97dab4bad..8e3458f86a29 100644 --- a/src/man.c +++ b/src/man.c @@ -1065,6 +1065,24 @@ static void add_col (pipeline *p, const char *locale_charset, ...) pipeline_command (p, cmd); } +/* Return pipecmd invoking the command through roff_maybe. */ +static pipecmd *roff_maybe_argstr (const char *command) +{ + const char command_prefix[] = ROFF_MAYBE " "; + char *full_command; + pipecmd *ret; + + full_command = malloc(strlen(command_prefix) + + strlen(command) + 1); + sprintf(full_command, "%s%s", + command_prefix, command); + + ret = pipecmd_new_argstr(full_command); + + free(full_command); + return ret; +} + /* Return pipeline to format file to stdout. */ static pipeline *make_roff_command (const char *dir, const char *file, pipeline *decomp, const char *dbfilters, @@ -1297,11 +1315,11 @@ static pipeline *make_roff_command (const char *dir, const char *file, case 0: /* done with preprocessors, now add roff */ if (troff) { - cmd = pipecmd_new_argstr + cmd = roff_maybe_argstr (get_def ("troff", TROFF)); save_cat = 0; } else - cmd = pipecmd_new_argstr + cmd = roff_maybe_argstr (get_def ("nroff", NROFF)); #ifdef TROFF_IS_GROFF diff --git a/src/roff_maybe b/src/roff_maybe new file mode 100755 index 000000000000..b40bfcab77dc --- /dev/null +++ b/src/roff_maybe @@ -0,0 +1,57 @@ +#!/bin/sh + +# roff_maybe: Workaround for catpages-installed-as-manpages +# +# Copyright (C) 2016 Mihail Konev. +# +# This file is part of man-db. +# +# man-db is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# man-db is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with man-db; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +# Run nroff (or whatever is passed as "$@"), +# but only if stdin has troff macros. +# If it is not, remove troff macros prepended by GNU tbl. +# +# This is to fix any possible alterations roff +# could introduce, such as inserting additional +# newlines. +# +# Caveat: stdout would always be terminated with +# a single newline, no matter how many (if any) +# were on stdin. + +input=$(cat) + +no_tbl_input=$( + echo "$input" | awk ' + BEGIN { after_tbl = 0; } + ! /^[.][il]f / { after_tbl = 1; } + + { + if (after_tbl) + print; + } + ' +) + +match=$(echo "$no_tbl_input" | grep -i '^[.][a-z]') + +if test ! -z "$match" ; then + echo "$input" | "$@" +else + echo "$no_tbl_input" +fi + -- 2.9.2