projects/guix·blob javascript-team · refs

1203 lines · 53.8 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014, 2021-2022 Ludovic Courtès <[email protected]>
3;;; Copyright © 2014 Eric Bavier <[email protected]>
4;;; Copyright © 2016 Mathieu Lirzin <[email protected]>
5;;; Copyright © 2018 Tobias Geerinckx-Rice <[email protected]>
6;;; Copyright © 2020 Marius Bakke <[email protected]>
7;;; Copyright © 2021, 2022, 2023 Maxim Cournoyer <[email protected]>
8;;; Copyright © 2021 Mark H Weaver <[email protected]>
9;;; Copyright © 2021 Efraim Flashner <[email protected]>
10;;; Copyright © 2021 Andrew Whatson <[email protected]>
11;;; Copyright © 2023 Bruno Victal <[email protected]>
12;;; Copyright © 2026 Arun Isaac <[email protected]>
13;;;
14;;; This file is part of GNU Guix.
15;;;
16;;; GNU Guix is free software; you can redistribute it and/or modify it
17;;; under the terms of the GNU General Public License as published by
18;;; the Free Software Foundation; either version 3 of the License, or (at
19;;; your option) any later version.
20;;;
21;;; GNU Guix is distributed in the hope that it will be useful, but
22;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24;;; GNU General Public License for more details.
25;;;
26;;; You should have received a copy of the GNU General Public License
27;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29(define-module (gnu packages docbook)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages autotools)
32 #:use-module (gnu packages bash)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages groff)
35 #:use-module (gnu packages java)
36 #:use-module (gnu packages java-xml)
37 #:use-module (gnu packages imagemagick)
38 #:use-module (gnu packages inkscape)
39 #:use-module (gnu packages tex)
40 #:use-module (gnu packages texinfo)
41 #:use-module (gnu packages perl)
42 #:use-module (gnu packages python)
43 #:use-module (gnu packages python-build)
44 #:use-module (gnu packages python-xyz)
45 #:use-module (gnu packages base)
46 #:use-module (gnu packages web)
47 #:use-module (gnu packages web-browsers)
48 #:use-module (gnu packages xfig)
49 #:use-module (gnu packages xml)
50 #:use-module (guix gexp)
51 #:use-module (guix search-paths)
52 #:use-module (guix utils)
53 #:use-module ((guix licenses) #:prefix license:)
54 #:use-module (guix packages)
55 #:use-module (guix download)
56 #:use-module (guix git-download)
57 #:use-module (guix build-system ant)
58 #:use-module (guix build-system copy)
59 #:use-module (guix build-system gnu)
60 #:use-module (guix build-system pyproject)
61 #:use-module (srfi srfi-26))
62
63;; The fetch-plan, install-plan and phases for docbook-xml tend to vary
64;; between releases therefore we use a “template” package for the
65;; transformations that are common to these packages.
66(define* (docbook-xml-package source version)
67 "Return a package for a docbook-xml package version @var{version} and
68downloading from @var{source}, where @var{version} is a string and
69@var{source} is a @code{<origin>} record."
70 (package
71 (name "docbook-xml")
72 (version version)
73 (source source)
74 (build-system copy-build-system)
75 (arguments
76 (list
77 #:modules '((guix build copy-build-system)
78 (guix build utils)
79 (srfi srfi-26))
80 #:phases
81 #~(modify-phases %standard-phases
82 (add-after 'unpack 'fix-permissions
83 (lambda _
84 ;; These files do not need 0755 permission.
85 (for-each (cut chmod <> #o644) (find-files "."))))
86 (add-before 'install 'patch-catalog-xml
87 (lambda* (#:key inputs #:allow-other-keys)
88 (let ((xsltproc (search-input-file inputs "/bin/xsltproc"))
89 (xslt-file #$(local-file
90 (search-auxiliary-file
91 "xml/patch-catalog-xml.xsl")))
92 ;; Avoid profile conflicts by installing to a
93 ;; versioned path.
94 (dest-path
95 (format #f "~a/xml/docbook/~a" #$output #$version)))
96 (for-each
97 (lambda (catalog)
98 (let ((catalog* (string-append catalog ".new")))
99 (invoke xsltproc "--nonet" "--novalid" "--noout"
100 "--stringparam" "prefix" dest-path
101 "--output" catalog*
102 xslt-file catalog)
103 (rename-file catalog* catalog)))
104 (find-files "." "catalog\\.xml$"))))))))
105 (native-inputs (list libxslt unzip))
106 (home-page "https://docbook.org")
107 (synopsis "DocBook XML DTDs for document authoring")
108 (description
109 "DocBook is general purpose XML and SGML document type particularly well
110suited to books and papers about computer hardware and software (though it is
111by no means limited to these applications.) This package provides XML DTDs.")
112 (license (license:x11-style "" "See file headers."))))
113
114(define-public docbook-xml-5.1
115 (let* ((version "5.1")
116 (source (origin
117 (method url-fetch/zipbomb)
118 (uri (string-append "https://docbook.org/xml/" version
119 "/docbook-v" version "-os.zip"))
120 (sha256
121 (base32
122 "0zqy9prj9wam9dn7v3mgr7ld1axqxdhgrmv06dviwg00ahv43wxk"))
123 (modules '((guix build utils)))
124 (snippet
125 ;; The .zip release mistakenly uses '5.1CR4' instead of
126 ;; '5.1' as intended by <https://docbook.org/xml/5.1/catalog.xml>.
127 #~(substitute* "schemas/catalog.xml"
128 (("5\\.1CR4") #$version)))))
129 (template (docbook-xml-package source version)))
130 (package
131 (inherit template)
132 (arguments
133 (let ((dest-dir (format #f "xml/docbook/~a/" version)))
134 (substitute-keyword-arguments arguments
135 ;; XXX: A default value must be provided otherwise this
136 ;; substitution has no effect.
137 ((#:install-plan _ #f)
138 #~`(("schemas/" #$dest-dir)))))))))
139
140(define-public docbook-xml-5.0.1
141 (let* ((version "5.0.1")
142 (source (origin
143 (method url-fetch)
144 (uri (string-append "https://docbook.org/xml/" version
145 "/docbook-" version ".zip"))
146 (sha256
147 (base32
148 "1iz3hq1lqgnshvlz4j9gvh4jy1ml74qf90vqf2ikbq0h4i2xzybs"))))
149 (template (docbook-xml-package source version)))
150 (package
151 (inherit template)
152 (arguments
153 (let ((dest-dir (format #f "xml/docbook/~a/" version)))
154 (substitute-keyword-arguments arguments
155 ((#:install-plan _ #f)
156 #~`(("catalog.xml" #$dest-dir)
157 ("docbook.nvdl" #$dest-dir)
158 ("dtd" #$dest-dir)
159 ("rng" #$dest-dir)
160 ("sch" #$dest-dir)
161 ("xsd" #$dest-dir)))))))))
162
163;; XXX: docbook-xml-4.x versions use the same #:install-plan but since the
164;; paths are versioned we can't use (inherit …).
165(define* (docbook-xml-4.x-package source version)
166 "Return a template for a docbook-xml-4.x package version @var{version} and
167downloading from @var{source}, where @var{version} is a string and
168@var{source} is a @code{<origin>} record."
169 (let ((base-template (docbook-xml-package source version)))
170 (package
171 (inherit base-template)
172 (arguments
173 (let* ((dest-dir (format #f "xml/docbook/~a/" version)))
174 (substitute-keyword-arguments arguments
175 ((#:phases phases)
176 ;; Some programs, such as kdoctools, instead of using
177 ;; XML_CATALOG_FILES, prefer to use cmake to locate
178 ;; the DTDs for docbook-xml-4.x packages but
179 ;; since there's no agreed standard as to where these files
180 ;; should be placed, in practice the .cmake files
181 ;; end up searching for paths that are distribution specific.
182 #~(modify-phases #$phases
183 (add-after 'install 'symlink-alternate-path
184 (lambda _
185 ;; kdoctools searches under xml/dtd/docbook/
186 ;; which is the convention used by Nix.
187 (mkdir-p (string-append #$output "/xml/dtd"))
188 (symlink (string-append #$output "/" #$dest-dir)
189 (string-append #$output "/xml/dtd/docbook"))))))
190 ((#:install-plan _ #f)
191 #~`(("./" #$dest-dir
192 #:exclude-regexp ("ChangeLog$"
193 "README$"
194 "docbook\\.cat$"
195 "\\.txt$"))))))))))
196
197(define-public docbook-xml-4.5
198 (let* ((version "4.5")
199 (source (origin
200 (method url-fetch/zipbomb)
201 (uri (string-append "https://docbook.org/xml/" version
202 "/docbook-xml-" version ".zip"))
203 (sha256
204 (base32
205 "1d671lcjckjri28xfbf6dq7y3xnkppa910w1jin8rjc35dx06kjf")))))
206 (docbook-xml-4.x-package source version)))
207
208(define-public docbook-xml-4.4
209 (let* ((version "4.4")
210 (source (origin
211 (method url-fetch/zipbomb)
212 (uri (string-append "https://docbook.org/xml/" version
213 "/docbook-xml-" version ".zip"))
214 (sha256
215 (base32
216 "141h4zsyc71sfi2zzd89v4bb4qqq9ca1ri9ix2als9f4i3mmkw82")))))
217 (docbook-xml-4.x-package source version)))
218
219(define-public docbook-xml-4.3
220 (let* ((version "4.3")
221 (source (origin
222 (method url-fetch/zipbomb)
223 (uri (string-append "https://docbook.org/xml/" version
224 "/docbook-xml-" version ".zip"))
225 (sha256
226 (base32
227 "0r1l2if1z4wm2v664sqdizm4gak6db1kx9y50jq89m3gxaa8l1i3")))))
228 (docbook-xml-4.x-package source version)))
229
230(define-public docbook-xml-4.2
231 (let* ((version "4.2")
232 (source (origin
233 (method url-fetch/zipbomb)
234 (uri (string-append "https://docbook.org/xml/" version
235 "/docbook-xml-" version ".zip"))
236 (sha256
237 (base32
238 "18hgwvmywh6a5jh38szjmg3hg2r4v5lb6r3ydc3rd8cp9wg61i5c")))))
239 (docbook-xml-4.x-package source version)))
240
241(define-public docbook-xml-4.1.2
242 (let* ((version "4.1.2")
243 (source (origin
244 (method url-fetch/zipbomb)
245 (uri (string-append "https://docbook.org/xml/" version
246 "/docbkx412.zip"))
247 (sha256
248 (base32
249 "0wkp5rvnqj0ghxia0558mnn4c7s3n501j99q2isp3sp0ci069w1h"))))
250 (template (docbook-xml-4.x-package source version)))
251 (package
252 (inherit template)
253 (arguments
254 (substitute-keyword-arguments arguments
255 ((#:phases phases)
256 #~(modify-phases #$phases
257 (add-after 'unpack 'copy-catalog-file
258 ;; docbook-xml-4.1.2 is unique in the fact that it doesn't come
259 ;; with a catalog.xml file, requiring it to be generated by hand
260 ;; from the docbook.cat SGML catalog. We could automatically
261 ;; generate it here at the cost of enlarging the package
262 ;; definition with a rudimentary (PEG) parser for the SGML
263 ;; catalog but this is overkill since this file is unlikely to
264 ;; change, therefore we ship a pre-generated catalog.xml.
265 (lambda _
266 (copy-file
267 #$(local-file
268 (search-auxiliary-file
269 "xml/docbook-xml/catalog-4.1.2.xml"))
270 "catalog.xml")))
271 (add-after 'patch-catalog-xml 'add-rewrite-entries
272 (lambda* (#:key inputs #:allow-other-keys)
273 (let ((xmlcatalog (search-input-file inputs
274 "/bin/xmlcatalog"))
275 (dtd-path (format #f "~a/xml/docbook/~a"
276 #$output #$version)))
277 (for-each
278 (lambda (type)
279 (invoke xmlcatalog "--noout"
280 "--add" type
281 "http://www.oasis-open.org/docbook/xml/4.1.2/"
282 (string-append "file:" dtd-path "/")
283 "catalog.xml"))
284 (list "rewriteSystem" "rewriteURI")))))))))
285 (native-inputs
286 (modify-inputs native-inputs
287 (prepend libxml2))))))
288
289(define-public docbook-mathml-1.0
290 (package
291 (name "docbook-mathml")
292 (version "1.0")
293 (source (origin
294 (method url-fetch)
295 (uri
296 (string-append "https://www.oasis-open.org/docbook/xml/mathml/"
297 version "/dbmathml.dtd"))
298 (sha256
299 (base32
300 "10vmyl29j829w4xn928rznh163pf47gyzbbjjwqrbg2bidfnk7vp"))))
301 (build-system copy-build-system)
302 (arguments
303 (let ((target (format #f "xml/docbook/mathml/~a/" version)))
304 (list
305 #:modules '((guix build copy-build-system)
306 (guix build utils)
307 (sxml simple)
308 (srfi srfi-1))
309 #:phases
310 #~(modify-phases %standard-phases
311 (add-before 'install 'generate-catalog.xml
312 (lambda _
313 (let ((store-uri (string-append "file:"
314 #$output "/"
315 #$target "dbmathml.dtd")))
316 (call-with-output-file "catalog.xml"
317 (lambda (port)
318 (sxml->xml
319 `(*TOP*
320 (*PI* xml "version='1.0'")
321 (catalog (@ (xmlns "urn:oasis:names:tc:entity:xmlns:xml:catalog"))
322 (public (@ (publicId "-//OASIS//DTD DocBook MathML Module V1.0//EN")
323 (uri ,store-uri)))
324 ,@(map
325 (lambda (scheme)
326 `(system
327 (@ (systemId
328 ,(string-append scheme
329 "://www.oasis-open.org/docbook/xml/"
330 "mathml/1.0/dbmathml.dtd"))
331 (uri ,store-uri))))
332 '("http" "https"))))
333 port)))))))
334 #:install-plan
335 #~`(("catalog.xml" #$target)
336 ("dbmathml.dtd" #$target)))))
337 (propagated-inputs
338 ;; These must be propagated for the package to make sense.
339 ;; TODO: Package MathML2 DTD and propagate it as well.
340 (list docbook-xml-4.1.2))
341 (home-page
342 "https://www.oasis-open.org/docbook/xml/mathml/1.0/index.1.shtml")
343 (synopsis "MathML support for DocBook XML V4.1.2")
344 (description "The DocBook MathML Module is an extension to DocBook XML
345V4.1.2 that adds support for MathML in equation markup.")
346 (license (license:non-copyleft "" "See file headers."))))
347
348(define-public docbook-xml docbook-xml-5.1)
349
350;;; There's an issue in docbook-xsl 1.79.2 that causes manpages to be
351;;; generated incorrectly and embed raw nroff syntax such as '.PP' when there
352;;; is a namespace/non-namespace mismatch between the sources and the
353;;; stylesheets used (see:
354;;; https://github.com/docbook/xslt10-stylesheets/issues/109).
355(define-public docbook-xsl
356 (let ((commit "fe16c90013b64e316c3e21ef92d1e8813c10f88c")
357 (revision "0")
358 (base-version "1.79.2"))
359 (package
360 (name "docbook-xsl")
361 (version (git-version base-version revision commit))
362 (source (origin
363 (method git-fetch)
364 (uri (git-reference
365 (url "https://github.com/docbook/xslt10-stylesheets")
366 (commit commit)))
367 (file-name (git-file-name name version))
368 (modules '((guix build utils)))
369 (snippet
370 #~(begin
371 ;; Multiple .jar files are bundled with the sources.
372 (for-each delete-file
373 (find-files "." "\\.jar$"))
374 ;; Do not build webhelp files, as they require a Saxon from
375 ;; 2005, which is not packaged in Guix.
376 (substitute* "xsl/Makefile"
377 ((" webhelp") ""))))
378 (sha256
379 (base32
380 "1bl8dwrcy7skrlh80fpsmiw045bv2j0aym231ikcv3hvm2pi98dj"))))
381 (build-system gnu-build-system)
382 (arguments
383 (list
384 #:make-flags #~(list "XSLTENGINE=xsltproc")
385 #:modules '((guix build gnu-build-system)
386 (guix build utils)
387 (sxml simple))
388 #:phases
389 #~(let ((dest-path (format #f "~a/xml/xsl/~a-~a"
390 #$output #$name #$version)))
391 (modify-phases %standard-phases
392 (replace 'configure
393 (lambda _
394 ;; The build systems insist on a ~/.xmlc, and it is simpler to
395 ;; create a dummy config file than to patch it into
396 ;; submission.
397 (setenv "HOME" "/tmp")
398 (call-with-output-file "/tmp/.xmlc"
399 (lambda (port)
400 (sxml->xml
401 '(*TOP*
402 (*PI* xml "version='1.0'")
403 (config
404 (java (@ (xml:id "bigmem"))
405 (java-options (@ (name "Xmx512m"))))
406 (xsltproc (@ (xml:id "xsltproc")
407 (exec "xsltproc")))
408 (xmllint (@ (xml:id "xmllint")
409 (exec "xmllint")))))
410 port)))))
411 (add-before 'install 'generate-catalog.xml
412 (lambda* (#:key make-flags #:allow-other-keys)
413 (apply invoke "make" "-C" "xsl" "catalog.xml" make-flags)))
414 (add-after 'generate-catalog.xml 'patch-catalog.xml
415 ;; Note: URI resolutions are not recursive.
416 ;; A rewrite rule from:
417 ;; 'http://docbook.sourceforge.net/release/xsl-ns/'
418 ;; to
419 ;; 'http://docbook.sourceforge.net/release/xsl/'
420 ;; will not trigger the rewrite rule that ultimately
421 ;; remaps to a /gnu/store URI, as can be seen by
422 ;; invoking:
423 ;; $ xmlcatalog "" \
424 ;; 'http://docbook.sourceforge.net/release/xsl-ns/current/'
425 ;; http://docbook.sourceforge.net/release/xsl/current/
426 ;; $ xmlcatalog "" \
427 ;; 'http://docbook.sourceforge.net/release/xsl/current/'
428 ;; file:/gnu/store/…/xml/xsl/…
429 ;;
430 ;; See XML Catalog specification, item 7.2.2. for
431 ;; details.
432 (lambda* (#:key inputs #:allow-other-keys)
433 (let ((xmlcatalog (search-input-file inputs
434 "/bin/xmlcatalog"))
435 (catalog-file "xsl/catalog.xml")
436 (store-uri (string-append "file:" dest-path "/")))
437 ;; Remove /snapshot/ references.
438 (for-each
439 (lambda (scheme)
440 (invoke xmlcatalog "--noout"
441 "--del"
442 (string-append
443 scheme
444 "://cdn.docbook.org/release/xsl/snapshot/")
445 catalog-file))
446 (list "http" "https"))
447 ;; Rewrite both http:// and https:// URIs.
448 (for-each
449 (lambda (path)
450 (for-each
451 (lambda (scheme)
452 (for-each
453 (lambda (entry-type)
454 (let ((uri (string-append scheme "://" path)))
455 (invoke xmlcatalog "--noout"
456 "--add" entry-type uri store-uri
457 catalog-file)))
458 (list "rewriteSystem" "rewriteURI")))
459 (list "http" "https")))
460 (list #$(format #f "cdn.docbook.org/release/xsl/~a/"
461 base-version)
462 "cdn.docbook.org/release/xsl/current/"
463 ;; Re-add the no longer present compatibility entries for
464 ;; v.1.79.1 or earlier URIs.
465 "docbook.sourceforge.net/release/xsl/current/"
466 ;; Originally the
467 ;; "http://docbook.sourceforge.net/release/xsl/"
468 ;; URI referred to the non-namespaced docbook-xsl,
469 ;; with its namespaced version using a URI differing in
470 ;; the path component as '…/xsl-ns/'.
471 ;; At some point the namespaced version was made the
472 ;; canonical docbook-xsl package whilst preserving the
473 ;; original URI.
474 ;;
475 ;; For compatibility with XML files that still specify
476 ;; the legacy namespaced docbook-xsl URIs we re-add them
477 ;; here.
478 "docbook.sourceforge.net/release/xsl-ns/current/")))))
479 (replace 'install
480 (lambda _
481 (let ((select-rx (make-regexp
482 "(\\.xml$|\\.xsl$|\\.dtd$|\\.ent$)")))
483 ;; Install catalog.
484 (chdir "xsl")
485 (install-file "catalog.xml" dest-path)
486 (install-file "VERSION.xsl" dest-path)
487 ;; Install style sheets.
488 (for-each
489 (lambda (dir)
490 (for-each (lambda (f)
491 (install-file
492 f
493 (string-append dest-path "/" (dirname f))))
494 (find-files dir select-rx)))
495 '("assembly" "common" "eclipse" "epub" "epub3" "fo"
496 "highlighting" "html" "htmlhelp" "javahelp" "lib"
497 "manpages" "params" "profiling" "roundtrip"
498 "template" "website"
499 "xhtml" "xhtml-1_1" "xhtml5")))))))))
500 (native-inputs (list docbook-xml-4.4 ; for tests
501 libxml2
502 libxslt
503 perl
504 perl-xml-xpath))
505 (home-page "https://docbook.org")
506 (synopsis "DocBook XSL style sheets for document authoring")
507 (description
508 "This package provides XSL style sheets for DocBook.")
509 (license (license:x11-style "" "See 'COPYING' file.")))))
510
511(define-public docbook-xsltng
512 ;; docbook-xsltng 1.4.0 is the last version that does not depend on
513 ;; org.xmlresolver.
514 (package
515 (name "docbook-xsltng")
516 ;; When updating this package, also update the gitref in the build phase.
517 (version "1.4.0")
518 (source (origin
519 (method git-fetch)
520 (uri (git-reference
521 (url "https://codeberg.org/DocBook/xslTNG")
522 ;; The Codeberg repo does not have the tag for the 1.4.0
523 ;; release; only the older GitHub repo does.
524 (commit "f5c8bd9930d75191d029a3f01d3b58d8bb873551")))
525 (file-name (git-file-name name version))
526 (sha256
527 (base32
528 "0assl9p52lhrscyd47j1dq9r48j6d8jcl4a75350x5d20qc5f6yy"))
529 (snippet
530 #~(begin
531 ;; Delete bundled CSS and javascript files.
532 (for-each delete-file
533 (list "src/main/web/css/prism.css"
534 "src/main/web/js/prism.js"))))))
535 (build-system ant-build-system)
536 ;; Upstream uses gradle to build and run the tests. Since we don't have a
537 ;; gradle package yet, we translate many of the build steps to scheme. For
538 ;; simplicity, we skip the tests for now.
539 (arguments
540 (list
541 #:tests? #f
542 #:jar-name "docbook-xsltng.jar"
543 #:source-dir "src/main/java"
544 #:modules '((guix build ant-build-system)
545 (guix build utils)
546 (ice-9 match))
547 #:phases
548 #~(modify-phases %standard-phases
549 (add-after 'unpack 'rearrange-sources
550 (lambda _
551 ;; Unify all sources under the same directory tree.
552 (rename-file "buildSrc/src/main/java/org/docbook/xsltng/extensions"
553 "src/main/java/org/docbook/xsltng/extensions")
554 ;; From line 29 of buildSrc/build.gradle
555 (call-with-output-file "src/main/java/org/docbook/xsltng/BuildConfig.java"
556 (lambda (port)
557 (format port
558 "package org.docbook.xsltng;
559
560public final class BuildConfig {
561 public static final String TITLE = \"DocBook xslTNG\";
562 public static final String VERSION = \"~a\";
563 public static final String SAXON_VERSION = \"~a\";
564 private BuildConfig() {}
565}
566"
567 #$version
568 #$(package-version java-saxon-he-10))))
569 ;; We have not packaged com.nwalsh.xslt and
570 ;; org.iso_relax.verifier. Hence we cannot compile these
571 ;; extensions; delete them for now.
572 (substitute* "src/main/java/org/docbook/xsltng/extensions/Register.java"
573 (("config\\.registerExtensionFunction\\(new XInclude\\(\\)\\);")
574 "")
575 (("config\\.registerExtensionFunction\\(new ValidateRNG\\(\\)\\);")
576 ""))
577 (for-each delete-file
578 (list "src/main/java/org/docbook/xsltng/extensions/ValidateRNG.java"
579 "src/main/java/org/docbook/xsltng/extensions/XInclude.java"))))
580 (add-after 'build 'build-stylesheets
581 (lambda* (#:key inputs #:allow-other-keys)
582 ;; Build XSLT stylesheets using saxon.
583 (let ((saxon (search-input-file inputs "share/java/saxon-he.jar")))
584 (for-each (match-lambda
585 ((source stylesheet output params ...)
586 (format #t "SAXON ~a + ~a -> ~a ~a~%"
587 source stylesheet output params)
588 (apply invoke
589 "java"
590 "-classpath" saxon
591 "net.sf.saxon.Transform"
592 (string-append "-s:" source)
593 (string-append "-xsl:" stylesheet)
594 (string-append "-o:" output)
595 params)))
596 `(("src/main/xslt/param.xsl"
597 "tools/parameter-maps.xsl"
598 "src/main/xslt/parameter-maps.xsl")
599 ("tools/version.xsl"
600 "tools/version.xsl"
601 "src/main/xslt/VERSION.xsl"
602 ,(string-append "version=" #$version)
603 ;; When updating this package, update this gitref
604 ;; to the commit corresponding to the release.
605 "gitref=f5c8bd993")
606 ,@(map (lambda (xml)
607 (list xml
608 "tools/xform-locale.xsl"
609 (string-append "src/main/xslt/locale/"
610 (basename xml))))
611 (find-files "src/main/locales/locale"
612 "\\.xml$")))))
613 ;; Substitute in TITLE and VERSION.
614 (substitute* (append (find-files "src/main/web/css" "\\.css$")
615 (find-files "src/main/web/js" "\\.js$"))
616 (("@@TITLE@@") "DocBook xslTNG")
617 (("@@VERSION@@") #$version))
618 ;; ;; Generate pygments CSS file.
619 (invoke "python3" "tools/generate-pygments.py"
620 "--version" #$version
621 "--title" "DocBook xslTNG"
622 "--output" "src/main/web/css/pygments.css")))
623 (add-after 'install 'install-bin
624 (lambda* (#:key inputs outputs #:allow-other-keys)
625 ;; Install XSLT stylesheets.
626 (copy-recursively "src/main/xslt"
627 (string-append #$output
628 "/xml/xsl/docbook-xsltng-"
629 #$version))
630 ;; Install CSS and javascript files.
631 (copy-recursively "src/main/web"
632 (string-append #$output "/share/web"))
633 ;; Configure paths in docbook script.
634 (let ((bin (string-append #$output "/bin")))
635 (mkdir-p bin)
636 (substitute* "src/bin/docbook.py"
637 ;; Path to java
638 (("self._java = None")
639 (string-append "self._java = \""
640 (search-input-file inputs "bin/java")
641 "\""))
642 ;; Path to docbook.xsl
643 (("\\{self\\.root\\}/xslt/docbook.xsl")
644 (search-input-file outputs
645 (string-append "xml/xsl/docbook-xsltng-"
646 #$version
647 "/docbook.xsl")))
648 ;; Path to web resources
649 (("\\{self\\.root\\}/resources")
650 (search-input-directory outputs "share/web"))
651 ;; Disable computing classpath.
652 (("docbook\\.compute_dependencies\\(\\)") "")
653 ;; Set classpath explicitly.
654 (("cp = self\\.classpath\\(\\)")
655 (let ((docbook-xsltng
656 (search-input-file outputs
657 "share/java/docbook-xsltng.jar"))
658 (metadata-extractor
659 (search-input-file inputs
660 "share/java/metadata-extractor.jar"))
661 (saxon
662 (search-input-file inputs
663 "share/java/saxon-he.jar")))
664 (string-append "cp = \""
665 (list->search-path-as-string
666 (list docbook-xsltng
667 metadata-extractor
668 saxon)
669 ":")
670 "\"")))
671 ;; Disable references to org.xmlresolver dependencies that
672 ;; have not been packaged yet.
673 (("\"-x:org.xmlresolver.tools.ResolvingXMLReader\",") "")
674 (("\"-y:org.xmlresolver.tools.ResolvingXMLReader\",") "")
675 (("\"-r:org.xmlresolver.Resolver\",") ""))
676 ;; Install docbook script.
677 (copy-file "src/bin/docbook.py"
678 (string-append bin "/docbook"))
679 ;; Wrap docbook script in python environment.
680 (wrap-program (string-append bin "/docbook")
681 `("GUIX_PYTHONPATH" ":" prefix
682 (,(getenv "GUIX_PYTHONPATH"))))))))))
683 (inputs
684 (list bash-minimal
685 java-metadata-extractor
686 java-saxon-he-10
687 python
688 python-click
689 python-pygments))
690 (home-page "https://xsltng.docbook.org/")
691 (synopsis "XSLT 3.0 stylesheets for DocBook")
692 (description "This package provides XSLT 3.0 stylesheets for DocBook.
693They transform DocBook XML documents into clean, semantically rich HTML5. CSS
694stylesheet and javascript suitable for online presentation is included.
695Producing high quality print output with a paged media capable CSS processor
696is also supported.")
697 (license license:expat)))
698
699(define-public docbook-dsssl
700 (package
701 (name "docbook-dsssl")
702 (version "1.79")
703 (source (origin
704 (method url-fetch)
705 (uri (string-append "mirror://sourceforge/docbook/"
706 name "/" version "/"
707 name "-" version ".tar.bz2"))
708 (sha256
709 (base32
710 "1g72y2yyc2k89kzs0lvrb9n7hjayw1hdskfpplpz97pf1c99wcig"))
711 (snippet
712 #~(begin
713 (chmod "bin/collateindex.pl" #o755)
714 ;; Remove empty directories.
715 (rmdir "doc")
716 (rmdir "docsrc")))))
717 (build-system copy-build-system)
718 (outputs '("out" "doc"))
719 (arguments
720 (list
721 #:install-plan
722 #~`(("./" "sgml/dtd/docbook/" #:exclude ("bin"))
723 ("bin/collateindex.pl" "bin/")
724 ("bin/collateindex.pl.1" "share/man/man1/")
725 (#$(this-package-input "docbook-dsssl-doc") "./" #:output "doc"))))
726 (inputs
727 (list perl docbook-dsssl-doc))
728 (home-page "https://docbook.org/")
729 (synopsis "DSSSL style sheets for DocBook")
730 (description "This package provides DSSSL style sheets for DocBook.")
731 (license (license:non-copyleft "file:/README"))))
732
733;;; Private variable, used as the 'doc' output of the docbook-dsssl package.
734(define docbook-dsssl-doc
735 (package
736 (name "docbook-dsssl-doc")
737 (version "1.79")
738 (source (origin
739 (method url-fetch)
740 (uri (string-append "mirror://sourceforge/docbook/"
741 name "/" version "/"
742 name "-" version ".tar.bz2"))
743 (sha256
744 (base32
745 "1plp5ngc96pbna4rwglp9glcadnirbm3hlcjb4gjvq1f8biic9lz"))))
746 (build-system copy-build-system)
747 (arguments
748 (list
749 #:install-plan
750 #~`(("doc/" #$(string-append "/share/doc/docbook-dsssl-" version)))))
751 (home-page "https://docbook.org/")
752 (synopsis "DocBook DSSSL style sheets documentation")
753 (description "Documentation for the DocBook DSSSL style sheets.")
754 (license (license:non-copyleft "file:/doc/LEGALNOTICE.htm"))))
755
756(define-public docbook-sgml-4.2
757 (package
758 (name "docbook-sgml")
759 (version "4.2")
760 (source (origin
761 (method url-fetch/zipbomb)
762 (uri (string-append
763 "https://www.oasis-open.org/docbook/sgml/4.2/docbook-"
764 version ".zip"))
765 (sha256
766 (base32
767 "1hrm4qmmzi285bkxkc74lxvjvw2gbl7ycbaxhv31h9rl9g4x5sv7"))))
768 (build-system copy-build-system)
769 (arguments
770 (list
771 #:modules '((guix build copy-build-system)
772 (guix build utils)
773 (srfi srfi-26))
774 #:install-plan
775 #~`(("./" "sgml/dtd/docbook"
776 #:exclude-regexp ("catalog\\.xml$"
777 "ChangeLog$"
778 "README$"
779 "\\.txt$")))
780 #:phases
781 #~(modify-phases %standard-phases
782 (add-after 'unpack 'fix-permissions
783 (lambda _
784 (for-each (cut chmod <> #o644) (find-files "."))))
785 (add-before 'install 'patch-iso-entities
786 (lambda* (#:key inputs #:allow-other-keys)
787 ;; Reference the ISO 8879 character entities.
788 ;; e.g. "iso-lat1.gml" --> "<iso-entities-dir>/ISOlat1"
789 (let ((iso-entities-dir
790 (assoc-ref %build-inputs "iso-8879-entities")))
791 (substitute* "docbook.cat"
792 (("\"iso-(.*)\\.gml\"" _ name)
793 (string-append "\"" iso-entities-dir "/ISO" name "\"")))))))))
794 (native-inputs
795 (list unzip))
796 (inputs
797 (list iso-8879-entities))
798 (home-page "https://docbook.org")
799 (synopsis "DocBook SGML style sheets for document authoring")
800 (description "This package provides SGML style sheets for DocBook.")
801 (license (license:x11-style "" "See file headers."))))
802
803(define-public docbook-sgml-4.1
804 (package
805 (inherit docbook-sgml-4.2)
806 (version "4.1")
807 (source (origin
808 (method url-fetch/zipbomb)
809 (uri (string-append "https://www.oasis-open.org/docbook/sgml/"
810 version "/docbk41.zip"))
811 (sha256
812 (base32
813 "04b3gp4zkh9c5g9kvnywdkdfkcqx3kjc04j4mpkr4xk7lgqgrany"))))))
814
815(define-public docbook-sgml docbook-sgml-4.1)
816
817(define-public docbook-sgml-3.1
818 (package
819 (inherit docbook-sgml)
820 (version "3.1")
821 (source (origin
822 (method url-fetch/zipbomb)
823 (uri (string-append "https://www.oasis-open.org/docbook/sgml/"
824 version "/docbk31.zip"))
825 (sha256
826 (base32
827 "0f25ch7bywwhdxb1qa0hl28mgq1blqdap3rxzamm585rf4kis9i0"))))))
828
829;;; Private package referenced by docbook-sgml.
830(define iso-8879-entities
831 (package
832 (name "iso-8879-entities")
833 (version "0.0") ;no proper version
834 (source (origin
835 (method url-fetch/zipbomb)
836 (uri "https://www.oasis-open.org/cover/ISOEnts.zip")
837 (sha256
838 (base32
839 "1clrkaqnvc1ja4lj8blr0rdlphngkcda3snm7b9jzvcn76d3br6w"))))
840 (build-system copy-build-system)
841 (native-inputs (list unzip))
842 (home-page "https://www.oasis-open.org/")
843 (synopsis "ISO 8879 character entities")
844 (description "ISO 8879 character entities that are typically used in
845the in DocBook SGML DTDs.")
846 (license (license:x11-style "" "See file headers."))))
847
848(define-public dblatex
849 (package
850 (name "dblatex")
851 (version "0.3.12")
852 (source (origin
853 (method url-fetch)
854 (uri (string-append "mirror://sourceforge/dblatex/dblatex/"
855 "dblatex-" version "/dblatex3-"
856 version ".tar.bz2"))
857 (sha256
858 (base32
859 "0yd09nypswy3q4scri1dg7dr99d7gd6r2dwx0xm81l9f4y32gs0n"))
860 (patches
861 (search-patches "dblatex-importlib.patch"
862 "dblatex-inkscape-1.0.patch"))))
863 (outputs '("out" "doc"))
864 (build-system pyproject-build-system)
865 (arguments
866 (list
867 #:tests? #f ;no test suite
868 #:phases
869 #~(modify-phases %standard-phases
870 (add-after 'unpack 'use-modern-entry-points
871 (lambda _
872 (substitute* "setup.py"
873 (("'build_scripts': BuildScripts,")
874 "")
875 (("scripts=\\['scripts/dblatex'\\],")
876 (format #f "entry_points={'console_scripts':[~s]},"
877 "dblatex = dbtexmf.dblatex.dblatex:main")))
878 (substitute* "lib/dbtexmf/dblatex/dblatex.py"
879 (("main\\(base=\"\"\\)")
880 (format #f "main(base=~s)"
881 (string-append #$output "/share/dblatex"))))))
882 (add-after 'install 'move-doc
883 (lambda _
884 (let ((old (string-append #$output "/share/doc"))
885 (new (string-append #$output:doc "/share/doc")))
886 (mkdir-p (dirname new))
887 (rename-file old new))))
888 (add-after 'wrap 'wrap-dblatex
889 (lambda* (#:key inputs #:allow-other-keys)
890 (let ((path
891 (search-path-as-list
892 '("bin")
893 '#$(map (cut this-package-input <>)
894 (list "libxslt" "imagemagick" "inkscape"
895 "fig2dev" "texlive-bin")))))
896 ;; dblatex executes helper programs at runtime.
897 (wrap-program (string-append #$output "/bin/dblatex")
898 `("PATH" ":" prefix ,path)
899 `("GUIX_TEXMF" prefix (,(getenv "GUIX_TEXMF")))))))
900 (add-after 'check 'check-wrap
901 (lambda* (#:key tests? #:allow-other-keys)
902 (when tests?
903 (unsetenv "GUIX_TEXMF")
904 (invoke/quiet (string-append #$output "/bin/dblatex")
905 "--quiet" "tests/mathml/mmltest2.xml")))))))
906 (native-inputs (list docbook-mathml-1.0 python-setuptools))
907 (inputs
908 (list bash-minimal
909 texlive-bin
910 (texlive-local-tree (list texlive-amsmath
911 texlive-anysize
912 texlive-appendix
913 texlive-auxhook
914 texlive-bigintcalc
915 texlive-bin
916 texlive-bitset
917 texlive-bookmark
918 texlive-changebar
919 texlive-colortbl
920 texlive-courier
921 texlive-eepic
922 texlive-epstopdf-pkg
923 texlive-eso-pic
924 texlive-etexcmds
925 texlive-fancybox
926 texlive-fancyhdr
927 texlive-fancyvrb
928 texlive-float
929 texlive-footmisc
930 texlive-gettitlestring
931 texlive-graphics
932 texlive-graphics-cfg
933 texlive-helvetic
934 texlive-hycolor
935 texlive-hyperref
936 texlive-infwarerr
937 texlive-intcalc
938 texlive-jknapltx
939 texlive-kpathsea
940 texlive-kvdefinekeys
941 texlive-kvoptions
942 texlive-kvsetkeys
943 texlive-l3backend
944 texlive-latex
945 texlive-latex-bin
946 texlive-letltxmacro
947 texlive-listings
948 texlive-ltxcmds
949 texlive-multirow
950 texlive-overpic
951 texlive-pdfescape
952 texlive-pdflscape
953 texlive-pdfpages
954 texlive-pdftexcmds
955 texlive-psnfss
956 texlive-refcount
957 texlive-rerunfilecheck
958 texlive-rsfs
959 texlive-stmaryrd
960 texlive-subfigure
961 texlive-symbol
962 texlive-times
963 texlive-titlesec
964 texlive-tools
965 texlive-uniquecounter
966 texlive-url
967 texlive-wasysym
968 texlive-zapfding))
969 fig2dev
970 imagemagick ;for convert
971 inkscape ;for svg conversion
972 docbook-xml
973 libxslt)) ;for xsltproc
974 ;; lib/dbtexmf/xslt/4xslt.py shows that this package
975 ;; makes use of XML_CATALOG_FILES and also invokes
976 ;; xsltproc.
977 (native-search-paths %libxslt-search-paths)
978 (home-page "https://dblatex.sourceforge.net")
979 (synopsis "DocBook to LaTeX Publishing")
980 (description
981 "DocBook to LaTeX Publishing transforms your SGML/XML DocBook documents
982to DVI, PostScript or PDF by translating them in pure LaTeX as a first
983process. MathML 2.0 markups are supported too. It started as a clone of
984DB2LaTeX.")
985 ;; lib/contrib/which is under an X11 license
986 (license license:gpl2+)))
987
988;; This is a variant of the 'dblatex' package that is not updated often. It
989;; is intended to be used as a native-input at build-time only, e.g. by
990;; 'gtk-doc' for generating package documentation. This allows the main
991;; 'dblatex' and 'imagemagick' packages to be freely updated on the 'master'
992;; branch without triggering an excessive number of rebuilds.
993(define-public dblatex/stable
994 (hidden-package
995 (package/inherit dblatex
996 (inputs (modify-inputs inputs
997 (replace "imagemagick" imagemagick/stable)
998 (replace "inkscape" inkscape/pinned))))))
999
1000(define-public docbook-utils
1001 (package
1002 (name "docbook-utils")
1003 (version "0.6.14")
1004 (source (origin
1005 (method url-fetch)
1006 ;; The original sources are not accessible anymore.
1007 (uri (string-append "http://deb.debian.org/debian/pool/main/"
1008 "d/docbook-utils/docbook-utils_"
1009 version ".orig.tar.gz"))
1010 (sha256
1011 (base32
1012 "1scj5vgw1xz872pq54a89blcxqqm11p90yzv8a9mqq57x27apyj8"))
1013 (patches
1014 (search-patches "docbook-utils-documentation-edits.patch"
1015 "docbook-utils-escape-characters.patch"
1016 "docbook-utils-remove-jade-sp.patch"
1017 "docbook-utils-respect-refentry-for-name.patch"
1018 "docbook-utils-use-date-element.patch"
1019 "docbook-utils-source-date-epoch.patch"))
1020 (modules '((guix build utils)))
1021 (snippet
1022 #~(begin
1023 ;; Patch build system.
1024 (substitute* (find-files "." "\\.(in|am)$")
1025 ;; Do not hard-code SGML_CATALOG_FILES.
1026 ((".*SGML_CATALOG_FILES=/etc/sgml/catalog.*") ""))
1027
1028 ;; Do not override the SGML_CATALOG_FILES environment
1029 ;; variable.
1030 (substitute* "bin/jw.in"
1031 ((".*SGML_CATALOG_FILES=`find.*")
1032 "")
1033 (("SGML_CATALOG_FILES=`echo.*")
1034 ":\n")
1035 (("SGML_CATALOG_FILES=\"\"")
1036 ":")
1037 (("\\bwhich\\b")
1038 "command -v"))
1039
1040 ;; Locate lynx, links or w3m from the PATH, not from
1041 ;; /usr/bin.
1042 (substitute* "backends/txt"
1043 (("CONVERT=/usr/bin/")
1044 "CONVERT=")
1045 (("\\[ -x /usr/bin/([^ ]+) \\]" _ command)
1046 (format #f "command -v ~a > /dev/null" command)))
1047
1048 ;; This forces autoreconf to be invoked, needed for patches
1049 ;; to be effective.
1050 (delete-file "configure")))))
1051 (native-inputs (list autoconf automake libtool))
1052 (build-system gnu-build-system)
1053 ;; Propagated for convenience. All these tools are used at run time to
1054 ;; provide the complete functionality of the docbook-utils commands.
1055 (propagated-inputs
1056 (list texlive-jadetex
1057 docbook-sgml-3.1
1058 docbook-dsssl
1059 openjade
1060 opensp
1061 lynx
1062 perl-sgmls))
1063 (home-page "https://packages.debian.org/sid/docbook-utils")
1064 (synopsis "DocBook converter to other formats")
1065 (description "The docbook-utils package is a collection of utilities
1066intended to ease the use of SGML and XML.
1067@table @command
1068@item jw
1069Convert a SGML DocBook file to other formats such as Hyper Text Markup
1070Language (HTML), Rich Text Format (RTF), PostScript (PS), man, Portable
1071Document Format (PDF), TeX, Texinfo or plain text (txt). It can be used
1072more conveniently via the following wrappers:
1073@table @command
1074@item docbook2dvi
1075Convert a SGML DocBook file to the DVI format.
1076@item docbook2html
1077Convert a SGML DocBook file to an HTML document.
1078@item docbook2man
1079Convert a SGML DocBook file a man page.
1080@item docbook2pdf
1081@itemx docbook2ps
1082@itemx docbook2rtf
1083@itemx docbook2tex
1084@itemx docbook2texi
1085Convert a SGML DocBook file to a PDF/PS/RTF/TeX document.
1086@item docbook2txt
1087Convert a SGML DocBook file to a plain text document.
1088@end table
1089@item sgmldiff
1090Detect the differences in markup between two SGML files.
1091@end table")
1092 (license license:gpl2+)))
1093
1094(define-public docbook2x
1095 (package
1096 (name "docbook2x")
1097 (version "0.8.8")
1098 (source (origin
1099 (method url-fetch)
1100 (uri (string-append "mirror://sourceforge/docbook2x/docbook2x/"
1101 version "/docbook2X-" version ".tar.gz"))
1102 (sha256
1103 (base32
1104 "0ifwzk99rzjws0ixzimbvs83x6cxqk1xzmg84wa1p7bs6rypaxs0"))
1105 (patches
1106 (search-patches "docbook2x-filename-handling.patch"
1107 "docbook2x-fix-synopsis.patch"
1108 "docbook2x-manpage-typo.patch"
1109 "docbook2x-preprocessor-declaration.patch"
1110 "docbook2x-static-datadir-evaluation.patch"
1111 "docbook2x-entity-lt.patch"))
1112 (modules '((guix build utils)))
1113 (snippet
1114 ;; Fix a failing test (maybe it worked with old texinfo?)
1115 #~(begin
1116 (substitute* "test/complete-manuals/at1.xml"
1117 (("<bridgehead>")
1118 "<bridgehead renderas=\"sect2\">"))
1119 ;; Force a new autoreconf run.
1120 (delete-file "configure")))))
1121 (outputs '("out" "doc"))
1122 (build-system gnu-build-system)
1123 (arguments
1124 (list
1125 #:make-flags ''("AM_MAKEINFOHTMLFLAGS=\"--no-split\"")
1126 #:modules '((guix build gnu-build-system)
1127 (guix build utils)
1128 (srfi srfi-26))
1129 #:phases
1130 #~(modify-phases %standard-phases
1131 (add-after 'unpack 'skip-test
1132 (lambda _
1133 (substitute* "test/refentry/Makefile.am"
1134 (("VCR.\\w+") ""))))
1135 (add-before 'build 'clean
1136 (lambda _
1137 (invoke "make" "clean")))
1138 (add-after 'install 'move-doc
1139 (lambda _
1140 (let* ((old (string-append #$output "/share/doc"))
1141 (new (string-append #$output:doc "/share/doc")))
1142 (mkdir-p (dirname new))
1143 (rename-file old new))))
1144 (add-after 'install 'wrap-programs
1145 (lambda* (#:key inputs outputs #:allow-other-keys)
1146 (let ((programs
1147 (map (lambda (p)
1148 (search-input-file outputs
1149 (string-append "bin/" p)))
1150 '("db2x_manxml" "db2x_texixml" "db2x_xsltproc"
1151 "docbook2man" "docbook2texi")))
1152 (perl5lib
1153 (search-path-as-list
1154 '("/lib/perl5/site_perl")
1155 (map (cut assoc-ref inputs <>)
1156 '("perl-xml-namespacesupport"
1157 "perl-xml-parser"
1158 "perl-xml-sax"
1159 "perl-xml-sax-base")))))
1160 (map (lambda (program)
1161 (wrap-program program
1162 `("PERL5LIB" ":" prefix ,perl5lib)))
1163 programs))))
1164 (add-after 'install 'sgml-check
1165 ;; This is not covered by 'make check'.
1166 ;; Test that 'sgml2xml-isoent' works.
1167 (lambda* (#:key tests? #:allow-other-keys)
1168 (when tests?
1169 (invoke "make" "installcheck"))))
1170 (add-after 'install 'create-symlinks
1171 (lambda _
1172 ;; Create db2x_* symlinks to satisfy some configure scripts
1173 ;; which use these names to differentiate from an older
1174 ;; docbook2man script provided by docbook-utils.
1175 (map (lambda (prog)
1176 (symlink prog (string-append #$output
1177 "/bin/db2x_" prog)))
1178 '("docbook2man" "docbook2texi")))))))
1179 (inputs
1180 (list bash-minimal
1181 opensp
1182 perl
1183 perl-xml-namespacesupport
1184 perl-xml-parser
1185 perl-xml-sax
1186 perl-xml-sax-base
1187 texinfo
1188 libxslt))
1189 (native-inputs
1190 (list autoconf automake libtool
1191 tidy-html
1192 ;; For tests
1193 docbook-xml-4.1.2 docbook-xml-4.2 docbook-xml-4.4
1194 groff-minimal libxml2))
1195 (native-search-paths %libxslt-search-paths)
1196 (home-page "https://docbook2x.sourceforge.net")
1197 (synopsis "Convert DocBook to man page and Texinfo format")
1198 (description
1199 "docbook2X is a software package that converts DocBook documents into the
1200traditional Unix man page format and the GNU Texinfo format. Notable features
1201include table support for man pages, internationalization support, and easy
1202customization of the output using XSLT.")
1203 (license license:expat)))