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, 2021 Brendan Tildesley <mail@brendan.scot>
6 ;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
7 ;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
9 ;;; Copyright © 2020, 2021 Vinicius Monego <monego@posteo.net>
10 ;;; Copyright © 2020 Zheng Junjie <873216071@qq.com>
12 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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 pantheon)
59 #:use-module (gnu packages pdf)
60 #:use-module (gnu packages pkg-config)
61 #:use-module (gnu packages python)
62 #:use-module (gnu packages python-build)
63 #:use-module (gnu packages python-compression)
64 #:use-module (gnu packages python-crypto)
65 #:use-module (gnu packages python-web)
66 #:use-module (gnu packages python-xyz)
67 #:use-module (gnu packages qt)
68 #:use-module (gnu packages serialization)
69 #:use-module (gnu packages speech)
70 #:use-module (gnu packages sqlite)
71 #:use-module (gnu packages time)
72 #:use-module (gnu packages tls)
73 #:use-module (gnu packages web)
74 #:use-module (gnu packages xml)
75 #:use-module (gnu packages xorg)
76 #:use-module (gnu packages wxwidgets))
84 (uri (string-append "http://www.jedrea.com/chmlib/chmlib-"
88 "18zzb4x3z0d7fjh1x5439bs62dmgsi4c1pg3qyr7h5gp1i5xcj9l"))
89 (patches (search-patches "chmlib-inttypes.patch"))))
90 (build-system gnu-build-system)
91 (home-page "http://www.jedrea.com/chmlib/")
92 (synopsis "Library for CHM files")
93 (description "CHMLIB is a library for dealing with ITSS/CHM format files.")
94 (license license:lgpl2.1+)))
96 (define-public python-pychm
103 (uri (pypi-uri "pychm" version))
106 "0wpn9ijlsmrpyiwg3drmgz4dms1i1i347adgqw37bkrh3vn6yq16"))))
107 (build-system python-build-system)
109 `(("chmlib" ,chmlib)))
110 (home-page "https://github.com/dottedmag/pychm")
111 (synopsis "Handle CHM files")
112 (description "This package provides a Python module for interacting
113 with Microsoft Compiled HTML (CHM) files")
114 (license license:gpl2+)))
116 (define-public calibre
123 (uri (string-append "http://download.calibre-ebook.com/"
128 "0w8j9r9qa56r8gm9b10dwh8zrzqlv79s2br82jqg02lrnrbwwv0q"))
129 (modules '((guix build utils)))
132 ;; Unbundle python2-odfpy.
133 (delete-file-recursively "src/odf")
134 ;; Disable test that attempts to load it.
135 (substitute* "setup/test.py"
139 ;; Remove unneeded resources.
140 (delete-file "resources/mozilla-ca-certs.pem")
141 (delete-file "resources/calibre-portable.bat")
142 (delete-file "resources/calibre-portable.sh")
144 (patches (search-patches "calibre-no-updates-dialog.patch"
145 "calibre-remove-test-sqlite.patch" ; TODO: fix test.
146 "calibre-remove-test-unrar.patch"))))
147 (build-system python-build-system)
149 `(("pkg-config" ,pkg-config)
150 ("qtbase" ,qtbase-5) ; for qmake
151 ("python-flake8" ,python-flake8)
152 ("python-pyqt-builder" ,python-pyqt-builder)
153 ("xdg-utils" ,xdg-utils)))
155 `(("fontconfig" ,fontconfig)
156 ("font-liberation" ,font-liberation)
158 ("hunspell" ,hunspell)
163 ("libjpeg" ,libjpeg-turbo)
170 ("python-apsw" ,python-apsw)
171 ("python-beautifulsoup4" ,python-beautifulsoup4)
172 ("python-cchardet" ,python-cchardet)
173 ("python-css-parser" ,python-css-parser)
174 ("python-cssselect" ,python-cssselect)
175 ("python-dateutil" ,python-dateutil)
176 ("python-dbus" ,python-dbus)
177 ("python-dnspython" ,python-dnspython-1.16)
178 ("python-dukpy" ,python-dukpy)
179 ("python-feedparser" ,python-feedparser)
180 ("python-html2text" ,python-html2text)
181 ("python-html5-parser" ,python-html5-parser)
182 ("python-html5lib" ,python-html5lib)
183 ("python-lxml" ,python-lxml)
184 ("python-markdown" ,python-markdown)
185 ("python-mechanize" ,python-mechanize)
186 ;; python-msgpack is needed for the network content server to work.
187 ("python-msgpack" ,python-msgpack)
188 ("python-netifaces" ,python-netifaces)
189 ("python-odfpy" ,python-odfpy)
190 ("python-pillow" ,python-pillow)
191 ("python-psutil" ,python-psutil)
192 ("python-py7zr" ,python-py7zr)
193 ("python-pychm" ,python-pychm)
194 ("python-pycryptodome" ,python-pycryptodome)
195 ("python-pygments" ,python-pygments)
196 ("python-pyqt" ,python-pyqt)
197 ("python-pyqtwebengine" ,python-pyqtwebengine)
198 ("python-regex" ,python-regex)
199 ("python-speechd" ,speech-dispatcher)
200 ("python-zeroconf" ,python-zeroconf)
201 ("qtwebengine" ,qtwebengine)
204 `(;; Calibre is using setuptools by itself, but the setup.py is not
205 ;; compatible with the shim wrapper (taken from pip) we are using.
208 (modify-phases %standard-phases
209 (add-after 'unpack 'patch-source
211 (substitute* "src/calibre/linux.py"
212 ;; We can't use the uninstaller in Guix. Don't build it.
213 (("self\\.create_uninstaller()") ""))
215 (add-after 'patch-source-shebangs 'patch-more-shebangs
217 ;; Patch various inline shebangs.
218 (substitute* '("src/calibre/gui2/preferences/tweaks.py"
219 "src/calibre/gui2/dialogs/custom_recipes.py"
221 "setup/linux-installer.sh")
222 (("#!/usr/bin/env python")
223 (string-append "#!" (which "python")))
225 (string-append "#!" (which "sh"))))
227 (add-after 'unpack 'dont-load-remote-icons
229 (substitute* "setup/plugins_mirror.py"
230 (("href=\"//calibre-ebook.com/favicon.ico\"")
231 "href=\"favicon.ico\""))
233 (add-before 'build 'configure
234 (lambda* (#:key inputs outputs #:allow-other-keys)
235 (let ((podofo (assoc-ref inputs "podofo"))
236 (pyqt (assoc-ref inputs "python-pyqt"))
237 (python-sip (assoc-ref inputs "python-sip"))
238 (out (assoc-ref outputs "out")))
239 (substitute* "setup/build.py"
240 (("\\[tool.sip.bindings.pictureflow\\]")
241 "[tool.sip.bindings.pictureflow]
242 tags = [\"WS_X11\"]")
243 (("\\[tool.sip.project\\]")
244 (string-append "[tool.sip.project]
245 sip-include-dirs = [\"" pyqt "/share/sip" "\"]")))
246 (substitute* "src/calibre/ebooks/pdf/pdftohtml.py"
247 (("PDFTOHTML = 'pdftohtml'")
248 (string-append "PDFTOHTML = \"" (assoc-ref inputs "poppler")
249 "/bin/pdftohtml\"")))
250 ;; get_exe_path looks in poppler's output for these binaries. Make
252 (substitute* "src/calibre/utils/img.py"
253 (("get_exe_path..jpegtran..") (string-append "'" (which "jpegtran") "'"))
254 (("get_exe_path..cjpeg..") (string-append "'" (which "cjpeg") "'"))
255 (("get_exe_path..optipng..") (string-append "'" (which "optipng") "'"))
256 (("get_exe_path..JxrDecApp..") (string-append "'" (which "JxrDecApp") "'")))
257 ;; Calibre thinks we are installing desktop files into a home
258 ;; directory, but here we butcher the script in to installing
259 ;; to calibres /share directory.
260 (setenv "XDG_DATA_HOME" (string-append out "/share"))
261 (substitute* "src/calibre/linux.py"
262 (("'~/.local/share'") "''"))
264 ;; 'python setup.py rapydscript' uses QtWebEngine, which
265 ;; needs to create temporary files in $HOME.
266 (setenv "HOME" "/tmp")
268 ;; XXX: QtWebEngine will fail if no fonts are available. This
269 ;; can likely be removed when fontconfig has been patched to
270 ;; include TrueType fonts by default.
271 (symlink (string-append (assoc-ref inputs "font-liberation")
275 (setenv "PODOFO_INC_DIR" (string-append podofo "/include/podofo"))
276 (setenv "PODOFO_LIB_DIR" (string-append podofo "/lib"))
277 ;; This informs the tests we are a continuous integration
278 ;; environment and thus have no networking.
280 ;; The Qt test complains about being unable to load all image plugins, and I
281 ;; notice the available plugins list it shows lacks 'svg'. Adding qtsvg doesn't
282 ;; fix it, so I'm not sure how to fix it. TODO: Fix test and remove this.
283 (setenv "SKIP_QT_BUILD_TEST" "true")
285 (add-after 'install 'install-rapydscript
286 (lambda* (#:key inputs #:allow-other-keys)
287 ;; Unset so QtWebengine doesn't dump temporary files here.
288 (unsetenv "XDG_DATA_HOME")
289 (invoke "python" "setup.py" "rapydscript")
291 (add-after 'install 'install-man-pages
292 (lambda* (#:key outputs #:allow-other-keys)
295 (string-append (assoc-ref outputs "out") "/share/man"))
297 ;; The font TTF files are used in some miscellaneous tests, so we
298 ;; unbundle them here to avoid patching the tests.
299 (add-after 'install 'unbundle-font-liberation
300 (lambda* (#:key inputs outputs #:allow-other-keys)
301 (let ((font-dest (string-append (assoc-ref outputs "out")
302 "/share/calibre/fonts/liberation"))
303 (font-src (string-append (assoc-ref inputs "font-liberation")
304 "/share/fonts/truetype")))
305 (delete-file-recursively font-dest)
306 (symlink font-src font-dest))
308 ;; Make run-time dependencies available to the binaries.
309 (add-after 'wrap 'wrap-program
310 (lambda* (#:key inputs outputs #:allow-other-keys)
311 (let ((out (assoc-ref outputs "out"))
312 (qtwebengine (assoc-ref inputs "qtwebengine")))
313 (with-directory-excursion (string-append out "/bin")
317 ;; Make QtWebEngineProcess available.
318 `("QTWEBENGINEPROCESS_PATH" =
319 ,(list (string-append
321 "/lib/qt5/libexec/QtWebEngineProcess")))))
322 ;; Wrap all the binaries shipping with the package, except
323 ;; for the wrappings created during the 'wrap standard
324 ;; phase. This extends existing .calibre-real wrappers
325 ;; rather than create ..calibre-real-real-s. For more
326 ;; information see: https://issues.guix.gnu.org/43249.
327 (find-files "." (lambda (file stat)
328 (not (wrapper? file)))))))
330 (home-page "https://calibre-ebook.com/")
331 (synopsis "E-book library management software")
332 (description "Calibre is an e-book library manager. It can view, convert
333 and catalog e-books in most of the major e-book formats. It can also talk
334 to many e-book reader devices. It can go out to the Internet and fetch
335 metadata for books. It can download newspapers and convert them into
336 e-books for convenient reading.")
337 ;; Calibre is largely GPL3+, but includes a number of components covered
338 ;; by other licenses. See COPYRIGHT for more details.
339 (license (list license:gpl3+
347 license:public-domain
349 license:cc-by-sa3.0))))
351 (define-public ebook-tools
358 (uri (string-append "mirror://sourceforge/ebook-tools/ebook-tools/"
359 version "/ebook-tools-" version ".tar.gz"))
362 "1bi7wsz3p5slb43kj7lgb3r6lb91lvb6ldi556k4y50ix6b5khyb"))))
364 `(#:tests? #f)) ; No 'test' target
365 (build-system cmake-build-system)
367 `(("pkg-config" ,pkg-config)))
370 ("libxml2" ,libxml2)))
371 (home-page "http://ebook-tools.sourceforge.net")
372 (synopsis "Tools and library for dealing with various ebook file formats")
373 (description "This package provides command-line tools and a library for
374 accessing and converting various ebook file formats.")
375 (license license:expat)))
377 (define-public liblinebreak
379 (name "liblinebreak")
383 (uri (string-append "mirror://sourceforge/vimgadgets"
384 "/liblinebreak/" version
385 "/liblinebreak-" version ".tar.gz"))
388 "1f36dbq7nc77lln1by2n1yl050g9dc63viawhs3gc3169mavm36x"))))
389 (build-system gnu-build-system)
390 (home-page "http://vimgadgets.sourceforge.net/liblinebreak/")
391 (synopsis "Library for detecting where linebreaks are allowed in text")
392 (description "@code{liblinebreak} is an implementation of the line
393 breaking algorithm as described in Unicode 6.0.0 Standard Annex 14,
394 Revision 26. It breaks lines that contain Unicode characters. It is
395 designed to be used in a generic text renderer.")
396 (license license:zlib)))
398 (define-public fbreader
405 (url "https://github.com/geometer/FBReader")
406 (commit (string-append version "-freebsdport"))))
407 (file-name (git-file-name name version))
410 "0c0s4silpax74kwfz3dfmzn4lkv6jsyb800vfak166vii0hvbv3d"))
411 (patches (search-patches "fbreader-curl-7.62.patch"))))
412 (build-system gnu-build-system)
419 ("libjpeg" ,libjpeg-turbo)
420 ("liblinebreak" ,liblinebreak)
426 ("pkg-config" ,pkg-config)))
428 `(#:tests? #f ; No tests exist.
429 #:make-flags `("CC=gcc" "TARGET_ARCH=desktop" "UI_TYPE=gtk"
430 "TARGET_STATUS=release"
431 ,(string-append "INSTALLDIR="
432 (assoc-ref %outputs "out"))
433 ,(string-append "LDFLAGS=-Wl,-rpath="
434 (assoc-ref %outputs "out") "/lib"))
436 (modify-phases %standard-phases
437 (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
438 (lambda* (#:key inputs #:allow-other-keys)
439 ;; Hide the default GCC from CPLUS_INCLUDE_PATH to prevent a header
440 ;; conflict with the GCC provided in native-inputs.
441 (let ((gcc (assoc-ref inputs "gcc")))
442 (setenv "CPLUS_INCLUDE_PATH"
444 (delete (string-append gcc "/include/c++")
445 (string-split (getenv "CPLUS_INCLUDE_PATH")
450 (add-after 'unpack 'fix-install-locations
451 (lambda* (#:key outputs #:allow-other-keys)
452 (let ((out (assoc-ref outputs "out")))
453 (substitute* "fbreader/desktop/Makefile"
456 (home-page "https://fbreader.org/")
457 (synopsis "E-Book reader")
458 (description "@code{fbreader} is an E-Book reader. It supports the
473 (license license:gpl2+)))
483 (url "https://github.com/geigi/cozy")
485 (file-name (git-file-name name version))
487 (base32 "0m0xiqpb87pwr3fhy0a4qxg67yjhwchcxj3x2anyy0li4inryxag"))))
488 (build-system meson-build-system)
492 (modify-phases %standard-phases
493 (add-after 'unpack 'patch-desktop-file
495 (substitute* "data/com.github.geigi.cozy.desktop"
496 (("Exec=com.github.geigi.cozy") "Exec=cozy"))
498 (add-after 'install 'patch-executable-name
499 (lambda* (#:key outputs #:allow-other-keys)
500 (with-directory-excursion
501 (string-append (assoc-ref outputs "out") "/bin")
502 (rename-file "com.github.geigi.cozy" "cozy"))
504 (add-after 'wrap 'wrap-libs
505 (lambda* (#:key outputs #:allow-other-keys)
506 (let* ((out (assoc-ref outputs "out"))
507 (pylib (string-append
509 ,(version-major+minor
510 (package-version python))
512 (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
513 (gst-plugin-path (getenv "GST_PLUGIN_SYSTEM_PATH"))
514 (libmagic-path (string-append
515 (assoc-ref %build-inputs "file")
517 (python-path (getenv "PYTHONPATH")))
518 (wrap-program (string-append out "/bin/cozy")
519 `("LD_LIBRARY_PATH" ":" prefix (,libmagic-path))
520 `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))
521 `("GST_PLUGIN_SYSTEM_PATH" ":" prefix (,gst-plugin-path))
522 `("PYTHONPATH" ":" prefix (,python-path ,pylib))))
525 `(("desktop-file-utils" ,desktop-file-utils)
526 ("gettext" ,gettext-minimal)
527 ("glib:bin" ,glib "bin")
528 ("gobject-introspection" ,gobject-introspection)
529 ("gtk+:bin" ,gtk+ "bin")
530 ("pkg-config" ,pkg-config)
531 ("python" ,python-wrapper)))
535 ("gsettings-desktop-schemas" ,gsettings-desktop-schemas)
536 ("gst-libav" ,gst-libav)
537 ("gst-plugins-bad" ,gst-plugins-bad)
538 ("gst-plugins-good" ,gst-plugins-good)
539 ("gst-plugins-ugly" ,gst-plugins-ugly)
542 ("libhandy" ,libhandy)
543 ("python-distro" ,python-distro)
544 ("python-gst" ,python-gst)
545 ("python-mutagen" ,python-mutagen)
546 ("python-packaging" ,python-packaging)
547 ("python-peewee" ,python-peewee)
548 ("python-pycairo" ,python-pycairo)
549 ("python-pygobject" ,python-pygobject)
550 ("python-pytz" ,python-pytz)
551 ("python-requests" ,python-requests)))
552 (home-page "https://cozy.geigi.de/")
553 (synopsis "Modern audiobook player using GTK+")
555 "Cozy is a modern audiobook player written in GTK+.
557 Some of the current features:
560 @item Import your audiobooks into Cozy to browse them comfortably
561 @item Sort your audio books by author, reader & name
562 @item Remembers your playback position
564 @item Playback speed control
565 @item Search your library
567 @item Add multiple storage locations
568 @item Drag & Drop to import new audio books
569 @item Support for DRM free mp3, m4a (aac, ALAC, …), flac, ogg, opus, wav files
570 @item Mpris integration (Media keys & playback info for desktop environment)
572 ;; TODO: Unbundle python-inject.
573 (license (list license:gpl3+ ;cozy
574 license:asl2.0)))) ;python-inject (bundled dependency)
582 (uri (string-append "https://github.com/rzvncj/xCHM"
583 "/releases/download/"
584 version "/xchm-" version ".tar.gz"))
587 "0b12ym7cn65wy268kbksyhakicwb053c8xfn76q2dawrvbras9dj"))))
588 (build-system gnu-build-system)
590 `(("wxwidgets" ,wxwidgets)
593 `(("pkg-config" ,pkg-config)))
594 (home-page "https://github.com/rzvncj/xCHM")
595 (synopsis "CHM file viewer")
596 (description "xCHM is a graphical CHM file viewer. It is a frontend to
597 the CHM library CHMLIB.")
598 (license license:gpl2+)))