1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
5 ;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
6 ;;; Copyright © 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2019 Eric Bavier <bavier@member.fsf.org>
8 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
9 ;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
10 ;;; Copyright © 2020 Prafulla Giri <pratheblackdiamond@gmail.com>
12 ;;; This file is part of GNU Guix.
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27 (define-module (gnu packages groff)
28 #:use-module (guix licenses)
29 #:use-module (guix packages)
30 #:use-module (guix utils)
31 #:use-module (guix download)
32 #:use-module (guix git-download)
33 #:use-module (guix build-system gnu)
34 #:use-module (guix build-system ruby)
35 #:use-module (gnu packages)
36 #:use-module (gnu packages ruby)
37 #:use-module (gnu packages bison)
38 #:use-module (gnu packages ghostscript)
39 #:use-module (gnu packages netpbm)
40 #:use-module (gnu packages perl)
41 #:use-module (gnu packages texinfo)
42 #:use-module (gnu packages web))
50 (uri (string-append "mirror://gnu/groff/groff-" version
53 "14q2mldnr1vx0l9lqp9v2f6iww24gj28iyh4j2211hyynx67p3p7"))))
54 (build-system gnu-build-system)
56 "doc")) ;12MiB of PS, PDF, HTML, and examples
58 ;; Note: groff's HTML backend uses executables from netpbm when they are in
59 ;; $PATH. In practice, not having them doesn't prevent it from install its
60 ;; own HTML doc, nor does it change its capabilities, so we removed netpbm
63 (inputs `(("ghostscript" ,ghostscript)))
65 ;; When cross-compiling, this package depends upon a native install of
67 (native-inputs `(,@(if (%current-target-system)
68 `(("self" ,this-package))
73 ("texinfo" ,texinfo)))
75 `(#:parallel-build? #f ; parallel build fails
76 ,@(if (%current-target-system)
78 ;; In groff-minimal package, that inherits from this package,
79 ;; we'll need to locate "groff" instead of "self".
80 (let ((groff (or (assoc-ref %build-host-inputs "groff")
81 (assoc-ref %build-host-inputs "self"))))
83 (string-append "GROFF_BIN_PATH=" groff)
84 (string-append "GROFFBIN=" groff "/bin/groff"))))
87 (modify-phases %standard-phases
88 (add-after 'unpack 'disable-relocatability
90 ;; Groff contains a Rube Goldberg-esque relocator for the file
91 ;; "charset.alias". It tries to find the current executable
92 ;; using realpath, a do-it-yourself search in $PATH and so on.
93 ;; Furthermore, the routine that does the search is buggy
94 ;; in that it doesn't handle error cases when they arise.
95 ;; This causes preconv to segfault when trying to look up
96 ;; the file "charset.alias" in the NULL location.
97 ;; The "charset.alias" parser is a copy of gnulib's, and a
98 ;; non-broken version of gnulib's "charset.alias" parser is
99 ;; part of glibc's libcharset.
100 ;; However, groff unconditionally uses their own
101 ;; "charset.alias" parser, but then DOES NOT INSTALL the
102 ;; file "charset.alias" when glibc is too new.
103 ;; In Guix, our file "charset.alias" only contains an obscure
104 ;; alias for ASCII and nothing else. So just disable relocation
105 ;; and make the entire "charset.alias" lookup fail.
106 ;; See <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30785> for
108 (substitute* "Makefile.in"
109 (("-DENABLE_RELOCATABLE=1") ""))
111 (add-after 'unpack 'setenv
113 (setenv "GS_GENERATE_UUIDS" "0")
115 (add-after 'unpack 'fix-docdir
116 (lambda _ ;see https://savannah.gnu.org/bugs/index.php?55461
117 (substitute* "Makefile.in"
118 (("^docdir =.*") "docdir = @docdir@\n"))
120 (synopsis "Typesetting from plain text mixed with formatting commands")
122 "Groff is a typesetting package that reads plain text and produces
123 formatted output based on formatting commands contained within the text. It
124 is usually the formatter of \"man\" documentation pages.")
126 (home-page "https://www.gnu.org/software/groff/")))
128 (define-public groff-minimal
129 ;; Minimialist groff for use by man-db. Its closure size is less than half
130 ;; that of the full-blown groff.
133 (name "groff-minimal")
134 (synopsis "Minimalist variant of Groff for use by man-db")
137 ;; Omit the DVI, PS, PDF, and HTML backends.
139 (native-inputs `(("bison" ,bison)
144 `(#:disallowed-references (,perl)
146 #:configure-flags '("--with-doc=no")
148 ,@(substitute-keyword-arguments (package-arguments groff)
150 `(modify-phases ,phases
151 (add-after 'install 'remove-non-essential-programs
152 (lambda* (#:key outputs #:allow-other-keys)
153 ;; Keep only the programs that man-db needs at run time,
154 ;; and make sure we don't pull in Perl.
155 (let ((out (assoc-ref outputs "out"))
156 (kept '("eqn" "neqn" "pic" "tbl" "refer" "preconv"
157 "nroff" "groff" "troff" "grotty")))
158 (for-each (lambda (file)
159 (unless (member (basename file) kept)
161 (find-files (string-append out "/bin")))
163 ;; Remove a bunch of unneeded Perl scripts.
164 (for-each delete-file (find-files out "\\.pl$"))
165 (for-each delete-file
166 (find-files out "BuildFoundries"))
168 ;; Remove ~3 MiB from share/groff/X.Y/font/devBACKEND
169 ;; corresponding to the unused backends.
170 (for-each delete-file-recursively
171 (find-files out "^dev(dvi|ps|pdf|html|lj4)$"
175 ;; There are no releases, so we take the latest commit.
176 (define-public roffit
177 (let ((commit "b59e6c855ebea03daf76e996b5c0f8343f11be3d")
181 (version (string-append "0.12-" revision "." (string-take commit 9)))
185 (url "https://github.com/bagder/roffit")
187 (file-name (string-append "roffit-" commit "-checkout"))
190 "0z4cs92yqh22sykfgbjlyxfaifdvsd47cf1yhr0f2rgcc6l0fj1r"))))
191 (build-system gnu-build-system)
193 `(#:test-target "test"
195 (list (string-append "INSTALLDIR="
196 (assoc-ref %outputs "out") "/bin"))
198 (modify-phases %standard-phases
200 (add-before 'install 'pre-install
201 (lambda* (#:key outputs #:allow-other-keys)
202 (mkdir-p (string-append (assoc-ref outputs "out")
205 (add-after 'install 'wrap-program
206 (lambda* (#:key outputs #:allow-other-keys)
207 (let ((out (assoc-ref outputs "out")))
208 (wrap-program (string-append out "/bin/roffit")
209 `("PERL5LIB" ":" prefix (,(getenv "PERL5LIB"))))
211 (native-inputs `(("html-tree" ,perl-html-tree))) ; for test
214 (home-page "https://daniel.haxx.se/projects/roffit/")
215 (synopsis "Convert nroff files to HTML")
217 "Roffit is a program that reads an nroff file and outputs an HTML file.
218 It is typically used to display man pages on a web site.")
221 (define-public ronn-ng
228 (uri (rubygems-uri "ronn-ng" version))
231 "1slxfg57cabmh98fw507z4ka6lwq1pvbrqwppflxw6700pi8ykfh"))))
232 (build-system ruby-build-system)
235 (modify-phases %standard-phases
236 (add-after 'extract-gemspec 'fix-gemspec-mustache
238 (substitute* "ronn-ng.gemspec"
239 (("(<mustache>.freeze.*~>).*(\".*$)" all start end)
240 (string-append start " 1.0" end)))
242 (add-after 'wrap 'wrap-program
243 (lambda* (#:key outputs #:allow-other-keys)
244 (let ((prog (string-append (assoc-ref %outputs "out") "/bin/ronn")))
246 `("PATH" ":" suffix ,(map
249 (assoc-ref %build-inputs exp_inpt)
256 `(("ruby-kramdown" ,ruby-kramdown)
257 ("ruby-mustache" ,ruby-mustache)
258 ("ruby-nokogiri" ,ruby-nokogiri)))
260 "Build manuals in HTML and Unix man page format from Markdown")
262 "Ronn-NG is an updated fork of ronn. It builds manuals in HTML and Unix
263 man page format from Markdown.")
264 (home-page "https://github.com/apjanke/ronn-ng")