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