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