gnu: Add m4rie.
[jackhill/guix/guix.git] / gnu / packages / ebook.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015, 2016 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2016, 2018 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2016, 2017 Alex Griffin <a@ajgrf.com>
5 ;;; Copyright © 2017, 2019 Brendan Tildesley <mail@brendan.scot>
6 ;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
7 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
15 ;;;
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
20 ;;;
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24 (define-module (gnu packages ebook)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix git-download)
29 #:use-module (guix build-system gnu)
30 #:use-module (gnu packages)
31 #:use-module (guix build-system python)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages curl)
35 #:use-module (gnu packages databases)
36 #:use-module (gnu packages fonts)
37 #:use-module (gnu packages fontutils)
38 #:use-module (gnu packages freedesktop)
39 #:use-module (gnu packages fribidi)
40 #:use-module (gnu packages gtk)
41 #:use-module (gnu packages gnome)
42 #:use-module (gnu packages glib)
43 #:use-module (gnu packages icu4c)
44 #:use-module (gnu packages image)
45 #:use-module (gnu packages javascript)
46 #:use-module (gnu packages libusb)
47 #:use-module (gnu packages pdf)
48 #:use-module (gnu packages pkg-config)
49 #:use-module (gnu packages python)
50 #:use-module (gnu packages python-web)
51 #:use-module (gnu packages python-xyz)
52 #:use-module (gnu packages qt)
53 #:use-module (gnu packages serialization)
54 #:use-module (gnu packages sqlite)
55 #:use-module (gnu packages time)
56 #:use-module (gnu packages tls)
57 #:use-module (gnu packages web)
58 #:use-module (gnu packages xml)
59 #:use-module (gnu packages xorg))
60
61 (define-public chmlib
62 (package
63 (name "chmlib")
64 (version "0.40")
65 (source (origin
66 (method url-fetch)
67 (uri (string-append "http://www.jedrea.com/chmlib/chmlib-"
68 version ".tar.bz2"))
69 (sha256
70 (base32
71 "18zzb4x3z0d7fjh1x5439bs62dmgsi4c1pg3qyr7h5gp1i5xcj9l"))
72 (patches (search-patches "chmlib-inttypes.patch"))))
73 (build-system gnu-build-system)
74 (home-page "http://www.jedrea.com/chmlib/")
75 (synopsis "Library for CHM files")
76 (description "CHMLIB is a library for dealing with ITSS/CHM format files.")
77 (license license:lgpl2.1+)))
78
79 (define-public calibre
80 (package
81 (name "calibre")
82 (version "3.42.0")
83 (source
84 (origin
85 (method url-fetch)
86 (uri (string-append "http://download.calibre-ebook.com/"
87 version "/calibre-"
88 version ".tar.xz"))
89 (sha256
90 (base32
91 "0ymdhws3cb44p3fb24vln1wx6s7qnb8rr241jvm6qbj5rnp984dm"))
92 ;; Unbundle python2-odfpy.
93 ;; https://lists.gnu.org/archive/html/guix-devel/2015-02/msg00478.html
94 (modules '((guix build utils)))
95 (snippet
96 '(begin
97 (delete-file-recursively "src/odf")
98 (delete-file "resources/viewer.js")
99 (delete-file "resources/viewer.html")
100 (delete-file "resources/mozilla-ca-certs.pem")
101 (delete-file "resources/calibre-portable.bat")
102 (delete-file "resources/calibre-portable.sh")
103 #t))
104 (patches (search-patches "calibre-no-updates-dialog.patch"
105 "calibre-remove-test-bs4.patch" ; TODO: fix test.
106 "calibre-remove-test-sqlite.patch" ; TODO: fix test.
107 "calibre-remove-test-unrar.patch"))))
108 (build-system python-build-system)
109 (native-inputs
110 `(("pkg-config" ,pkg-config)
111 ("qtbase" ,qtbase) ; for qmake
112 ("python2-flake8" ,python2-flake8)
113 ("xdg-utils" ,xdg-utils)))
114 ;; Beautifulsoup3 is bundled but obsolete and not packaged, so just leave it bundled.
115 (inputs
116 `(("chmlib" ,chmlib)
117 ("fontconfig" ,fontconfig)
118 ("font-liberation" ,font-liberation)
119 ("glib" ,glib)
120 ("icu4c" ,icu4c)
121 ("js-mathjax" ,js-mathjax)
122 ("libmtp" ,libmtp)
123 ("libpng" ,libpng)
124 ("libusb" ,libusb)
125 ("openssl" ,openssl)
126 ("optipng" ,optipng)
127 ("podofo" ,podofo)
128 ("poppler" ,poppler)
129 ("python" ,python-2)
130 ("python2-apsw" ,python2-apsw)
131 ("python2-chardet" ,python2-chardet)
132 ("python2-cssselect" ,python2-cssselect)
133 ("python2-css-parser" ,python2-css-parser)
134 ("python2-dateutil" ,python2-dateutil)
135 ("python2-dbus" ,python2-dbus)
136 ("python2-dnspython" ,python2-dnspython)
137 ("python2-dukpy" ,python2-dukpy)
138 ("python2-feedparser" ,python2-feedparser)
139 ("python2-html2text" ,python2-html2text)
140 ("python2-html5-parser" ,python2-html5-parser)
141 ("python2-html5lib" ,python2-html5lib)
142 ("python2-lxml" ,python2-lxml)
143 ("python2-markdown" ,python2-markdown)
144 ("python2-mechanize" ,python2-mechanize)
145 ;; python2-msgpack is needed for the network content server to work.
146 ("python2-msgpack" ,python2-msgpack)
147 ("python2-netifaces" ,python2-netifaces)
148 ("python2-odfpy" ,python2-odfpy)
149 ("python2-pillow" ,python2-pillow)
150 ("python2-psutil" ,python2-psutil)
151 ("python2-pygments" ,python2-pygments)
152 ("python2-pyqt" ,python2-pyqt)
153 ("python2-sip" ,python2-sip)
154 ("python2-regex" ,python2-regex)
155 ("sqlite" ,sqlite)))
156 (arguments
157 `(#:python ,python-2
158 ;; Calibre is using setuptools by itself, but the setup.py is not
159 ;; compatible with the shim wrapper (taken from pip) we are using.
160 #:use-setuptools? #f
161 #:phases
162 (modify-phases %standard-phases
163 (add-after 'unpack 'patch-source
164 (lambda _
165 (substitute* "src/calibre/linux.py"
166 ;; We can't use the uninstaller in Guix. Don't build it.
167 (("self\\.create_uninstaller()") ""))
168 #t))
169 (add-after 'unpack 'dont-load-remote-icons
170 (lambda _
171 (substitute* "setup/plugins_mirror.py"
172 (("href=\"//calibre-ebook.com/favicon.ico\"")
173 "href=\"favicon.ico\""))
174 #t))
175 (add-before 'build 'configure
176 (lambda* (#:key inputs outputs #:allow-other-keys)
177 (let ((podofo (assoc-ref inputs "podofo"))
178 (pyqt (assoc-ref inputs "python2-pyqt"))
179 (out (assoc-ref outputs "out")))
180 (substitute* "setup/build_environment.py"
181 (("sys.prefix") (string-append "'" pyqt "'")))
182 (substitute* "src/calibre/ebooks/pdf/pdftohtml.py"
183 (("PDFTOHTML = 'pdftohtml'")
184 (string-append "PDFTOHTML = \"" (assoc-ref inputs "poppler")
185 "/bin/pdftohtml\"")))
186
187 ;; Calibre thinks we are installing desktop files into a home
188 ;; directory, but here we butcher the script in to installing
189 ;; to calibres /share directory.
190 (setenv "XDG_DATA_HOME" (string-append out "/share"))
191 (substitute* "src/calibre/linux.py"
192 (("'~/.local/share'") "''"))
193
194 (setenv "PODOFO_INC_DIR" (string-append podofo "/include/podofo"))
195 (setenv "PODOFO_LIB_DIR" (string-append podofo "/lib"))
196 ;; This informs the tests we are a continuous integration
197 ;; environment and thus have no networking.
198 (setenv "CI" "true")
199 ;; The Qt test complains about being unable to load all image plugins, and I
200 ;; notice the available plugins list it shows lacks 'svg'. Adding qtsvg doesn't
201 ;; fix it, so I'm not sure how to fix it. TODO: Fix test and remove this.
202 (setenv "SKIP_QT_BUILD_TEST" "true")
203 #t)))
204 (add-after 'build 'build-extra
205 (lambda* (#:key inputs #:allow-other-keys)
206 (invoke "python2" "setup.py" "mathjax""--system-mathjax"
207 "--path-to-mathjax" (string-append
208 (assoc-ref inputs "js-mathjax")
209 "/share/javascript/mathjax"))
210 (invoke "python2" "setup.py" "rapydscript")))
211 (add-after 'install 'install-man-pages
212 (lambda* (#:key outputs #:allow-other-keys)
213 (copy-recursively
214 "man-pages"
215 (string-append (assoc-ref outputs "out") "/share/man"))
216 #t))
217 ;; The font TTF files are used in some miscellaneous tests, so we
218 ;; unbundle them here to avoid patching the tests.
219 (add-after 'install 'unbundle-font-liberation
220 (lambda* (#:key inputs outputs #:allow-other-keys)
221 (let ((font-dest (string-append (assoc-ref outputs "out")
222 "/share/calibre/fonts/liberation"))
223 (font-src (string-append (assoc-ref inputs "font-liberation")
224 "/share/fonts/truetype")))
225 (delete-file-recursively font-dest)
226 (symlink font-src font-dest))
227 #t)))))
228 (home-page "http://calibre-ebook.com/")
229 (synopsis "E-book library management software")
230 (description "Calibre is an e-book library manager. It can view, convert
231 and catalog e-books in most of the major e-book formats. It can also talk
232 to many e-book reader devices. It can go out to the Internet and fetch
233 metadata for books. It can download newspapers and convert them into
234 e-books for convenient reading.")
235 ;; Calibre is largely GPL3+, but includes a number of components covered
236 ;; by other licenses. See COPYRIGHT for more details.
237 (license (list license:gpl3+
238 license:gpl2+
239 license:lgpl2.1+
240 license:lgpl2.1
241 license:bsd-3
242 license:expat
243 license:zpl2.1
244 license:asl2.0
245 license:public-domain
246 license:silofl1.1
247 license:cc-by-sa3.0))))
248
249 (define-public liblinebreak
250 (package
251 (name "liblinebreak")
252 (version "2.1")
253 (source (origin
254 (method url-fetch)
255 (uri (string-append "mirror://sourceforge/vimgadgets"
256 "/liblinebreak/" version
257 "/liblinebreak-" version ".tar.gz"))
258 (sha256
259 (base32
260 "1f36dbq7nc77lln1by2n1yl050g9dc63viawhs3gc3169mavm36x"))))
261 (build-system gnu-build-system)
262 (home-page "http://vimgadgets.sourceforge.net/liblinebreak/")
263 (synopsis "Library for detecting where linebreaks are allowed in text")
264 (description "@code{liblinebreak} is an implementation of the line
265 breaking algorithm as described in Unicode 6.0.0 Standard Annex 14,
266 Revision 26. It breaks lines that contain Unicode characters. It is
267 designed to be used in a generic text renderer.")
268 (license license:zlib)))
269
270 (define-public fbreader
271 (package
272 (name "fbreader")
273 (version "0.99.6")
274 (source (origin
275 (method git-fetch)
276 (uri (git-reference
277 (url "https://github.com/geometer/FBReader")
278 (commit (string-append version "-freebsdport"))))
279 (file-name (git-file-name name version))
280 (sha256
281 (base32
282 "0c0s4silpax74kwfz3dfmzn4lkv6jsyb800vfak166vii0hvbv3d"))
283 (patches (search-patches "fbreader-curl-7.62.patch"))))
284 (build-system gnu-build-system)
285 (inputs
286 `(("curl" ,curl)
287 ("expat" ,expat)
288 ("fribidi" ,fribidi)
289 ("glib" ,glib)
290 ("gtk+-2" ,gtk+-2)
291 ("libjpeg" ,libjpeg)
292 ("liblinebreak" ,liblinebreak)
293 ("libxft" ,libxft)
294 ("sqlite" ,sqlite)
295 ("zlib" ,zlib)))
296 (native-inputs
297 `(("pkg-config" ,pkg-config)))
298 (arguments
299 `(#:tests? #f ; No tests exist.
300 #:make-flags `("CC=gcc" "TARGET_ARCH=desktop" "UI_TYPE=gtk"
301 "TARGET_STATUS=release"
302 ,(string-append "INSTALLDIR="
303 (assoc-ref %outputs "out"))
304 ,(string-append "LDFLAGS=-Wl,-rpath="
305 (assoc-ref %outputs "out") "/lib"))
306 #:phases
307 (modify-phases %standard-phases
308 (delete 'configure)
309 (add-after 'unpack 'fix-install-locations
310 (lambda* (#:key outputs #:allow-other-keys)
311 (let ((out (assoc-ref outputs "out")))
312 (substitute* "fbreader/desktop/Makefile"
313 (("/usr") out))
314 #t))))))
315 (home-page "https://fbreader.org/")
316 (synopsis "E-Book reader")
317 (description "@code{fbreader} is an E-Book reader. It supports the
318 following formats:
319
320 @enumerate
321 @item CHM
322 @item Docbook
323 @item FB2
324 @item HTML
325 @item OEB
326 @item PDB
327 @item RTF
328 @item TCR
329 @item TXT
330 @item XHTML
331 @end enumerate")
332 (license license:gpl2+)))