0daf614302a3e87a187a764b0b69002f64beeb07
[jackhill/guix/guix.git] / gnu / packages / groff.scm
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>
11 ;;;
12 ;;; This file is part of GNU Guix.
13 ;;;
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.
18 ;;;
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.
23 ;;;
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/>.
26
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))
43
44 (define-public groff
45 (package
46 (name "groff")
47 (version "1.22.4")
48 (source (origin
49 (method url-fetch)
50 (uri (string-append "mirror://gnu/groff/groff-" version
51 ".tar.gz"))
52 (sha256 (base32
53 "14q2mldnr1vx0l9lqp9v2f6iww24gj28iyh4j2211hyynx67p3p7"))))
54 (build-system gnu-build-system)
55 (outputs '("out"
56 "doc")) ;12MiB of PS, PDF, HTML, and examples
57
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
61 ;; from 'inputs'.
62
63 (inputs `(("ghostscript" ,ghostscript)))
64
65 ;; When cross-compiling, this package depends upon a native install of
66 ;; itself.
67 (native-inputs `(,@(if (%current-target-system)
68 `(("self" ,this-package))
69 '())
70 ("bison" ,bison)
71 ("perl" ,perl)
72 ("psutils" ,psutils)
73 ("texinfo" ,texinfo)))
74 (arguments
75 `(#:parallel-build? #f ; parallel build fails
76 ,@(if (%current-target-system)
77 `(#:make-flags
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"))))
82 (list
83 (string-append "GROFF_BIN_PATH=" groff)
84 (string-append "GROFFBIN=" groff "/bin/groff"))))
85 '())
86 #:phases
87 (modify-phases %standard-phases
88 (add-after 'unpack 'disable-relocatability
89 (lambda _
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
107 ;; details.
108 (substitute* "Makefile.in"
109 (("-DENABLE_RELOCATABLE=1") ""))
110 #t))
111 (add-after 'unpack 'setenv
112 (lambda _
113 (setenv "GS_GENERATE_UUIDS" "0")
114 #t))
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"))
119 #t)))))
120 (synopsis "Typesetting from plain text mixed with formatting commands")
121 (description
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.")
125 (license gpl3+)
126 (home-page "https://www.gnu.org/software/groff/")))
127
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.
131 (package
132 (inherit groff)
133 (name "groff-minimal")
134 (synopsis "Minimalist variant of Groff for use by man-db")
135 (outputs '("out"))
136
137 ;; Omit the DVI, PS, PDF, and HTML backends.
138 (inputs '())
139 (native-inputs `(("bison" ,bison)
140 ("perl" ,perl)
141 ("groff" ,groff)))
142
143 (arguments
144 `(#:disallowed-references (,perl)
145
146 #:configure-flags '("--with-doc=no")
147
148 ,@(substitute-keyword-arguments (package-arguments groff)
149 ((#:phases phases)
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)
160 (delete-file file)))
161 (find-files (string-append out "/bin")))
162
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"))
167
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)$"
172 #:directories? #t))
173 #t))))))))))
174
175 ;; There are no releases, so we take the latest commit.
176 (define-public roffit
177 (let ((commit "b59e6c855ebea03daf76e996b5c0f8343f11be3d")
178 (revision "1"))
179 (package
180 (name "roffit")
181 (version (string-append "0.12-" revision "." (string-take commit 9)))
182 (source (origin
183 (method git-fetch)
184 (uri (git-reference
185 (url "https://github.com/bagder/roffit")
186 (commit commit)))
187 (file-name (string-append "roffit-" commit "-checkout"))
188 (sha256
189 (base32
190 "0z4cs92yqh22sykfgbjlyxfaifdvsd47cf1yhr0f2rgcc6l0fj1r"))))
191 (build-system gnu-build-system)
192 (arguments
193 `(#:test-target "test"
194 #:make-flags
195 (list (string-append "INSTALLDIR="
196 (assoc-ref %outputs "out") "/bin"))
197 #:phases
198 (modify-phases %standard-phases
199 (delete 'configure)
200 (add-before 'install 'pre-install
201 (lambda* (#:key outputs #:allow-other-keys)
202 (mkdir-p (string-append (assoc-ref outputs "out")
203 "/bin"))
204 #t))
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"))))
210 #t))))))
211 (native-inputs `(("html-tree" ,perl-html-tree))) ; for test
212 (inputs
213 `(("perl" ,perl)))
214 (home-page "https://daniel.haxx.se/projects/roffit/")
215 (synopsis "Convert nroff files to HTML")
216 (description
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.")
219 (license expat))))
220
221 (define-public ronn-ng
222 (package
223 (name "ronn-ng")
224 (version "0.9.1")
225 (source
226 (origin
227 (method url-fetch)
228 (uri (rubygems-uri "ronn-ng" version))
229 (sha256
230 (base32
231 "1slxfg57cabmh98fw507z4ka6lwq1pvbrqwppflxw6700pi8ykfh"))))
232 (build-system ruby-build-system)
233 (arguments
234 `(#:phases
235 (modify-phases %standard-phases
236 (add-after 'extract-gemspec 'fix-gemspec-mustache
237 (lambda _
238 (substitute* "ronn-ng.gemspec"
239 (("(<mustache>.freeze.*~>).*(\".*$)" all start end)
240 (string-append start " 1.0" end)))
241 #t))
242 (add-after 'wrap 'wrap-program
243 (lambda* (#:key outputs #:allow-other-keys)
244 (let ((prog (string-append (assoc-ref %outputs "out") "/bin/ronn")))
245 (wrap-program prog
246 `("PATH" ":" suffix ,(map
247 (lambda (exp_inpt)
248 (string-append
249 (assoc-ref %build-inputs exp_inpt)
250 "/bin"))
251 '("ruby-kramdown"
252 "ruby-mustache"
253 "ruby-nokogiri")))))
254 #t)))))
255 (inputs
256 `(("ruby-kramdown" ,ruby-kramdown)
257 ("ruby-mustache" ,ruby-mustache)
258 ("ruby-nokogiri" ,ruby-nokogiri)))
259 (synopsis
260 "Build manuals in HTML and Unix man page format from Markdown")
261 (description
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")
265 (license expat)))