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