gnu: docbook-xsl: Disable recursion in string substitution.
[jackhill/guix/guix.git] / gnu / packages / docbook.scm
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 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (gnu packages docbook)
22 #:use-module (gnu packages)
23 #:use-module (gnu packages compression)
24 #:use-module (gnu packages imagemagick)
25 #:use-module (gnu packages inkscape)
26 #:use-module (gnu packages tex)
27 #:use-module (gnu packages python)
28 #:use-module (gnu packages base)
29 #:use-module (gnu packages xml)
30 #:use-module (guix licenses)
31 #:use-module (guix packages)
32 #:use-module (guix download)
33 #:use-module (guix build-system trivial)
34 #:use-module (guix build-system python))
35
36 (define-public docbook-xml
37 (package
38 (name "docbook-xml")
39 (version "4.5")
40 (source (origin
41 (method url-fetch)
42 (uri (string-append "http://www.docbook.org/xml/" version
43 "/docbook-xml-" version ".zip"))
44 (sha256
45 (base32
46 "1d671lcjckjri28xfbf6dq7y3xnkppa910w1jin8rjc35dx06kjf"))))
47 (build-system trivial-build-system)
48 (arguments
49 '(#:builder (begin
50 (use-modules (guix build utils))
51
52 (let* ((unzip
53 (string-append (assoc-ref %build-inputs "unzip")
54 "/bin/unzip"))
55 (source (assoc-ref %build-inputs "source"))
56 (out (assoc-ref %outputs "out"))
57 (dtd (string-append out "/xml/dtd/docbook")))
58 (mkdir-p dtd)
59 (with-directory-excursion dtd
60 (system* unzip source))
61 (substitute* (string-append out "/xml/dtd/docbook/catalog.xml")
62 (("uri=\"")
63 (string-append
64 "uri=\"file://" dtd "/")))))
65 #:modules ((guix build utils))))
66 (native-inputs `(("unzip" ,unzip)))
67 (home-page "http://docbook.org")
68 (synopsis "DocBook XML DTDs for document authoring")
69 (description
70 "DocBook is general purpose XML and SGML document type particularly well
71 suited to books and papers about computer hardware and software (though it is
72 by no means limited to these applications.) This package provides XML DTDs.")
73 (license (x11-style "" "See file headers."))))
74
75 (define-public docbook-xml-4.4
76 (package (inherit docbook-xml)
77 (version "4.4")
78 (source (origin
79 (method url-fetch)
80 (uri (string-append "http://www.docbook.org/xml/" version
81 "/docbook-xml-" version ".zip"))
82 (sha256
83 (base32
84 "141h4zsyc71sfi2zzd89v4bb4qqq9ca1ri9ix2als9f4i3mmkw82"))))))
85
86 (define-public docbook-xml-4.3
87 (package (inherit docbook-xml)
88 (version "4.3")
89 (source (origin
90 (method url-fetch)
91 (uri (string-append "http://www.docbook.org/xml/" version
92 "/docbook-xml-" version ".zip"))
93 (sha256
94 (base32
95 "0r1l2if1z4wm2v664sqdizm4gak6db1kx9y50jq89m3gxaa8l1i3"))))))
96
97 (define-public docbook-xml-4.2
98 (package (inherit docbook-xml)
99 (version "4.2")
100 (source (origin
101 (method url-fetch)
102 (uri (string-append "http://www.docbook.org/xml/" version
103 "/docbook-xml-" version ".zip"))
104 (sha256
105 (base32
106 "18hgwvmywh6a5jh38szjmg3hg2r4v5lb6r3ydc3rd8cp9wg61i5c"))))))
107
108 (define-public docbook-xml-4.1.2
109 (package (inherit docbook-xml)
110 (version "4.1.2")
111 (source (origin
112 (method url-fetch)
113 (uri (string-append "http://www.docbook.org/xml/" version
114 "/docbkx412.zip"))
115 (sha256
116 (base32
117 "0wkp5rvnqj0ghxia0558mnn4c7s3n501j99q2isp3sp0ci069w1h"))))
118 (arguments
119 '(#:modules ((guix build utils))
120 #:builder
121 (begin
122 (use-modules (guix build utils))
123 (let ((source (assoc-ref %build-inputs "source"))
124 (unzip (string-append (assoc-ref %build-inputs "unzip")
125 "/bin/unzip"))
126 (dtd (string-append (assoc-ref %outputs "out")
127 "/xml/dtd/docbook")))
128 (mkdir-p dtd)
129 (zero? (system* unzip source "-d" dtd))))))))
130
131 (define-public docbook-xsl
132 (package
133 (name "docbook-xsl")
134 (version "1.79.1")
135 (source (origin
136 (method url-fetch)
137 (uri (string-append "mirror://sourceforge/docbook/docbook-xsl/"
138 version "/docbook-xsl-" version ".tar.bz2"))
139 ;; Note: If removing all patches, the XZ dependency is no longer needed.
140 (patches (search-patches "docbook-xsl-nonrecursive-string-subst.patch"))
141 (sha256
142 (base32
143 "0s59lihif2fr7rznckxr2kfyrvkirv76r1zvidp9b5mj28p4apvj"))))
144 (build-system trivial-build-system)
145 (arguments
146 `(#:builder (let ((name-version (string-append ,name "-" ,version)))
147 (use-modules (guix build utils))
148
149 (let* ((bzip2 (assoc-ref %build-inputs "bzip2"))
150 (xz (assoc-ref %build-inputs "xz"))
151 (tar (assoc-ref %build-inputs "tar"))
152 (source (assoc-ref %build-inputs "source"))
153 (out (assoc-ref %outputs "out"))
154 (xsl (string-append out "/xml/xsl")))
155 (setenv "PATH" (string-append bzip2 "/bin" ":" xz "/bin"))
156 (system* (string-append tar "/bin/tar") "xvf" source)
157
158 (mkdir-p xsl)
159 (copy-recursively name-version
160 (string-append xsl "/" name-version))
161
162 (substitute* (string-append xsl "/" name-version "/catalog.xml")
163 (("rewritePrefix=\"./")
164 (string-append "rewritePrefix=\"file://" xsl "/"
165 name-version "/")))))
166 #:modules ((guix build utils))))
167 (native-inputs `(("bzip2" ,bzip2)
168 ("xz" ,xz)
169 ("tar" ,tar)))
170 (home-page "http://docbook.org")
171 (synopsis "DocBook XSL style sheets for document authoring")
172 (description
173 "This package provides XSL style sheets for DocBook.")
174 (license (x11-style "" "See 'COPYING' file."))))
175
176 (define-public dblatex
177 (package
178 (name "dblatex")
179 (version "0.3.9")
180 (source (origin
181 (method url-fetch)
182 (uri (string-append "mirror://sourceforge/dblatex/dblatex/"
183 "dblatex-" version "/dblatex-"
184 version ".tar.bz2"))
185 (sha256
186 (base32
187 "0pdizc5rjywwzxa1qqhdmba5zr35pbmdwbysalsid7xw87w3kq06"))
188 (patches (search-patches "dblatex-remove-multirow.patch"))))
189 (build-system python-build-system)
190 ;; TODO: Add xfig/transfig for fig2dev utility
191 (inputs
192 `(("texlive" ,(texlive-union (list texlive-latex-amsfonts
193 texlive-latex-anysize
194 texlive-latex-appendix
195 texlive-latex-changebar
196 texlive-latex-colortbl
197 texlive-latex-eepic
198 texlive-latex-eso-pic
199 texlive-latex-fancybox
200 texlive-latex-fancyhdr
201 texlive-latex-fancyvrb
202 texlive-latex-float
203 texlive-latex-footmisc
204 texlive-latex-hyperref
205 texlive-latex-jknapltx
206 texlive-latex-listings
207 texlive-latex-multirow
208 texlive-latex-oberdiek
209 texlive-latex-overpic
210 texlive-latex-pdfpages
211 texlive-latex-subfigure
212 texlive-latex-titlesec
213 texlive-latex-url
214 texlive-latex-wasysym
215
216 texlive-fonts-amsfonts
217 texlive-fonts-ec
218 texlive-fonts-rsfs
219 texlive-fonts-stmaryrd
220
221 texlive-generic-ifxetex)))
222 ("imagemagick" ,imagemagick) ;for convert
223 ("inkscape" ,inkscape) ;for svg conversion
224 ("docbook" ,docbook-xml)
225 ("libxslt" ,libxslt))) ;for xsltproc
226 (arguments
227 `(#:python ,python-2 ;'print' syntax
228 ;; Using setuptools causes an invalid "package_base" path in
229 ;; out/bin/.dblatex-real due to a missing leading '/'. This is caused
230 ;; by dblatex's setup.py stripping the root path when creating the
231 ;; script. (dblatex's setup.py still uses distutils and thus has to
232 ;; create the script by itself. The feature for creating scripts is one
233 ;; of setuptools' features.)
234 ;; See this thread for details:
235 ;; https://lists.gnu.org/archive/html/guix-devel/2016-12/msg00030.html
236 #:use-setuptools? #f
237 #:tests? #f ;no 'test' command
238 #:phases
239 (alist-cons-after
240 'wrap 'set-path
241 (lambda* (#:key inputs outputs #:allow-other-keys)
242 (let ((out (assoc-ref outputs "out")))
243 ;; dblatex executes helper programs at runtime.
244 (wrap-program (string-append out "/bin/dblatex")
245 `("PATH" ":" prefix
246 ,(map (lambda (input)
247 (string-append (assoc-ref inputs input)
248 "/bin"))
249 '("libxslt" "texlive"
250 "imagemagick" "inkscape"))))))
251 %standard-phases)))
252 (home-page "http://dblatex.sourceforge.net")
253 (synopsis "DocBook to LaTeX Publishing")
254 (description
255 "DocBook to LaTeX Publishing transforms your SGML/XML DocBook documents
256 to DVI, PostScript or PDF by translating them in pure LaTeX as a first
257 process. MathML 2.0 markups are supported too. It started as a clone of
258 DB2LaTeX.")
259 ;; lib/contrib/which is under an X11 license
260 (license gpl2+)))