1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 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 Andrew Whatson <whatson@gmail.com>
11 ;;; This file is part of GNU Guix.
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.
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.
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/>.
26 (define-module (gnu packages docbook)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages bash)
29 #:use-module (gnu packages compression)
30 #:use-module (gnu packages imagemagick)
31 #:use-module (gnu packages inkscape)
32 #:use-module (gnu packages tex)
33 #:use-module (gnu packages texinfo)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages python)
36 #:use-module (gnu packages base)
37 #:use-module (gnu packages xml)
38 #:use-module ((guix licenses) #:prefix license:)
39 #:use-module (guix packages)
40 #:use-module (guix download)
41 #:use-module ((guix build utils) #:select (alist-replace))
42 #:use-module (guix build-system gnu)
43 #:use-module (guix build-system trivial)
44 #:use-module (guix build-system python))
46 (define-public docbook-xml-5
52 (uri (string-append "https://docbook.org/xml/" version
53 "/docbook-" version ".zip"))
56 "1iz3hq1lqgnshvlz4j9gvh4jy1ml74qf90vqf2ikbq0h4i2xzybs"))))
57 (build-system trivial-build-system)
59 `(#:modules ((guix build utils))
62 (use-modules (guix build utils))
64 (string-append (assoc-ref %build-inputs "unzip")
66 (source (assoc-ref %build-inputs "source"))
67 (out (assoc-ref %outputs "out"))
68 (dtd (string-append out "/xml/dtd/docbook")))
71 (copy-recursively (string-append "docbook-" ,version) dtd)
72 (with-directory-excursion dtd
73 (substitute* (string-append out "/xml/dtd/docbook/catalog.xml")
76 "uri=\"file://" dtd "/")))
78 (native-inputs `(("unzip" ,unzip)))
79 (home-page "https://docbook.org")
80 (synopsis "DocBook XML DTDs for document authoring")
82 "DocBook is general purpose XML and SGML document type particularly well
83 suited to books and papers about computer hardware and software (though it is
84 by no means limited to these applications.) This package provides XML DTDs.")
85 (license (license:x11-style "" "See file headers."))))
87 (define-public docbook-xml
89 (inherit docbook-xml-5)
94 (uri (string-append "https://docbook.org/xml/" version
95 "/docbook-xml-" version ".zip"))
98 "1d671lcjckjri28xfbf6dq7y3xnkppa910w1jin8rjc35dx06kjf"))))
101 (use-modules (guix build utils))
104 (string-append (assoc-ref %build-inputs "unzip")
106 (source (assoc-ref %build-inputs "source"))
107 (out (assoc-ref %outputs "out"))
108 (dtd (string-append out "/xml/dtd/docbook")))
110 (with-directory-excursion dtd
111 (invoke unzip source))
112 (substitute* (string-append out "/xml/dtd/docbook/catalog.xml")
115 "uri=\"file://" dtd "/")))
117 #:modules ((guix build utils))))))
119 (define-public docbook-xml-4.4
120 (package (inherit docbook-xml)
124 (uri (string-append "https://docbook.org/xml/" version
125 "/docbook-xml-" version ".zip"))
128 "141h4zsyc71sfi2zzd89v4bb4qqq9ca1ri9ix2als9f4i3mmkw82"))))))
130 (define-public docbook-xml-4.3
131 (package (inherit docbook-xml)
135 (uri (string-append "https://docbook.org/xml/" version
136 "/docbook-xml-" version ".zip"))
139 "0r1l2if1z4wm2v664sqdizm4gak6db1kx9y50jq89m3gxaa8l1i3"))))))
141 (define-public docbook-xml-4.2
142 (package (inherit docbook-xml)
146 (uri (string-append "https://docbook.org/xml/" version
147 "/docbook-xml-" version ".zip"))
150 "18hgwvmywh6a5jh38szjmg3hg2r4v5lb6r3ydc3rd8cp9wg61i5c"))))))
152 (define-public docbook-xml-4.1.2
153 (package (inherit docbook-xml)
157 (uri (string-append "https://docbook.org/xml/" version
161 "0wkp5rvnqj0ghxia0558mnn4c7s3n501j99q2isp3sp0ci069w1h"))))
163 '(#:modules ((guix build utils))
166 (use-modules (guix build utils))
167 (let ((source (assoc-ref %build-inputs "source"))
168 (unzip (string-append (assoc-ref %build-inputs "unzip")
170 (dtd (string-append (assoc-ref %outputs "out")
171 "/xml/dtd/docbook")))
173 (invoke unzip source "-d" dtd)))))))
175 (define-public docbook-xsl
181 (uri (string-append "mirror://sourceforge/docbook/docbook-xsl/"
182 version "/docbook-xsl-" version ".tar.bz2"))
183 (patches (search-patches "docbook-xsl-nonrecursive-string-subst.patch"))
186 "0s59lihif2fr7rznckxr2kfyrvkirv76r1zvidp9b5mj28p4apvj"))
187 (modules '((guix build utils)))
190 (for-each delete-file (find-files "." "\\.jar$"))
192 (build-system trivial-build-system)
194 `(#:builder (let ((name-version (string-append ,name "-" ,version)))
195 (use-modules (guix build utils))
197 (let* ((bzip2 (assoc-ref %build-inputs "bzip2"))
198 (xz (assoc-ref %build-inputs "xz"))
199 (tar (assoc-ref %build-inputs "tar"))
200 (source (assoc-ref %build-inputs "source"))
201 (out (assoc-ref %outputs "out"))
202 (xsl (string-append out "/xml/xsl")))
203 (setenv "PATH" (string-append bzip2 "/bin" ":" xz "/bin"))
204 (invoke (string-append tar "/bin/tar") "xvf" source)
207 (copy-recursively name-version
208 (string-append xsl "/" name-version))
210 (substitute* (string-append xsl "/" name-version "/catalog.xml")
211 (("rewritePrefix=\"./")
212 (string-append "rewritePrefix=\"file://" xsl "/"
215 #:modules ((guix build utils))))
216 (native-inputs `(("bzip2" ,bzip2)
217 ("xz" ,xz) ;needed for repacked tarballs
219 (home-page "https://docbook.org")
220 (synopsis "DocBook XSL style sheets for document authoring")
222 "This package provides XSL style sheets for DocBook.")
223 (license (license:x11-style "" "See 'COPYING' file."))))
225 (define-public docbook-dsssl
227 (name "docbook-dsssl")
231 (uri (string-append "mirror://sourceforge/docbook/"
233 name "-" version ".tar.bz2"))
236 "1g72y2yyc2k89kzs0lvrb9n7hjayw1hdskfpplpz97pf1c99wcig"))))
237 (build-system trivial-build-system)
238 (outputs '("out" "doc"))
240 `(#:modules ((guix build utils))
243 (use-modules (guix build utils))
244 (let ((source (assoc-ref %build-inputs "source"))
245 (dtd (string-append (assoc-ref %outputs "out")
246 "/sgml/dtd/docbook"))
247 (docbook-dsssl-doc (assoc-ref %build-inputs "docbook-dsssl-doc"))
248 (doc (assoc-ref %outputs "doc"))
249 (tar (assoc-ref %build-inputs "tar"))
250 (bzip2 (assoc-ref %build-inputs "bzip2")))
251 (setenv "PATH" (string-append tar "/bin" ":" bzip2 "/bin"))
253 (invoke "tar" "-xf" source "-C" dtd)
254 ;; The doc output contains 1.4 MiB of HTML documentation.
255 (symlink docbook-dsssl-doc doc)))))
257 `(("docbook-dsssl-doc" ,docbook-dsssl-doc)))
261 (home-page "https://docbook.org/")
262 (synopsis "DSSSL style sheets for DocBook")
263 (description "This package provides DSSSL style sheets for DocBook.")
264 (license (license:non-copyleft "file://README"))))
266 ;;; Private variable, used as the 'doc' output of the docbook-dsssl package.
267 (define docbook-dsssl-doc
269 (name "docbook-dsssl-doc")
273 (uri (string-append "mirror://sourceforge/docbook/"
275 name "-" version ".tar.bz2"))
278 "1plp5ngc96pbna4rwglp9glcadnirbm3hlcjb4gjvq1f8biic9lz"))))
279 (build-system trivial-build-system)
281 `(#:modules ((guix build utils))
284 (use-modules (guix build utils))
285 (let ((source (assoc-ref %build-inputs "source"))
286 (docdir (string-append (assoc-ref %outputs "out")
287 "/share/doc/" "docbook-dsssl-" ,version))
288 (tar (assoc-ref %build-inputs "tar"))
289 (bzip2 (assoc-ref %build-inputs "bzip2")))
290 (setenv "PATH" (string-append tar "/bin" ":" bzip2 "/bin"))
292 ;; Extract the "doc" subdirectory.
293 (invoke "tar" "-xf" source "--strip-components=2"
294 "--no-same-owner" "-C" docdir
295 (string-append "docbook-dsssl-" ,version "/doc"))))))
299 (home-page "https://docbook.org/")
300 (synopsis "DocBook DSSSL style sheets documentation")
301 (description "Documentation for the DocBook DSSSL style sheets.")
302 (license (license:non-copyleft "file://doc/LEGALNOTICE.htm"))))
304 (define-public docbook-sgml
306 (name "docbook-sgml")
310 (uri (string-append "https://www.oasis-open.org/docbook/sgml/"
311 version "/docbk41.zip"))
314 "04b3gp4zkh9c5g9kvnywdkdfkcqx3kjc04j4mpkr4xk7lgqgrany"))))
315 (build-system trivial-build-system)
317 '(#:modules ((guix build utils))
320 (use-modules (guix build utils))
321 (let ((source (assoc-ref %build-inputs "source"))
322 (iso-entities-dir (string-append
323 (assoc-ref %build-inputs "iso-8879-entities")))
324 (unzip (string-append (assoc-ref %build-inputs "unzip")
326 (dtd (string-append (assoc-ref %outputs "out")
327 "/sgml/dtd/docbook")))
328 ;; Extract the sources.
331 (invoke unzip source)
332 ;; Reference the ISO 8879 character entities.
333 ;; e.g. "iso-lat1.gml" --> "<iso-entities-dir>/ISOlat1"
334 (substitute* "docbook.cat"
335 (("(.*ISO 8879.*)\"iso-(.*)\\.gml\"" _ head name)
336 (string-append head "\"" iso-entities-dir "/ISO" name "\"")))))))
340 `(("iso-8879-entities" ,iso-8879-entities)))
341 (home-page "https://docbook.org")
342 (synopsis "DocBook SGML style sheets for document authoring")
343 (description "This package provides SGML style sheets for DocBook.")
344 (license (license:x11-style "" "See file headers."))))
346 (define-public docbook-sgml-3.1
348 (inherit docbook-sgml)
352 (uri (string-append "https://www.oasis-open.org/docbook/sgml/"
353 version "/docbk31.zip"))
356 "0f25ch7bywwhdxb1qa0hl28mgq1blqdap3rxzamm585rf4kis9i0"))))))
358 ;;; Private package referenced by docbook-sgml.
359 (define iso-8879-entities
361 (name "iso-8879-entities")
362 (version "0.0") ;no proper version
365 (uri "http://www.oasis-open.org/cover/ISOEnts.zip")
368 "1clrkaqnvc1ja4lj8blr0rdlphngkcda3snm7b9jzvcn76d3br6w"))))
369 (build-system trivial-build-system)
371 '(#:modules ((guix build utils))
374 (use-modules (guix build utils))
375 (let ((source (assoc-ref %build-inputs "source"))
376 (unzip (string-append (assoc-ref %build-inputs "unzip")
378 (out (string-append (assoc-ref %outputs "out"))))
379 (invoke unzip source "-d" out)))))
380 (native-inputs `(("unzip" ,unzip)))
381 (home-page "https://www.oasis-open.org/")
382 (synopsis "ISO 8879 character entities")
383 (description "ISO 8879 character entities that are typically used in
384 the in DocBook SGML DTDs.")
385 (license (license:x11-style "" "See file headers."))))
387 (define-public dblatex
393 (uri (string-append "mirror://sourceforge/dblatex/dblatex/"
394 "dblatex-" version "/dblatex-"
398 "0rp1bc2lgisigscq1i7zxfd2qdaxxxld6khbcxss4pq7fpi9fzkv"))))
399 (build-system python-build-system)
400 ;; TODO: Add xfig/transfig for fig2dev utility
402 `(("texlive" ,(texlive-union (list texlive-amsfonts/patched
403 texlive-latex-anysize
404 texlive-latex-appendix
405 texlive-latex-changebar
406 texlive-latex-colortbl
408 texlive-latex-eso-pic
409 texlive-latex-fancybox
410 texlive-latex-fancyhdr
411 texlive-latex-fancyvrb
413 texlive-latex-footmisc
414 texlive-latex-hyperref
415 texlive-latex-jknapltx
416 texlive-latex-listings
417 texlive-latex-multirow
418 texlive-latex-oberdiek
419 texlive-latex-overpic
420 texlive-latex-pdfpages
421 texlive-latex-subfigure
422 texlive-latex-titlesec
424 texlive-latex-wasysym
428 texlive-fonts-stmaryrd
430 texlive-generic-ifxetex)))
431 ("imagemagick" ,imagemagick) ;for convert
432 ("inkscape" ,inkscape) ;for svg conversion
433 ("docbook" ,docbook-xml)
434 ("libxslt" ,libxslt))) ;for xsltproc
436 `(#:python ,python-2 ;'print' syntax
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
446 #:tests? #f ;no 'test' command
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")
455 ,(map (lambda (input)
456 (string-append (assoc-ref inputs input)
458 '("libxslt" "texlive"
459 "imagemagick" "inkscape"))))
461 (home-page "http://dblatex.sourceforge.net")
462 (synopsis "DocBook to LaTeX Publishing")
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
468 ;; lib/contrib/which is under an X11 license
469 (license license:gpl2+)))
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
478 (package/inherit dblatex
479 (inputs (alist-replace "imagemagick" `(,imagemagick/stable)
480 (package-inputs dblatex))))))
482 (define-public docbook2x
488 (uri (string-append "mirror://sourceforge/docbook2x/docbook2x/"
489 version "/docbook2X-" version ".tar.gz"))
492 "0ifwzk99rzjws0ixzimbvs83x6cxqk1xzmg84wa1p7bs6rypaxs0"))))
493 (build-system gnu-build-system)
495 `(("bash-minimal" ,bash-minimal)
496 ("docbook-xml" ,docbook-xml)
498 ("perl-xml-namespacesupport" ,perl-xml-namespacesupport)
499 ("perl-xml-parser" ,perl-xml-parser)
500 ("perl-xml-sax" ,perl-xml-sax)
501 ("perl-xml-sax-base" ,perl-xml-sax-base)
503 ("xsltproc" ,libxslt)))
506 (modify-phases %standard-phases
507 (add-after 'configure 'patch-sources
508 (lambda* (#:key inputs outputs #:allow-other-keys)
509 ;; Fix failed substitution in config.pl
510 (substitute* "perl/config.pl"
512 (assoc-ref outputs "out")))
513 ;; Fix a failing test (maybe it worked with old texinfo?)
514 (substitute* "test/complete-manuals/at1.xml"
516 "<bridgehead renderas=\"sect2\">"))
517 ;; Patch all the tests use DocBook 4.5
518 (substitute* (find-files "test" "\\.xml$")
519 (("\"-//OASIS//DTD DocBook XML V4\\..+//EN\"")
520 "\"-//OASIS//DTD DocBook XML V4.5//EN\"")
521 (("\"http://www\\.oasis-open\\.org/docbook/xml/4\\..+/docbookx.dtd\"")
522 "\"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd\""))
523 ;; Set XML catalogs for tests to pass
524 (setenv "XML_CATALOG_FILES"
525 (string-append (assoc-ref inputs "docbook-xml")
526 "/xml/dtd/docbook/catalog.xml"))))
527 (add-after 'install 'wrap-programs
528 (lambda* (#:key inputs outputs #:allow-other-keys)
529 (let* ((out (assoc-ref outputs "out"))
532 (string-append out "/bin/" p))
533 '("db2x_manxml" "db2x_texixml" "db2x_xsltproc"
534 "docbook2man" "docbook2texi")))
537 (string-append (assoc-ref inputs i)
538 "/lib/perl5/site_perl"))
539 '("perl-xml-namespacesupport"
542 "perl-xml-sax-base")))
544 (list (string-append (assoc-ref inputs "docbook-xml")
545 "/xml/dtd/docbook/catalog.xml"))))
546 (map (lambda (program)
547 (wrap-program program
548 `("PERL5LIB" ":" prefix
550 `("XML_CATALOG_FILES" " " prefix
551 ,xml-catalog-files)))
553 (add-after 'install 'create-symlinks
554 (lambda* (#:key outputs #:allow-other-keys)
555 (let ((out (assoc-ref outputs "out")))
556 ;; Create db2x_* symlinks to satisfy some configure scripts
557 ;; which use these names to differentiate from an older
558 ;; docbook2man script provided by docbook-utils.
560 (symlink prog (string-append out "/bin/db2x_" prog)))
561 '("docbook2man" "docbook2texi"))))))))
562 (home-page "http://docbook2x.sourceforge.net")
563 (synopsis "Convert DocBook to man page and Texinfo format")
565 "docbook2X is a software package that converts DocBook documents into the
566 traditional Unix man page format and the GNU Texinfo format. Notable features
567 include table support for man pages, internationalization support, and easy
568 customization of the output using XSLT.")
569 (license license:expat)))