Subject: bug#30785: Man pages truncated, repeated

From: Marius Bakke <[email-masked]>
Date: Sat, 05 May 2018 23:40:51 +0200

Marius Bakke <[email-masked]> writes:

> Tobias Geerinckx-Rice <[email-masked]> writes:
>
>> Guix,
>>
>> Perhaps he's just getting old, but our man has a tendency to forget 
>> where he was, start over from the beginning, and repeat himself several 
>> times:
>>
>>    $ guix package -i knot rofi
>>    $ man 5 knot.conf | grep -E '^(NAME|DESCRIPTION)'
>>    NAME
>>    DESCRIPTION
>>    NAME
>>    DESCRIPTION
>>    NAME
>>    DESCRIPTION
>>    NAME
>>    DESCRIPTION
>>    NAME
>>    $
>
> One thing rofi.1 and knot.conf.5 have in common is that they are both
> unicode.  Whereas working pages are ASCII.

This ultimately turned out to be due to man-db not finding "preconv".

The attached patches fixes it.

Adding preconv adds ~0.1 MiB to the groff-minimal closure size.

WDYT?

From 42b43fca11ab1f9417499aea252ae7a871a53b1b Mon Sep 17 00:00:00 2001
From: Marius Bakke <[email-masked]>
Date: Sat, 5 May 2018 23:13:16 +0200
Subject: [PATCH 1/2] gnu: groff-minimal: Preserve 'preconv' executable.

* gnu/packages/groff.scm (groff-minimal)[arguments]: Add 'preconv' to the list
of kept programs.
---
 gnu/packages/groff.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnu/packages/groff.scm b/gnu/packages/groff.scm
index 5f1b8d0ed..77728a5d7 100644
--- a/gnu/packages/groff.scm
+++ b/gnu/packages/groff.scm
@@ -101,7 +101,7 @@ is usually the formatter of \"man\" documentation pages.")
                    ;; Keep only the programs that man-db needs at run time,
                    ;; and make sure we don't pull in Perl.
                    (let ((out  (assoc-ref outputs "out"))
-                         (kept '("eqn" "neqn" "pic" "tbl" "refer"
+                         (kept '("eqn" "neqn" "pic" "tbl" "refer" "preconv"
                                  "nroff" "groff" "troff" "grotty")))
                      (for-each (lambda (file)
                                  (unless (member (basename file) kept)
-- 
2.17.0

From 095d0db7db77261f59e6582af3a9b18b61dcb630 Mon Sep 17 00:00:00 2001
From: Marius Bakke <[email-masked]>
Date: Sat, 5 May 2018 23:30:04 +0200
Subject: [PATCH 2/2] gnu: man-db: Embed absolute reference to 'preconv'.

Fixes <https://bugs.gnu.org/30785>.
Reported by Tobias Geerinckx-Rice <[email-masked]>.

* gnu/packages/man.scm (man-db)[arguments]: Rename 'patch-iconv-path' to
'patch-absolute-paths'.  Add substitution for "preconv".
---
 gnu/packages/man.scm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/man.scm b/gnu/packages/man.scm
index ca6fd351d..f0bb2b66e 100644
--- a/gnu/packages/man.scm
+++ b/gnu/packages/man.scm
@@ -80,11 +80,19 @@ a flexible and convenient way.")
                               (string-append "#!" (which "sh")))))
                          (remove file-is-directory?
                                  (find-files "src/tests" ".*"))))))
-         (add-after 'unpack 'patch-iconv-path
+         (add-after 'unpack 'patch-absolute-paths
            (lambda* (#:key inputs #:allow-other-keys)
              (substitute* "src/man.c"
                (("\"iconv\"")
                 (string-append "\"" (which "iconv") "\"")))
+             ;; Embed an absolute reference to "preconv", otherwise it
+             ;; falls back to searching in PATH and ultimately fails
+             ;; to render unicode data (see <https://bugs.gnu.org/30785>).
+             (substitute* "lib/encodings.c"
+               (("groff_preconv = NULL")
+                (string-append "groff_preconv = \""
+                               (assoc-ref inputs "groff-minimal")
+                               "/bin/preconv\"")))
              #t)))
        #:configure-flags
        (let ((groff (assoc-ref %build-inputs "groff"))
-- 
2.17.0