Merge branch 'ungrafting' into staging
[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, 2020 Brendan Tildesley <mail@brendan.scot>
6 ;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
7 ;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
9 ;;; Copyright © 2020 Vinicius Monego <monego@posteo.net>
10 ;;; Copyright © 2020 Zheng Junjie <873216071@qq.com>
11 ;;;
12 ;;; This file is part of GNU Guix.
13 ;;;
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
18 ;;;
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27 (define-module (gnu packages ebook)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix utils)
32 #:use-module (guix git-download)
33 #:use-module (guix build-system cmake)
34 #:use-module (guix build-system gnu)
35 #:use-module (guix build-system meson)
36 #:use-module (guix build-system python)
37 #:use-module (gnu packages)
38 #:use-module (gnu packages compression)
39 #:use-module (gnu packages curl)
40 #:use-module (gnu packages databases)
41 #:use-module (gnu packages file)
42 #:use-module (gnu packages fonts)
43 #:use-module (gnu packages fontutils)
44 #:use-module (gnu packages freedesktop)
45 #:use-module (gnu packages fribidi)
46 #:use-module (gnu packages gcc)
47 #:use-module (gnu packages gettext)
48 #:use-module (gnu packages gtk)
49 #:use-module (gnu packages gnome)
50 #:use-module (gnu packages glib)
51 #:use-module (gnu packages gstreamer)
52 #:use-module (gnu packages icu4c)
53 #:use-module (gnu packages image)
54 #:use-module (gnu packages javascript)
55 #:use-module (gnu packages libusb)
56 #:use-module (gnu packages libreoffice)
57 #:use-module (gnu packages music)
58 #:use-module (gnu packages pdf)
59 #:use-module (gnu packages pkg-config)
60 #:use-module (gnu packages python)
61 #:use-module (gnu packages python-web)
62 #:use-module (gnu packages python-xyz)
63 #:use-module (gnu packages qt)
64 #:use-module (gnu packages serialization)
65 #:use-module (gnu packages sqlite)
66 #:use-module (gnu packages time)
67 #:use-module (gnu packages tls)
68 #:use-module (gnu packages web)
69 #:use-module (gnu packages xml)
70 #:use-module (gnu packages xorg)
71 #:use-module (gnu packages wxwidgets))
72
73 (define-public chmlib
74 (package
75 (name "chmlib")
76 (version "0.40")
77 (source (origin
78 (method url-fetch)
79 (uri (string-append "http://www.jedrea.com/chmlib/chmlib-"
80 version ".tar.bz2"))
81 (sha256
82 (base32
83 "18zzb4x3z0d7fjh1x5439bs62dmgsi4c1pg3qyr7h5gp1i5xcj9l"))
84 (patches (search-patches "chmlib-inttypes.patch"))))
85 (build-system gnu-build-system)
86 (home-page "http://www.jedrea.com/chmlib/")
87 (synopsis "Library for CHM files")
88 (description "CHMLIB is a library for dealing with ITSS/CHM format files.")
89 (license license:lgpl2.1+)))
90
91 (define-public calibre
92 (package
93 (name "calibre")
94 (version "4.18.0")
95 (source
96 (origin
97 (method url-fetch)
98 (uri (string-append "http://download.calibre-ebook.com/"
99 version "/calibre-"
100 version ".tar.xz"))
101 (sha256
102 (base32
103 "0w9pcfvskjh4v00vjw3i6hzrafy863pgsmmqdx4lffip3p856brw"))
104 (modules '((guix build utils)))
105 (snippet
106 '(begin
107 ;; Unbundle python2-odfpy.
108 (delete-file-recursively "src/odf")
109 ;; Disable test that attempts to load it.
110 (substitute* "setup/test.py"
111 ((".*SRC, 'odf'.*")
112 ""))
113
114 ;; Remove unneeded resources.
115 (delete-file "resources/viewer.js")
116 (delete-file "resources/viewer.html")
117 (delete-file "resources/mozilla-ca-certs.pem")
118 (delete-file "resources/calibre-portable.bat")
119 (delete-file "resources/calibre-portable.sh")
120 #t))
121 (patches (search-patches "calibre-no-updates-dialog.patch"
122 "calibre-remove-test-sqlite.patch" ; TODO: fix test.
123 "calibre-remove-test-unrar.patch"))))
124 (build-system python-build-system)
125 (native-inputs
126 `(("pkg-config" ,pkg-config)
127 ("qtbase" ,qtbase) ; for qmake
128 ("python2-flake8" ,python2-flake8)
129 ("xdg-utils" ,xdg-utils)))
130 (inputs
131 `(("chmlib" ,chmlib)
132 ("fontconfig" ,fontconfig)
133 ("font-liberation" ,font-liberation)
134 ("glib" ,glib)
135 ("hunspell" ,hunspell)
136 ("hyphen" ,hyphen)
137 ("icu4c" ,icu4c)
138 ("js-mathjax" ,js-mathjax)
139 ("libmtp" ,libmtp)
140 ("libpng" ,libpng)
141 ("libusb" ,libusb)
142 ("openssl" ,openssl)
143 ("optipng" ,optipng)
144 ("podofo" ,podofo)
145 ("poppler" ,poppler)
146 ("python" ,python-2)
147 ("python2-apsw" ,python2-apsw)
148 ("python2-beautifulsoup4" ,python2-beautifulsoup4)
149 ("python2-chardet" ,python2-chardet)
150 ("python2-cssselect" ,python2-cssselect)
151 ("python2-css-parser" ,python2-css-parser)
152 ("python2-dateutil" ,python2-dateutil)
153 ("python2-dbus" ,python2-dbus)
154 ("python2-dnspython" ,python2-dnspython-1.16)
155 ("python2-dukpy" ,python2-dukpy)
156 ("python2-feedparser" ,python2-feedparser)
157 ("python2-html2text" ,python2-html2text)
158 ("python2-html5-parser" ,python2-html5-parser)
159 ("python2-html5lib" ,python2-html5lib)
160 ("python2-lxml" ,python2-lxml)
161 ("python2-markdown" ,python2-markdown)
162 ("python2-mechanize" ,python2-mechanize)
163 ;; python2-msgpack is needed for the network content server to work.
164 ("python2-msgpack" ,python2-msgpack)
165 ("python2-netifaces" ,python2-netifaces)
166 ("python2-odfpy" ,python2-odfpy)
167 ("python2-pillow" ,python2-pillow)
168 ("python2-psutil" ,python2-psutil)
169 ("python2-pygments" ,python2-pygments)
170 ("python2-pyqtwebengine" ,python2-pyqtwebengine)
171 ("python2-pyqt" ,python2-pyqt)
172 ("python2-sip" ,python2-sip)
173 ("python2-regex" ,python2-regex)
174 ("qtwebengine" ,qtwebengine)
175 ("sqlite" ,sqlite)))
176 (arguments
177 `(#:python ,python-2
178 ;; Calibre is using setuptools by itself, but the setup.py is not
179 ;; compatible with the shim wrapper (taken from pip) we are using.
180 #:use-setuptools? #f
181 #:phases
182 (modify-phases %standard-phases
183 (add-after 'unpack 'patch-source
184 (lambda _
185 (substitute* "src/calibre/linux.py"
186 ;; We can't use the uninstaller in Guix. Don't build it.
187 (("self\\.create_uninstaller()") ""))
188 #t))
189 (add-after 'patch-source-shebangs 'patch-more-shebangs
190 (lambda _
191 ;; Patch various inline shebangs.
192 (substitute* '("src/calibre/gui2/preferences/tweaks.py"
193 "src/calibre/gui2/dialogs/custom_recipes.py"
194 "setup/install.py"
195 "setup/linux-installer.sh")
196 (("#!/usr/bin/env python")
197 (string-append "#!" (which "python")))
198 (("#!/bin/sh")
199 (string-append "#!" (which "sh"))))
200 #t))
201 (add-after 'unpack 'dont-load-remote-icons
202 (lambda _
203 (substitute* "setup/plugins_mirror.py"
204 (("href=\"//calibre-ebook.com/favicon.ico\"")
205 "href=\"favicon.ico\""))
206 #t))
207 (add-before 'build 'configure
208 (lambda* (#:key inputs outputs #:allow-other-keys)
209 (let ((podofo (assoc-ref inputs "podofo"))
210 (pyqt (assoc-ref inputs "python2-pyqt"))
211 (python-sip (assoc-ref inputs "python2-sip"))
212 (out (assoc-ref outputs "out")))
213 (substitute* "setup/build_environment.py"
214 (("= get_sip_dir\\(\\)")
215 (string-append "= '" pyqt "/share/sip'")))
216
217 (substitute* "src/calibre/ebooks/pdf/pdftohtml.py"
218 (("PDFTOHTML = 'pdftohtml'")
219 (string-append "PDFTOHTML = \"" (assoc-ref inputs "poppler")
220 "/bin/pdftohtml\"")))
221
222 ;; Calibre thinks we are installing desktop files into a home
223 ;; directory, but here we butcher the script in to installing
224 ;; to calibres /share directory.
225 (setenv "XDG_DATA_HOME" (string-append out "/share"))
226 (substitute* "src/calibre/linux.py"
227 (("'~/.local/share'") "''"))
228
229 ;; 'python setup.py rapydscript' uses QtWebEngine, which
230 ;; needs to create temporary files in $HOME.
231 (setenv "HOME" "/tmp")
232
233 ;; XXX: QtWebEngine will fail if no fonts are available. This
234 ;; can likely be removed when fontconfig has been patched to
235 ;; include TrueType fonts by default.
236 (symlink (string-append (assoc-ref inputs "font-liberation")
237 "/share/fonts")
238 "/tmp/.fonts")
239
240 (setenv "SIP_BIN" (string-append python-sip "/bin/sip"))
241 (setenv "PODOFO_INC_DIR" (string-append podofo "/include/podofo"))
242 (setenv "PODOFO_LIB_DIR" (string-append podofo "/lib"))
243 ;; This informs the tests we are a continuous integration
244 ;; environment and thus have no networking.
245 (setenv "CI" "true")
246 ;; The Qt test complains about being unable to load all image plugins, and I
247 ;; notice the available plugins list it shows lacks 'svg'. Adding qtsvg doesn't
248 ;; fix it, so I'm not sure how to fix it. TODO: Fix test and remove this.
249 (setenv "SKIP_QT_BUILD_TEST" "true")
250 #t)))
251 (add-after 'build 'build-extra
252 (lambda* (#:key inputs #:allow-other-keys)
253 (invoke "python2" "setup.py" "mathjax""--system-mathjax"
254 "--path-to-mathjax" (string-append
255 (assoc-ref inputs "js-mathjax")
256 "/share/javascript/mathjax"))
257 (invoke "python2" "setup.py" "rapydscript")
258 #t))
259 (add-after 'install 'install-man-pages
260 (lambda* (#:key outputs #:allow-other-keys)
261 (copy-recursively
262 "man-pages"
263 (string-append (assoc-ref outputs "out") "/share/man"))
264 #t))
265 ;; The font TTF files are used in some miscellaneous tests, so we
266 ;; unbundle them here to avoid patching the tests.
267 (add-after 'install 'unbundle-font-liberation
268 (lambda* (#:key inputs outputs #:allow-other-keys)
269 (let ((font-dest (string-append (assoc-ref outputs "out")
270 "/share/calibre/fonts/liberation"))
271 (font-src (string-append (assoc-ref inputs "font-liberation")
272 "/share/fonts/truetype")))
273 (delete-file-recursively font-dest)
274 (symlink font-src font-dest))
275 #t))
276 ;; Make run-time dependencies available to the binaries.
277 (add-after 'wrap 'wrap-program
278 (lambda* (#:key inputs outputs #:allow-other-keys)
279 (let ((out (assoc-ref outputs "out"))
280 (qtwebengine (assoc-ref inputs "qtwebengine")))
281 (with-directory-excursion (string-append out "/bin")
282 (for-each
283 (lambda (binary)
284 (wrap-program binary
285 ;; Make QtWebEngineProcess available.
286 `("QTWEBENGINEPROCESS_PATH" =
287 ,(list (string-append
288 qtwebengine
289 "/lib/qt5/libexec/QtWebEngineProcess")))))
290 ;; Wrap all the binaries shipping with the package, except
291 ;; for the wrappings created during the 'wrap standard
292 ;; phase. This extends existing .calibre-real wrappers
293 ;; rather than create ..calibre-real-real-s. For more
294 ;; information see: https://issues.guix.gnu.org/43249.
295 (find-files "." (lambda (file stat)
296 (not (wrapper? file)))))))
297 #t)))))
298 (home-page "https://calibre-ebook.com/")
299 (synopsis "E-book library management software")
300 (description "Calibre is an e-book library manager. It can view, convert
301 and catalog e-books in most of the major e-book formats. It can also talk
302 to many e-book reader devices. It can go out to the Internet and fetch
303 metadata for books. It can download newspapers and convert them into
304 e-books for convenient reading.")
305 ;; Calibre is largely GPL3+, but includes a number of components covered
306 ;; by other licenses. See COPYRIGHT for more details.
307 (license (list license:gpl3+
308 license:gpl2+
309 license:lgpl2.1+
310 license:lgpl2.1
311 license:bsd-3
312 license:expat
313 license:zpl2.1
314 license:asl2.0
315 license:public-domain
316 license:silofl1.1
317 license:cc-by-sa3.0))))
318
319 (define-public ebook-tools
320 (package
321 (name "ebook-tools")
322 (version "0.2.2")
323 (source
324 (origin
325 (method url-fetch)
326 (uri (string-append "mirror://sourceforge/ebook-tools/ebook-tools/"
327 version "/ebook-tools-" version ".tar.gz"))
328 (sha256
329 (base32
330 "1bi7wsz3p5slb43kj7lgb3r6lb91lvb6ldi556k4y50ix6b5khyb"))))
331 (arguments
332 `(#:tests? #f)) ; No 'test' target
333 (build-system cmake-build-system)
334 (native-inputs
335 `(("pkg-config" ,pkg-config)))
336 (inputs
337 `(("libzip" ,libzip)
338 ("libxml2" ,libxml2)))
339 (home-page "http://ebook-tools.sourceforge.net")
340 (synopsis "Tools and library for dealing with various ebook file formats")
341 (description "This package provides command-line tools and a library for
342 accessing and converting various ebook file formats.")
343 (license license:expat)))
344
345 (define-public liblinebreak
346 (package
347 (name "liblinebreak")
348 (version "2.1")
349 (source (origin
350 (method url-fetch)
351 (uri (string-append "mirror://sourceforge/vimgadgets"
352 "/liblinebreak/" version
353 "/liblinebreak-" version ".tar.gz"))
354 (sha256
355 (base32
356 "1f36dbq7nc77lln1by2n1yl050g9dc63viawhs3gc3169mavm36x"))))
357 (build-system gnu-build-system)
358 (home-page "http://vimgadgets.sourceforge.net/liblinebreak/")
359 (synopsis "Library for detecting where linebreaks are allowed in text")
360 (description "@code{liblinebreak} is an implementation of the line
361 breaking algorithm as described in Unicode 6.0.0 Standard Annex 14,
362 Revision 26. It breaks lines that contain Unicode characters. It is
363 designed to be used in a generic text renderer.")
364 (license license:zlib)))
365
366 (define-public fbreader
367 (package
368 (name "fbreader")
369 (version "0.99.6")
370 (source (origin
371 (method git-fetch)
372 (uri (git-reference
373 (url "https://github.com/geometer/FBReader")
374 (commit (string-append version "-freebsdport"))))
375 (file-name (git-file-name name version))
376 (sha256
377 (base32
378 "0c0s4silpax74kwfz3dfmzn4lkv6jsyb800vfak166vii0hvbv3d"))
379 (patches (search-patches "fbreader-curl-7.62.patch"))))
380 (build-system gnu-build-system)
381 (inputs
382 `(("curl" ,curl)
383 ("expat" ,expat)
384 ("fribidi" ,fribidi)
385 ("glib" ,glib)
386 ("gtk+-2" ,gtk+-2)
387 ("libjpeg" ,libjpeg-turbo)
388 ("liblinebreak" ,liblinebreak)
389 ("libxft" ,libxft)
390 ("sqlite" ,sqlite)
391 ("zlib" ,zlib)))
392 (native-inputs
393 `(("gcc@5" ,gcc-5)
394 ("pkg-config" ,pkg-config)))
395 (arguments
396 `(#:tests? #f ; No tests exist.
397 #:make-flags `("CC=gcc" "TARGET_ARCH=desktop" "UI_TYPE=gtk"
398 "TARGET_STATUS=release"
399 ,(string-append "INSTALLDIR="
400 (assoc-ref %outputs "out"))
401 ,(string-append "LDFLAGS=-Wl,-rpath="
402 (assoc-ref %outputs "out") "/lib"))
403 #:phases
404 (modify-phases %standard-phases
405 (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
406 (lambda* (#:key inputs #:allow-other-keys)
407 ;; Hide the default GCC from CPLUS_INCLUDE_PATH to prevent a header
408 ;; conflict with the GCC provided in native-inputs.
409 (let ((gcc (assoc-ref inputs "gcc")))
410 (setenv "CPLUS_INCLUDE_PATH"
411 (string-join
412 (delete (string-append gcc "/include/c++")
413 (string-split (getenv "CPLUS_INCLUDE_PATH")
414 #\:))
415 ":"))
416 #t)))
417 (delete 'configure)
418 (add-after 'unpack 'fix-install-locations
419 (lambda* (#:key outputs #:allow-other-keys)
420 (let ((out (assoc-ref outputs "out")))
421 (substitute* "fbreader/desktop/Makefile"
422 (("/usr") out))
423 #t))))))
424 (home-page "https://fbreader.org/")
425 (synopsis "E-Book reader")
426 (description "@code{fbreader} is an E-Book reader. It supports the
427 following formats:
428
429 @enumerate
430 @item CHM
431 @item Docbook
432 @item FB2
433 @item HTML
434 @item OEB
435 @item PDB
436 @item RTF
437 @item TCR
438 @item TXT
439 @item XHTML
440 @end enumerate")
441 (license license:gpl2+)))
442
443 (define-public cozy
444 (package
445 (name "cozy")
446 (version "0.7.6")
447 (source
448 (origin
449 (method git-fetch)
450 (uri (git-reference
451 (url "https://github.com/geigi/cozy")
452 (commit version)))
453 (file-name (git-file-name name version))
454 (sha256
455 (base32 "1pg0djhg4p32vxfwf6bfals31zf93m56fx1x4q5jhhdwmll7xl6w"))))
456 (build-system meson-build-system)
457 (arguments
458 `(#:glib-or-gtk? #t
459 #:phases
460 (modify-phases %standard-phases
461 (add-after 'unpack 'patch-desktop-file
462 (lambda _
463 (substitute* "data/com.github.geigi.cozy.desktop"
464 (("Exec=com.github.geigi.cozy") "Exec=cozy"))
465 #t))
466 (add-after 'install 'patch-executable-name
467 (lambda* (#:key outputs #:allow-other-keys)
468 (with-directory-excursion
469 (string-append (assoc-ref outputs "out") "/bin")
470 (rename-file "com.github.geigi.cozy" "cozy"))
471 #t))
472 (add-after 'wrap 'wrap-libs
473 (lambda* (#:key outputs #:allow-other-keys)
474 (let* ((out (assoc-ref outputs "out"))
475 (pylib (string-append
476 out "/lib/python"
477 ,(version-major+minor
478 (package-version python))
479 "/site-packages"))
480 (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
481 (gst-plugin-path (getenv "GST_PLUGIN_SYSTEM_PATH"))
482 (libmagic-path (string-append
483 (assoc-ref %build-inputs "file")
484 "/lib"))
485 (python-path (getenv "PYTHONPATH")))
486 (wrap-program (string-append out "/bin/cozy")
487 `("LD_LIBRARY_PATH" ":" prefix (,libmagic-path))
488 `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))
489 `("GST_PLUGIN_SYSTEM_PATH" ":" prefix (,gst-plugin-path))
490 `("PYTHONPATH" ":" prefix (,python-path ,pylib))))
491 #t)))))
492 (native-inputs
493 `(("desktop-file-utils" ,desktop-file-utils)
494 ("gettext" ,gettext-minimal)
495 ("glib:bin" ,glib "bin")
496 ("gobject-introspection" ,gobject-introspection)
497 ("gtk+:bin" ,gtk+ "bin")
498 ("pkg-config" ,pkg-config)
499 ("python" ,python-wrapper)))
500 (inputs
501 `(("file" ,file)
502 ("gsettings-desktop-schemas" ,gsettings-desktop-schemas)
503 ("gst-libav" ,gst-libav)
504 ("gst-plugins-bad" ,gst-plugins-bad)
505 ("gst-plugins-good" ,gst-plugins-good)
506 ("gst-plugins-ugly" ,gst-plugins-ugly)
507 ("gtk+" ,gtk+)
508 ("libhandy" ,libhandy)
509 ("python-distro" ,python-distro)
510 ("python-gst" ,python-gst)
511 ("python-mutagen" ,python-mutagen)
512 ("python-packaging" ,python-packaging)
513 ("python-peewee" ,python-peewee)
514 ("python-pycairo" ,python-pycairo)
515 ("python-pygobject" ,python-pygobject)
516 ("python-pytz" ,python-pytz)
517 ("python-requests" ,python-requests)))
518 (home-page "https://cozy.geigi.de/")
519 (synopsis "Modern audiobook player using GTK+")
520 (description
521 "Cozy is a modern audiobook player written in GTK+.
522
523 Some of the current features:
524
525 @itemize
526 @item Import your audiobooks into Cozy to browse them comfortably
527 @item Sort your audio books by author, reader & name
528 @item Remembers your playback position
529 @item Sleep timer
530 @item Playback speed control
531 @item Search your library
532 @item Offline mode
533 @item Add multiple storage locations
534 @item Drag & Drop to import new audio books
535 @item Support for DRM free mp3, m4a (aac, ALAC, …), flac, ogg, opus, wav files
536 @item Mpris integration (Media keys & playback info for desktop environment)
537 @end itemize")
538 ;; TODO: Unbundle python-inject.
539 (license (list license:gpl3+ ;cozy
540 license:asl2.0)))) ;python-inject (bundled dependency)
541
542 (define-public xchm
543 (package
544 (name "xchm")
545 (version "1.31")
546 (source (origin
547 (method url-fetch)
548 (uri (string-append "https://github.com/rzvncj/xCHM"
549 "/releases/download/"
550 version "/xchm-" version ".tar.gz"))
551 (sha256
552 (base32
553 "0aw6bysqiwbw75n3ad229ihlmh7chqs1wlxm0398z3lfp2y6n7qf"))))
554 (build-system gnu-build-system)
555 (inputs
556 `(("wxwidgets" ,wxwidgets)
557 ("chmlib" ,chmlib)))
558 (native-inputs
559 `(("pkg-config" ,pkg-config)))
560 (home-page "https://github.com/rzvncj/xCHM")
561 (synopsis "CHM file viewer")
562 (description "xCHM is a graphical CHM file viewer. It is a frontend to
563 the CHM library CHMLIB.")
564 (license license:gpl2+)))