gnu: nnn: Don't use NAME in source URI.
[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 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22 (define-module (gnu packages groff)
23 #:use-module (guix licenses)
24 #:use-module (guix packages)
25 #:use-module (guix utils)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix build-system gnu)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages bison)
31 #:use-module (gnu packages ghostscript)
32 #:use-module (gnu packages netpbm)
33 #:use-module (gnu packages perl)
34 #:use-module (gnu packages texinfo))
35
36 (define-public groff
37 (package
38 (name "groff")
39 (version "1.22.3")
40 (source (origin
41 (method url-fetch)
42 (uri (string-append "mirror://gnu/groff/groff-" version
43 ".tar.gz"))
44 (sha256 (base32
45 "1998v2kcs288d3y7kfxpvl369nqi06zbbvjzafyvyl3pr7bajj1s"))
46 (patches (search-patches "groff-source-date-epoch.patch"))))
47 (build-system gnu-build-system)
48 (outputs '("out"
49 "doc")) ;12MiB of PS, PDF, HTML, and examples
50
51 ;; Note: groff's HTML backend uses executables from netpbm when they are in
52 ;; $PATH. In practice, not having them doesn't prevent it from install its
53 ;; own HTML doc, nor does it change its capabilities, so we removed netpbm
54 ;; from 'inputs'.
55
56 (inputs `(("ghostscript" ,ghostscript)))
57 (native-inputs `(("bison" ,bison)
58 ("perl" ,perl)
59 ("psutils" ,psutils)
60 ("texinfo" ,texinfo)))
61 (arguments
62 `(#:parallel-build? #f ; parallel build fails
63 #:phases
64 (modify-phases %standard-phases
65 (add-after 'unpack 'setenv
66 (lambda _
67 (setenv "GS_GENERATE_UUIDS" "0")
68 #t)))))
69 (synopsis "Typesetting from plain text mixed with formatting commands")
70 (description
71 "Groff is a typesetting package that reads plain text and produces
72 formatted output based on formatting commands contained within the text. It
73 is usually the formatter of \"man\" documentation pages.")
74 (license gpl3+)
75 (home-page "https://www.gnu.org/software/groff/")))
76
77 (define-public groff-minimal
78 ;; Minimialist groff for use by man-db. Its closure size is less than half
79 ;; that of the full-blown groff.
80 (package
81 (inherit groff)
82 (name "groff-minimal")
83 (synopsis "Minimalist variant of Groff for use by man-db")
84 (outputs '("out"))
85
86 ;; Omit the DVI, PS, PDF, and HTML backends.
87 (inputs '())
88 (native-inputs `(("bison" ,bison)
89 ("perl" ,perl)))
90
91 (arguments
92 `(#:disallowed-references (,perl)
93
94 #:configure-flags '("--docdir=/tmp/trash/doc")
95
96 ,@(substitute-keyword-arguments (package-arguments groff)
97 ((#:phases phases)
98 `(modify-phases ,phases
99 (add-after 'unpack 'disable-relocatability
100 (lambda _
101 ;; Groff contains a Rube Goldberg-esque relocator for the
102 ;; file "charset.alias".
103 ;; It tries to find the current executable using realpath,
104 ;; a do-it-yourself search in $PATH and so on.
105 ;; Furthermore, the routine that does the search is buggy
106 ;; in that it doesn't handle error cases when they arise.
107 ;; This causes preconv to segfault when trying to look up
108 ;; the file "charset.alias" in the NULL location.
109 ;; The "charset.alias" parser is a copy of gnulib's, and a
110 ;; non-broken version of gnulib's "charset.alias" parser
111 ;; is part of glibc's libcharset.
112 ;; However, groff unconditionally uses their own
113 ;; "charset.alias" parser, but then DOES NOT INSTALL the
114 ;; file "charset.alias" when glibc is too new.
115 ;; In Guix, our file "charset.alias" only contains an
116 ;; obscure alias for ASCII and nothing else.
117 ;; So just disable relocation and make the entire
118 ;; "charset.alias" lookup fail.
119 ;; See <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30785>
120 ;; for details.
121 (substitute* "src/libs/libgroff/Makefile.sub"
122 (("-DENABLE_RELOCATABLE=1") ""))
123 ;; That file contains a crash bug--so make sure that
124 ;; its contents are not there.
125 (call-with-output-file "src/libs/libgroff/relocate.cpp"
126 (lambda (port)
127 #t))
128 #t))
129 (add-after 'install 'remove-non-essential-programs
130 (lambda* (#:key outputs #:allow-other-keys)
131 ;; Keep only the programs that man-db needs at run time,
132 ;; and make sure we don't pull in Perl.
133 (let ((out (assoc-ref outputs "out"))
134 (kept '("eqn" "neqn" "pic" "tbl" "refer" "preconv"
135 "nroff" "groff" "troff" "grotty")))
136 (for-each (lambda (file)
137 (unless (member (basename file) kept)
138 (delete-file file)))
139 (find-files (string-append out "/bin")))
140
141 ;; Remove a bunch of unneeded Perl scripts.
142 (for-each delete-file (find-files out "\\.pl$"))
143 (for-each delete-file
144 (find-files out "BuildFoundries"))
145
146 ;; Remove ~3 MiB from share/groff/X.Y/font/devBACKEND
147 ;; corresponding to the unused backends.
148 (for-each delete-file-recursively
149 (find-files out "^dev(dvi|ps|pdf|html|lj4)$"
150 #:directories? #t))
151 #t))))))))))
152
153 ;; There are no releases, so we take the latest commit.
154 (define-public roffit
155 (let ((commit "e5228388e3faf2b7f1ae5bd048ad46ed565304c6")
156 (revision "1"))
157 (package
158 (name "roffit")
159 (version (string-append "0.11-" revision "." (string-take commit 9)))
160 (source (origin
161 (method git-fetch)
162 (uri (git-reference
163 (url "https://github.com/bagder/roffit.git")
164 (commit commit)))
165 (file-name (string-append "roffit-" commit "-checkout"))
166 (sha256
167 (base32
168 "1y7ndbqciy7h0khlpi1bv4v1614vhybnmm4jysj6fwxkw9cwv1nc"))))
169 (build-system gnu-build-system)
170 (arguments
171 `(#:test-target "test"
172 #:make-flags
173 (list (string-append "INSTALLDIR="
174 (assoc-ref %outputs "out") "/bin"))
175 #:phases
176 (modify-phases %standard-phases
177 (delete 'configure)
178 (add-before 'install 'pre-install
179 (lambda* (#:key outputs #:allow-other-keys)
180 (mkdir-p (string-append (assoc-ref outputs "out")
181 "/bin"))
182 #t)))))
183 (inputs
184 `(("perl" ,perl)))
185 (home-page "https://daniel.haxx.se/projects/roffit/")
186 (synopsis "Convert nroff files to HTML")
187 (description
188 "Roffit is a program that reads an nroff file and outputs an HTML file.
189 It is typically used to display man pages on a web site.")
190 (license expat))))