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