gnu: groff: Disable relocatability.
[jackhill/guix/guix.git] / gnu / packages / groff.scm
CommitLineData
23180beb
AE
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
dec7ab59 3;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
33ca5517 4;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
3c97322a 5;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
23180beb
AE
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)
2ced84fb 25 #:use-module (guix utils)
23180beb 26 #:use-module (guix download)
33ca5517 27 #:use-module (guix git-download)
23180beb
AE
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")
dec7ab59 39 (version "1.22.3")
23180beb
AE
40 (source (origin
41 (method url-fetch)
42 (uri (string-append "mirror://gnu/groff/groff-" version
43 ".tar.gz"))
44 (sha256 (base32
9146543f
DM
45 "1998v2kcs288d3y7kfxpvl369nqi06zbbvjzafyvyl3pr7bajj1s"))
46 (patches (search-patches "groff-source-date-epoch.patch"))))
23180beb 47 (build-system gnu-build-system)
7d157c65
LC
48 (outputs '("out"
49 "doc")) ;12MiB of PS, PDF, HTML, and examples
0b6e4f82
LC
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)))
c4c4cc05 57 (native-inputs `(("bison" ,bison)
dec7ab59
MW
58 ("perl" ,perl)
59 ("psutils" ,psutils)
60 ("texinfo" ,texinfo)))
e9e6d40b
DM
61 (arguments
62 `(#:parallel-build? #f ; parallel build fails
63 #:phases
64 (modify-phases %standard-phases
f57693e1
DM
65 (add-after 'unpack 'disable-relocatability
66 (lambda _
67 ;; Groff contains a Rube Goldberg-esque relocator for the file
68 ;; "charset.alias". It tries to find the current executable
69 ;; using realpath, a do-it-yourself search in $PATH and so on.
70 ;; Furthermore, the routine that does the search is buggy
71 ;; in that it doesn't handle error cases when they arise.
72 ;; This causes preconv to segfault when trying to look up
73 ;; the file "charset.alias" in the NULL location.
74 ;; The "charset.alias" parser is a copy of gnulib's, and a
75 ;; non-broken version of gnulib's "charset.alias" parser is
76 ;; part of glibc's libcharset.
77 ;; However, groff unconditionally uses their own
78 ;; "charset.alias" parser, but then DOES NOT INSTALL the
79 ;; file "charset.alias" when glibc is too new.
80 ;; In Guix, our file "charset.alias" only contains an obscure
81 ;; alias for ASCII and nothing else. So just disable relocation
82 ;; and make the entire "charset.alias" lookup fail.
83 ;; See <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30785> for
84 ;; details.
85 (substitute* "src/libs/libgroff/Makefile.sub"
86 (("-DENABLE_RELOCATABLE=1") ""))
87 ;; That file contains a crash bug--so make sure that
88 ;; its contents are not there.
89 (call-with-output-file "src/libs/libgroff/relocate.cpp"
90 (lambda (port)
91 #t))
92 #t))
e9e6d40b
DM
93 (add-after 'unpack 'setenv
94 (lambda _
95 (setenv "GS_GENERATE_UUIDS" "0")
96 #t)))))
f50d2669 97 (synopsis "Typesetting from plain text mixed with formatting commands")
23180beb 98 (description
79c311b8 99 "Groff is a typesetting package that reads plain text and produces
a22dc0c4 100formatted output based on formatting commands contained within the text. It
79c311b8 101is usually the formatter of \"man\" documentation pages.")
23180beb 102 (license gpl3+)
6fd52309 103 (home-page "https://www.gnu.org/software/groff/")))
33ca5517 104
3c97322a
LC
105(define-public groff-minimal
106 ;; Minimialist groff for use by man-db. Its closure size is less than half
107 ;; that of the full-blown groff.
108 (package
109 (inherit groff)
110 (name "groff-minimal")
111 (synopsis "Minimalist variant of Groff for use by man-db")
112 (outputs '("out"))
113
114 ;; Omit the DVI, PS, PDF, and HTML backends.
115 (inputs '())
116 (native-inputs `(("bison" ,bison)
117 ("perl" ,perl)))
118
119 (arguments
120 `(#:disallowed-references (,perl)
121
122 #:configure-flags '("--docdir=/tmp/trash/doc")
123
2ced84fb
MB
124 ,@(substitute-keyword-arguments (package-arguments groff)
125 ((#:phases phases)
126 `(modify-phases ,phases
127 (add-after 'install 'remove-non-essential-programs
128 (lambda* (#:key outputs #:allow-other-keys)
129 ;; Keep only the programs that man-db needs at run time,
130 ;; and make sure we don't pull in Perl.
131 (let ((out (assoc-ref outputs "out"))
06fc895f 132 (kept '("eqn" "neqn" "pic" "tbl" "refer" "preconv"
2ced84fb
MB
133 "nroff" "groff" "troff" "grotty")))
134 (for-each (lambda (file)
135 (unless (member (basename file) kept)
136 (delete-file file)))
137 (find-files (string-append out "/bin")))
3c97322a 138
2ced84fb
MB
139 ;; Remove a bunch of unneeded Perl scripts.
140 (for-each delete-file (find-files out "\\.pl$"))
141 (for-each delete-file
142 (find-files out "BuildFoundries"))
3c97322a 143
2ced84fb
MB
144 ;; Remove ~3 MiB from share/groff/X.Y/font/devBACKEND
145 ;; corresponding to the unused backends.
146 (for-each delete-file-recursively
147 (find-files out "^dev(dvi|ps|pdf|html|lj4)$"
148 #:directories? #t))
149 #t))))))))))
3c97322a 150
33ca5517
RW
151;; There are no releases, so we take the latest commit.
152(define-public roffit
153 (let ((commit "e5228388e3faf2b7f1ae5bd048ad46ed565304c6")
154 (revision "1"))
155 (package
156 (name "roffit")
157 (version (string-append "0.11-" revision "." (string-take commit 9)))
158 (source (origin
159 (method git-fetch)
160 (uri (git-reference
161 (url "https://github.com/bagder/roffit.git")
162 (commit commit)))
163 (file-name (string-append "roffit-" commit "-checkout"))
164 (sha256
165 (base32
166 "1y7ndbqciy7h0khlpi1bv4v1614vhybnmm4jysj6fwxkw9cwv1nc"))))
167 (build-system gnu-build-system)
168 (arguments
169 `(#:test-target "test"
170 #:make-flags
171 (list (string-append "INSTALLDIR="
172 (assoc-ref %outputs "out") "/bin"))
173 #:phases
174 (modify-phases %standard-phases
175 (delete 'configure)
176 (add-before 'install 'pre-install
177 (lambda* (#:key outputs #:allow-other-keys)
178 (mkdir-p (string-append (assoc-ref outputs "out")
179 "/bin"))
180 #t)))))
181 (inputs
182 `(("perl" ,perl)))
183 (home-page "https://daniel.haxx.se/projects/roffit/")
184 (synopsis "Convert nroff files to HTML")
185 (description
186 "Roffit is a program that reads an nroff file and outputs an HTML file.
187It is typically used to display man pages on a web site.")
188 (license expat))))