gnu: texlive-context: Adjust to changes from 'master'.
[jackhill/guix/guix.git] / gnu / packages / docbook.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2021 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
4 ;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
5 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
6 ;;; Copyright © 2020 Marius Bakke <marius@gnu.org>
7 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
8 ;;; Copyright © 2021 Mark H Weaver <mhw@netris.org>
9 ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
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 docbook)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages compression)
29 #:use-module (gnu packages imagemagick)
30 #:use-module (gnu packages inkscape)
31 #:use-module (gnu packages tex)
32 #:use-module (gnu packages perl)
33 #:use-module (gnu packages python)
34 #:use-module (gnu packages base)
35 #:use-module (gnu packages web-browsers)
36 #:use-module (gnu packages xml)
37 #:use-module (guix licenses)
38 #:use-module (guix packages)
39 #:use-module (guix download)
40 #:use-module ((guix build utils) #:select (alist-replace))
41 #:use-module (guix build-system gnu)
42 #:use-module (guix build-system trivial)
43 #:use-module (guix build-system python))
44
45 (define-public docbook-xml-5
46 (package
47 (name "docbook-xml")
48 (version "5.0.1")
49 (source (origin
50 (method url-fetch)
51 (uri (string-append "https://docbook.org/xml/" version
52 "/docbook-" version ".zip"))
53 (sha256
54 (base32
55 "1iz3hq1lqgnshvlz4j9gvh4jy1ml74qf90vqf2ikbq0h4i2xzybs"))))
56 (build-system trivial-build-system)
57 (arguments
58 `(#:modules ((guix build utils))
59 #:builder
60 (begin
61 (use-modules (guix build utils))
62 (let* ((unzip
63 (string-append (assoc-ref %build-inputs "unzip")
64 "/bin/unzip"))
65 (source (assoc-ref %build-inputs "source"))
66 (out (assoc-ref %outputs "out"))
67 (dtd (string-append out "/xml/dtd/docbook")))
68 (invoke unzip source)
69 (mkdir-p dtd)
70 (copy-recursively (string-append "docbook-" ,version) dtd)
71 (with-directory-excursion dtd
72 (substitute* (string-append out "/xml/dtd/docbook/catalog.xml")
73 (("uri=\"")
74 (string-append
75 "uri=\"file://" dtd "/")))
76 #t)))))
77 (native-inputs `(("unzip" ,unzip)))
78 (home-page "https://docbook.org")
79 (synopsis "DocBook XML DTDs for document authoring")
80 (description
81 "DocBook is general purpose XML and SGML document type particularly well
82 suited to books and papers about computer hardware and software (though it is
83 by no means limited to these applications.) This package provides XML DTDs.")
84 (license (x11-style "" "See file headers."))))
85
86 (define-public docbook-xml
87 (package
88 (inherit docbook-xml-5)
89 (name "docbook-xml")
90 (version "4.5")
91 (source (origin
92 (method url-fetch)
93 (uri (string-append "https://docbook.org/xml/" version
94 "/docbook-xml-" version ".zip"))
95 (sha256
96 (base32
97 "1d671lcjckjri28xfbf6dq7y3xnkppa910w1jin8rjc35dx06kjf"))))
98 (arguments
99 '(#:builder (begin
100 (use-modules (guix build utils))
101
102 (let* ((unzip
103 (string-append (assoc-ref %build-inputs "unzip")
104 "/bin/unzip"))
105 (source (assoc-ref %build-inputs "source"))
106 (out (assoc-ref %outputs "out"))
107 (dtd (string-append out "/xml/dtd/docbook")))
108 (mkdir-p dtd)
109 (with-directory-excursion dtd
110 (invoke unzip source))
111 (substitute* (string-append out "/xml/dtd/docbook/catalog.xml")
112 (("uri=\"")
113 (string-append
114 "uri=\"file://" dtd "/")))
115 #t))
116 #:modules ((guix build utils))))))
117
118 (define-public docbook-xml-4.4
119 (package (inherit docbook-xml)
120 (version "4.4")
121 (source (origin
122 (method url-fetch)
123 (uri (string-append "https://docbook.org/xml/" version
124 "/docbook-xml-" version ".zip"))
125 (sha256
126 (base32
127 "141h4zsyc71sfi2zzd89v4bb4qqq9ca1ri9ix2als9f4i3mmkw82"))))))
128
129 (define-public docbook-xml-4.3
130 (package (inherit docbook-xml)
131 (version "4.3")
132 (source (origin
133 (method url-fetch)
134 (uri (string-append "https://docbook.org/xml/" version
135 "/docbook-xml-" version ".zip"))
136 (sha256
137 (base32
138 "0r1l2if1z4wm2v664sqdizm4gak6db1kx9y50jq89m3gxaa8l1i3"))))))
139
140 (define-public docbook-xml-4.2
141 (package (inherit docbook-xml)
142 (version "4.2")
143 (source (origin
144 (method url-fetch)
145 (uri (string-append "https://docbook.org/xml/" version
146 "/docbook-xml-" version ".zip"))
147 (sha256
148 (base32
149 "18hgwvmywh6a5jh38szjmg3hg2r4v5lb6r3ydc3rd8cp9wg61i5c"))))))
150
151 (define-public docbook-xml-4.1.2
152 (package (inherit docbook-xml)
153 (version "4.1.2")
154 (source (origin
155 (method url-fetch)
156 (uri (string-append "https://docbook.org/xml/" version
157 "/docbkx412.zip"))
158 (sha256
159 (base32
160 "0wkp5rvnqj0ghxia0558mnn4c7s3n501j99q2isp3sp0ci069w1h"))))
161 (arguments
162 '(#:modules ((guix build utils))
163 #:builder
164 (begin
165 (use-modules (guix build utils))
166 (let ((source (assoc-ref %build-inputs "source"))
167 (unzip (string-append (assoc-ref %build-inputs "unzip")
168 "/bin/unzip"))
169 (dtd (string-append (assoc-ref %outputs "out")
170 "/xml/dtd/docbook")))
171 (mkdir-p dtd)
172 (invoke unzip source "-d" dtd)))))))
173
174 (define-public docbook-xsl
175 (package
176 (name "docbook-xsl")
177 (version "1.79.2")
178 (source (origin
179 (method url-fetch)
180 (uri (string-append "https://github.com/docbook/xslt10-stylesheets"
181 "/releases/download/release%2F" version
182 "/docbook-xsl-" version ".tar.bz2"))
183 (patches (search-patches "docbook-xsl-support-old-url.patch"
184 "docbook-xsl-nonrecursive-string-subst.patch"))
185 (sha256
186 (base32
187 "0wd33z41kdsybyx3ay21w6bdlmgpd9kyn3mr5y520lsf8km28r9i"))
188 (modules '((guix build utils)))
189 (snippet
190 '(begin
191 (for-each delete-file (find-files "." "\\.jar$"))
192 #t))))
193 (build-system trivial-build-system)
194 (arguments
195 `(#:builder (begin
196 (use-modules (guix build utils))
197
198 (define name-version
199 (string-append ,name "-" ,version))
200
201 (let* ((bzip2 (assoc-ref %build-inputs "bzip2"))
202 (xz (assoc-ref %build-inputs "xz"))
203 (tar (assoc-ref %build-inputs "tar"))
204 (source (assoc-ref %build-inputs "source"))
205 (out (assoc-ref %outputs "out"))
206 (xsl (string-append out "/xml/xsl")))
207 (setenv "PATH" (string-append bzip2 "/bin" ":" xz "/bin"))
208 (invoke (string-append tar "/bin/tar") "xvf" source)
209
210 (mkdir-p xsl)
211 (copy-recursively name-version
212 (string-append xsl "/" name-version))
213
214 (substitute* (string-append xsl "/" name-version "/catalog.xml")
215 (("rewritePrefix=\"./")
216 (string-append "rewritePrefix=\"file://" xsl "/"
217 name-version "/")))
218 #t))
219 #:modules ((guix build utils))))
220 (native-inputs `(("bzip2" ,bzip2)
221 ("xz" ,xz) ;needed for repacked tarballs
222 ("tar" ,tar)))
223 (home-page "https://docbook.org")
224 (synopsis "DocBook XSL style sheets for document authoring")
225 (description
226 "This package provides XSL style sheets for DocBook.")
227 (license (x11-style "" "See 'COPYING' file."))))
228
229 (define-public docbook-dsssl
230 (package
231 (name "docbook-dsssl")
232 (version "1.79")
233 (source (origin
234 (method url-fetch)
235 (uri (string-append "mirror://sourceforge/docbook/"
236 name "/" version "/"
237 name "-" version ".tar.bz2"))
238 (sha256
239 (base32
240 "1g72y2yyc2k89kzs0lvrb9n7hjayw1hdskfpplpz97pf1c99wcig"))))
241 (build-system trivial-build-system)
242 (outputs '("out" "doc"))
243 (arguments
244 `(#:modules ((guix build utils))
245 #:builder
246 (begin
247 (use-modules (guix build utils))
248 (let ((source (assoc-ref %build-inputs "source"))
249 (dtd (string-append (assoc-ref %outputs "out")
250 "/sgml/dtd/docbook"))
251 (docbook-dsssl-doc (assoc-ref %build-inputs "docbook-dsssl-doc"))
252 (doc (assoc-ref %outputs "doc"))
253 (tar (assoc-ref %build-inputs "tar"))
254 (bzip2 (assoc-ref %build-inputs "bzip2")))
255 (setenv "PATH" (string-append tar "/bin" ":" bzip2 "/bin"))
256 (mkdir-p dtd)
257 (invoke "tar" "-xf" source "-C" dtd)
258 ;; The doc output contains 1.4 MiB of HTML documentation.
259 (symlink docbook-dsssl-doc doc)))))
260 (inputs
261 `(("docbook-dsssl-doc" ,docbook-dsssl-doc)))
262 (native-inputs
263 `(("bzip2" ,bzip2)
264 ("tar" ,tar)))
265 (home-page "https://docbook.org/")
266 (synopsis "DSSSL style sheets for DocBook")
267 (description "This package provides DSSSL style sheets for DocBook.")
268 (license (non-copyleft "file://README"))))
269
270 ;;; Private variable, used as the 'doc' output of the docbook-dsssl package.
271 (define docbook-dsssl-doc
272 (package
273 (name "docbook-dsssl-doc")
274 (version "1.79")
275 (source (origin
276 (method url-fetch)
277 (uri (string-append "mirror://sourceforge/docbook/"
278 name "/" version "/"
279 name "-" version ".tar.bz2"))
280 (sha256
281 (base32
282 "1plp5ngc96pbna4rwglp9glcadnirbm3hlcjb4gjvq1f8biic9lz"))))
283 (build-system trivial-build-system)
284 (arguments
285 `(#:modules ((guix build utils))
286 #:builder
287 (begin
288 (use-modules (guix build utils))
289 (let ((source (assoc-ref %build-inputs "source"))
290 (docdir (string-append (assoc-ref %outputs "out")
291 "/share/doc/" "docbook-dsssl-" ,version))
292 (tar (assoc-ref %build-inputs "tar"))
293 (bzip2 (assoc-ref %build-inputs "bzip2")))
294 (setenv "PATH" (string-append tar "/bin" ":" bzip2 "/bin"))
295 (mkdir-p docdir)
296 ;; Extract the "doc" subdirectory.
297 (invoke "tar" "-xf" source "--strip-components=2"
298 "--no-same-owner" "-C" docdir
299 (string-append "docbook-dsssl-" ,version "/doc"))))))
300 (native-inputs
301 `(("bzip2" ,bzip2)
302 ("tar" ,tar)))
303 (home-page "https://docbook.org/")
304 (synopsis "DocBook DSSSL style sheets documentation")
305 (description "Documentation for the DocBook DSSSL style sheets.")
306 (license (non-copyleft "file://doc/LEGALNOTICE.htm"))))
307
308 (define-public docbook-sgml
309 (package
310 (name "docbook-sgml")
311 (version "4.1")
312 (source (origin
313 (method url-fetch)
314 (uri (string-append "https://www.oasis-open.org/docbook/sgml/"
315 version "/docbk41.zip"))
316 (sha256
317 (base32
318 "04b3gp4zkh9c5g9kvnywdkdfkcqx3kjc04j4mpkr4xk7lgqgrany"))))
319 (build-system trivial-build-system)
320 (arguments
321 '(#:modules ((guix build utils))
322 #:builder
323 (begin
324 (use-modules (guix build utils))
325 (let ((source (assoc-ref %build-inputs "source"))
326 (iso-entities-dir (string-append
327 (assoc-ref %build-inputs "iso-8879-entities")))
328 (unzip (string-append (assoc-ref %build-inputs "unzip")
329 "/bin/unzip"))
330 (dtd (string-append (assoc-ref %outputs "out")
331 "/sgml/dtd/docbook")))
332 ;; Extract the sources.
333 (mkdir-p dtd)
334 (chdir dtd)
335 (invoke unzip source)
336 ;; Reference the ISO 8879 character entities.
337 ;; e.g. "iso-lat1.gml" --> "<iso-entities-dir>/ISOlat1"
338 (substitute* "docbook.cat"
339 (("(.*ISO 8879.*)\"iso-(.*)\\.gml\"" _ head name)
340 (string-append head "\"" iso-entities-dir "/ISO" name "\"")))))))
341 (native-inputs
342 `(("unzip" ,unzip)))
343 (inputs
344 `(("iso-8879-entities" ,iso-8879-entities)))
345 (home-page "https://docbook.org")
346 (synopsis "DocBook SGML style sheets for document authoring")
347 (description "This package provides SGML style sheets for DocBook.")
348 (license (x11-style "" "See file headers."))))
349
350 (define-public docbook-sgml-3.1
351 (package
352 (inherit docbook-sgml)
353 (version "3.1")
354 (source (origin
355 (method url-fetch)
356 (uri (string-append "https://www.oasis-open.org/docbook/sgml/"
357 version "/docbk31.zip"))
358 (sha256
359 (base32
360 "0f25ch7bywwhdxb1qa0hl28mgq1blqdap3rxzamm585rf4kis9i0"))))))
361
362 ;;; Private package referenced by docbook-sgml.
363 (define iso-8879-entities
364 (package
365 (name "iso-8879-entities")
366 (version "0.0") ;no proper version
367 (source (origin
368 (method url-fetch)
369 (uri "http://www.oasis-open.org/cover/ISOEnts.zip")
370 (sha256
371 (base32
372 "1clrkaqnvc1ja4lj8blr0rdlphngkcda3snm7b9jzvcn76d3br6w"))))
373 (build-system trivial-build-system)
374 (arguments
375 '(#:modules ((guix build utils))
376 #:builder
377 (begin
378 (use-modules (guix build utils))
379 (let ((source (assoc-ref %build-inputs "source"))
380 (unzip (string-append (assoc-ref %build-inputs "unzip")
381 "/bin/unzip"))
382 (out (string-append (assoc-ref %outputs "out"))))
383 (invoke unzip source "-d" out)))))
384 (native-inputs `(("unzip" ,unzip)))
385 (home-page "https://www.oasis-open.org/")
386 (synopsis "ISO 8879 character entities")
387 (description "ISO 8879 character entities that are typically used in
388 the in DocBook SGML DTDs.")
389 (license (x11-style "" "See file headers."))))
390
391 (define-public dblatex
392 (package
393 (name "dblatex")
394 (version "0.3.12")
395 (source (origin
396 (method url-fetch)
397 (uri (string-append "mirror://sourceforge/dblatex/dblatex/"
398 "dblatex-" version "/dblatex3-"
399 version ".tar.bz2"))
400 (sha256
401 (base32
402 "0yd09nypswy3q4scri1dg7dr99d7gd6r2dwx0xm81l9f4y32gs0n"))))
403 (build-system python-build-system)
404 ;; TODO: Add xfig/transfig for fig2dev utility
405 (inputs
406 `(("texlive" ,(texlive-updmap.cfg (list texlive-amsfonts
407 texlive-latex-anysize
408 texlive-latex-appendix
409 texlive-latex-bookmark
410 texlive-latex-changebar
411 texlive-latex-colortbl
412 texlive-latex-fancybox
413 texlive-latex-fancyhdr
414 texlive-latex-fancyvrb
415 texlive-latex-float
416 texlive-latex-footmisc
417 texlive-hyperref
418 texlive-latex-jknapltx
419 texlive-latex-listings
420 texlive-latex-multirow
421 texlive-latex-overpic
422 texlive-latex-pdfpages
423 texlive-latex-refcount
424 texlive-latex-subfigure
425 texlive-latex-titlesec
426 texlive-wasysym
427
428 texlive-fonts-rsfs
429 texlive-stmaryrd
430
431 texlive-generic-iftex)))
432 ("imagemagick" ,imagemagick) ;for convert
433 ("inkscape" ,inkscape) ;for svg conversion
434 ("docbook" ,docbook-xml)
435 ("libxslt" ,libxslt))) ;for xsltproc
436 (arguments
437 `(;; Using setuptools causes an invalid "package_base" path in
438 ;; out/bin/.dblatex-real due to a missing leading '/'. This is caused
439 ;; by dblatex's setup.py stripping the root path when creating the
440 ;; script. (dblatex's setup.py still uses distutils and thus has to
441 ;; create the script by itself. The feature for creating scripts is one
442 ;; of setuptools' features.)
443 ;; See this thread for details:
444 ;; https://lists.gnu.org/archive/html/guix-devel/2016-12/msg00030.html
445 #:use-setuptools? #f
446 #:tests? #f ;no 'test' command
447 #:phases
448 (modify-phases %standard-phases
449 (add-after 'wrap 'set-path
450 (lambda* (#:key inputs outputs #:allow-other-keys)
451 (let ((out (assoc-ref outputs "out")))
452 ;; dblatex executes helper programs at runtime.
453 (wrap-program (string-append out "/bin/dblatex")
454 `("PATH" ":" prefix
455 ,(map (lambda (input)
456 (string-append (assoc-ref inputs input)
457 "/bin"))
458 '("libxslt" "texlive"
459 "imagemagick" "inkscape"))))
460 #t))))))
461 (home-page "http://dblatex.sourceforge.net")
462 (synopsis "DocBook to LaTeX Publishing")
463 (description
464 "DocBook to LaTeX Publishing transforms your SGML/XML DocBook documents
465 to DVI, PostScript or PDF by translating them in pure LaTeX as a first
466 process. MathML 2.0 markups are supported too. It started as a clone of
467 DB2LaTeX.")
468 ;; lib/contrib/which is under an X11 license
469 (license gpl2+)))
470
471 ;; This is a variant of the 'dblatex' package that is not updated often. It
472 ;; is intended to be used as a native-input at build-time only, e.g. by
473 ;; 'gtk-doc' for generating package documentation. This allows the main
474 ;; 'dblatex' and 'imagemagick' packages to be freely updated on the 'master'
475 ;; branch without triggering an excessive number of rebuilds.
476 (define-public dblatex/stable
477 (hidden-package
478 (package/inherit dblatex
479 (inputs (alist-replace "imagemagick" `(,imagemagick/stable)
480 (package-inputs dblatex))))))
481
482 (define-public docbook-utils
483 (package
484 (name "docbook-utils")
485 (version "0.6.14")
486 (source (origin
487 (method url-fetch)
488 ;; The original sources are not accessible anymore.
489 (uri (string-append "http://deb.debian.org/debian/pool/main/"
490 "d/docbook-utils/docbook-utils_"
491 version ".orig.tar.gz"))
492 (sha256
493 (base32
494 "1scj5vgw1xz872pq54a89blcxqqm11p90yzv8a9mqq57x27apyj8"))))
495 (build-system gnu-build-system)
496 (arguments
497 `(#:phases (modify-phases %standard-phases
498 (add-after 'unpack 'patch-build-system
499 (lambda _
500 (substitute* (find-files "." "\\.in$")
501 ;; Do not hard-code SGML_CATALOG_FILES.
502 ((".*SGML_CATALOG_FILES=/etc/sgml/catalog.*") "")
503 ;; Use OpenSP and OpenJade.
504 (("\\bjade\\b")
505 "openjade")
506 (("\\bnsgmls\\b")
507 "onsgmls"))
508 #t))
509 (add-after 'unpack 'patch-jw.in
510 ;; Do not override the SGML_CATALOG_FILES environment
511 ;; variable.
512 (lambda _
513 (substitute* "bin/jw.in"
514 ((".*SGML_CATALOG_FILES=`find.*")
515 "")
516 (("SGML_CATALOG_FILES=`echo.*")
517 ":\n")
518 (("SGML_CATALOG_FILES=\"\"")
519 ":")
520 (("\\bwhich\\b")
521 "command -v"))
522 #t))
523 (add-after 'unpack 'patch-txt-backend
524 (lambda _
525 ;; Locate lynx, links or w3m from the PATH, not from
526 ;; /usr/bin.
527 (substitute* "backends/txt"
528 (("CONVERT=/usr/bin/")
529 "CONVERT=")
530 (("\\[ -x /usr/bin/([^ ]+) \\]" dummy command)
531 (string-append "command -v " command " > /dev/null")))
532 #t)))))
533 ;; Propagated for convenience. All these tools are used at run time to
534 ;; provide the complete functionality of the docbook-utils commands.
535 (propagated-inputs
536 `(("texlive-jadetex" ,texlive-jadetex)
537 ("docbook-sgml" ,docbook-sgml-3.1)
538 ("docbook-dsssl" ,docbook-dsssl)
539 ("openjade" ,openjade)
540 ("opensp" ,opensp)
541 ("lynx" ,lynx)
542 ("perl-sgmls" ,perl-sgmls)))
543 (home-page "https://packages.debian.org/sid/docbook-utils")
544 (synopsis "DocBook converter to other formats")
545 (description "The docbook-utils package is a collection of utilities
546 intended to ease the use of SGML and XML.
547 @table @command
548 @item jw
549 Convert a SGML DocBook file to other formats such as Hyper Text Markup
550 Language (HTML), Rich Text Format (RTF), PostScript (PS), man, Portable
551 Document Format (PDF), TeX, Texinfo or plain text (txt). It can be used
552 more conveniently via the following wrappers:
553 @itemx docbook2dvi Convert a SGML DocBook file to the DVI format.
554 @itemx docbook2html Convert a SGML DocBook file to an HTML document.
555 @itemx docbook2man Convert a SGML DocBook file a man page.
556 @itemx docbook2pdf Convert a SGML DocBook file to a PDF document.
557 @itemx docbook2ps Convert a SGML DocBook file to a PS document.
558 @itemx docbook2rtf Convert a SGML DocBook file to a RTF document.
559 @itemx docbook2tex Convert a SGML DocBook file to a TeX document.
560 @itemx docbook2texi Convert a SGML DocBook file to a Texinfo document.
561 @itemx docbook2txt Convert a SGML DocBook file to a plain text document.
562 @item sgmldiff
563 Detect the differences in markup between two SGML files.
564 @end table")
565 (license gpl2+)))