| 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 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 | (native-inputs `(("html-tree" ,perl-html-tree))) ; for test |
| 206 | (inputs |
| 207 | `(("perl" ,perl))) |
| 208 | (home-page "https://daniel.haxx.se/projects/roffit/") |
| 209 | (synopsis "Convert nroff files to HTML") |
| 210 | (description |
| 211 | "Roffit is a program that reads an nroff file and outputs an HTML file. |
| 212 | It is typically used to display man pages on a web site.") |
| 213 | (license expat)))) |
| 214 | |
| 215 | (define-public ronn-ng |
| 216 | (package |
| 217 | (name "ronn-ng") |
| 218 | (version "0.9.1") |
| 219 | (source |
| 220 | (origin |
| 221 | (method url-fetch) |
| 222 | (uri (rubygems-uri "ronn-ng" version)) |
| 223 | (sha256 |
| 224 | (base32 |
| 225 | "1slxfg57cabmh98fw507z4ka6lwq1pvbrqwppflxw6700pi8ykfh")))) |
| 226 | (build-system ruby-build-system) |
| 227 | (arguments |
| 228 | `(#:phases |
| 229 | (modify-phases %standard-phases |
| 230 | (add-after 'extract-gemspec 'fix-gemspec-mustache |
| 231 | (lambda _ |
| 232 | (substitute* "ronn-ng.gemspec" |
| 233 | (("(<mustache>.freeze.*~>).*(\".*$)" all start end) |
| 234 | (string-append start " 1.0" end))) |
| 235 | #t)) |
| 236 | (add-after 'wrap 'wrap-program |
| 237 | (lambda* (#:key outputs #:allow-other-keys) |
| 238 | (let ((prog (string-append (assoc-ref %outputs "out") "/bin/ronn"))) |
| 239 | (wrap-program prog |
| 240 | `("PATH" ":" suffix ,(map |
| 241 | (lambda (exp_inpt) |
| 242 | (string-append |
| 243 | (assoc-ref %build-inputs exp_inpt) |
| 244 | "/bin")) |
| 245 | '("ruby-kramdown" |
| 246 | "ruby-mustache" |
| 247 | "ruby-nokogiri"))))) |
| 248 | #t))))) |
| 249 | (inputs |
| 250 | `(("ruby-kramdown" ,ruby-kramdown) |
| 251 | ("ruby-mustache" ,ruby-mustache) |
| 252 | ("ruby-nokogiri" ,ruby-nokogiri))) |
| 253 | (synopsis |
| 254 | "Build manuals in HTML and Unix man page format from Markdown") |
| 255 | (description |
| 256 | "Ronn-NG is an updated fork of ronn. It builds manuals in HTML and Unix |
| 257 | man page format from Markdown.") |
| 258 | (home-page "https://github.com/apjanke/ronn-ng") |
| 259 | (license expat))) |