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 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
9 ;;; Copyright © 2020 Vinicius Monego <monego@posteo.net>
11 ;;; This file is part of GNU Guix.
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26 (define-module (gnu packages ebook)
27 #:use-module ((guix licenses) #:prefix license:)
28 #:use-module (guix packages)
29 #:use-module (guix download)
30 #:use-module (guix utils)
31 #:use-module (guix git-download)
32 #:use-module (guix build-system gnu)
33 #:use-module (guix build-system meson)
34 #:use-module (guix build-system python)
35 #:use-module (gnu packages)
36 #:use-module (gnu packages compression)
37 #:use-module (gnu packages curl)
38 #:use-module (gnu packages databases)
39 #:use-module (gnu packages file)
40 #:use-module (gnu packages fonts)
41 #:use-module (gnu packages fontutils)
42 #:use-module (gnu packages freedesktop)
43 #:use-module (gnu packages fribidi)
44 #:use-module (gnu packages gcc)
45 #:use-module (gnu packages gettext)
46 #:use-module (gnu packages gtk)
47 #:use-module (gnu packages gnome)
48 #:use-module (gnu packages glib)
49 #:use-module (gnu packages gstreamer)
50 #:use-module (gnu packages icu4c)
51 #:use-module (gnu packages image)
52 #:use-module (gnu packages javascript)
53 #:use-module (gnu packages libusb)
54 #:use-module (gnu packages libreoffice)
55 #:use-module (gnu packages music)
56 #:use-module (gnu packages pdf)
57 #:use-module (gnu packages pkg-config)
58 #:use-module (gnu packages python)
59 #:use-module (gnu packages python-web)
60 #:use-module (gnu packages python-xyz)
61 #:use-module (gnu packages qt)
62 #:use-module (gnu packages serialization)
63 #:use-module (gnu packages sqlite)
64 #:use-module (gnu packages time)
65 #:use-module (gnu packages tls)
66 #:use-module (gnu packages web)
67 #:use-module (gnu packages xml)
68 #:use-module (gnu packages xorg)
69 #:use-module (gnu packages wxwidgets))
77 (uri (string-append "http://www.jedrea.com/chmlib/chmlib-"
81 "18zzb4x3z0d7fjh1x5439bs62dmgsi4c1pg3qyr7h5gp1i5xcj9l"))
82 (patches (search-patches "chmlib-inttypes.patch"))))
83 (build-system gnu-build-system)
84 (home-page "http://www.jedrea.com/chmlib/")
85 (synopsis "Library for CHM files")
86 (description "CHMLIB is a library for dealing with ITSS/CHM format files.")
87 (license license:lgpl2.1+)))
89 (define-public calibre
96 (uri (string-append "http://download.calibre-ebook.com/"
101 "0w9pcfvskjh4v00vjw3i6hzrafy863pgsmmqdx4lffip3p856brw"))
102 (modules '((guix build utils)))
105 ;; Unbundle python2-odfpy.
106 (delete-file-recursively "src/odf")
107 ;; Disable test that attempts to load it.
108 (substitute* "setup/test.py"
112 ;; Remove unneeded resources.
113 (delete-file "resources/viewer.js")
114 (delete-file "resources/viewer.html")
115 (delete-file "resources/mozilla-ca-certs.pem")
116 (delete-file "resources/calibre-portable.bat")
117 (delete-file "resources/calibre-portable.sh")
119 (patches (search-patches "calibre-no-updates-dialog.patch"
120 "calibre-remove-test-sqlite.patch" ; TODO: fix test.
121 "calibre-remove-test-unrar.patch"))))
122 (build-system python-build-system)
124 `(("pkg-config" ,pkg-config)
125 ("qtbase" ,qtbase) ; for qmake
126 ("python2-flake8" ,python2-flake8)
127 ("xdg-utils" ,xdg-utils)))
130 ("fontconfig" ,fontconfig)
131 ("font-liberation" ,font-liberation)
133 ("hunspell" ,hunspell)
136 ("js-mathjax" ,js-mathjax)
145 ("python2-apsw" ,python2-apsw)
146 ("python2-beautifulsoup4" ,python2-beautifulsoup4)
147 ("python2-chardet" ,python2-chardet)
148 ("python2-cssselect" ,python2-cssselect)
149 ("python2-css-parser" ,python2-css-parser)
150 ("python2-dateutil" ,python2-dateutil)
151 ("python2-dbus" ,python2-dbus)
152 ("python2-dnspython" ,python2-dnspython)
153 ("python2-dukpy" ,python2-dukpy)
154 ("python2-feedparser" ,python2-feedparser)
155 ("python2-html2text" ,python2-html2text)
156 ("python2-html5-parser" ,python2-html5-parser)
157 ("python2-html5lib" ,python2-html5lib)
158 ("python2-lxml" ,python2-lxml)
159 ("python2-markdown" ,python2-markdown)
160 ("python2-mechanize" ,python2-mechanize)
161 ;; python2-msgpack is needed for the network content server to work.
162 ("python2-msgpack" ,python2-msgpack)
163 ("python2-netifaces" ,python2-netifaces)
164 ("python2-odfpy" ,python2-odfpy)
165 ("python2-pillow" ,python2-pillow)
166 ("python2-psutil" ,python2-psutil)
167 ("python2-pygments" ,python2-pygments)
168 ("python2-pyqtwebengine" ,python2-pyqtwebengine)
169 ("python2-pyqt" ,python2-pyqt)
170 ("python2-sip" ,python2-sip)
171 ("python2-regex" ,python2-regex)
172 ("qtwebengine" ,qtwebengine)
176 ;; Calibre is using setuptools by itself, but the setup.py is not
177 ;; compatible with the shim wrapper (taken from pip) we are using.
180 (modify-phases %standard-phases
181 (add-after 'unpack 'patch-source
183 (substitute* "src/calibre/linux.py"
184 ;; We can't use the uninstaller in Guix. Don't build it.
185 (("self\\.create_uninstaller()") ""))
187 (add-after 'patch-source-shebangs 'patch-more-shebangs
189 ;; Patch various inline shebangs.
190 (substitute* '("src/calibre/gui2/preferences/tweaks.py"
191 "src/calibre/gui2/dialogs/custom_recipes.py"
193 "setup/linux-installer.sh")
194 (("#!/usr/bin/env python")
195 (string-append "#!" (which "python")))
197 (string-append "#!" (which "sh"))))
199 (add-after 'unpack 'dont-load-remote-icons
201 (substitute* "setup/plugins_mirror.py"
202 (("href=\"//calibre-ebook.com/favicon.ico\"")
203 "href=\"favicon.ico\""))
205 (add-before 'build 'configure
206 (lambda* (#:key inputs outputs #:allow-other-keys)
207 (let ((podofo (assoc-ref inputs "podofo"))
208 (pyqt (assoc-ref inputs "python2-pyqt"))
209 (python-sip (assoc-ref inputs "python2-sip"))
210 (out (assoc-ref outputs "out")))
211 (substitute* "setup/build_environment.py"
212 (("= get_sip_dir\\(\\)")
213 (string-append "= '" pyqt "/share/sip'")))
215 (substitute* "src/calibre/ebooks/pdf/pdftohtml.py"
216 (("PDFTOHTML = 'pdftohtml'")
217 (string-append "PDFTOHTML = \"" (assoc-ref inputs "poppler")
218 "/bin/pdftohtml\"")))
220 ;; Calibre thinks we are installing desktop files into a home
221 ;; directory, but here we butcher the script in to installing
222 ;; to calibres /share directory.
223 (setenv "XDG_DATA_HOME" (string-append out "/share"))
224 (substitute* "src/calibre/linux.py"
225 (("'~/.local/share'") "''"))
227 ;; 'python setup.py rapydscript' uses QtWebEngine, which
228 ;; needs to create temporary files in $HOME.
229 (setenv "HOME" "/tmp")
231 ;; XXX: QtWebEngine will fail if no fonts are available. This
232 ;; can likely be removed when fontconfig has been patched to
233 ;; include TrueType fonts by default.
234 (symlink (string-append (assoc-ref inputs "font-liberation")
238 (setenv "SIP_BIN" (string-append python-sip "/bin/sip"))
239 (setenv "PODOFO_INC_DIR" (string-append podofo "/include/podofo"))
240 (setenv "PODOFO_LIB_DIR" (string-append podofo "/lib"))
241 ;; This informs the tests we are a continuous integration
242 ;; environment and thus have no networking.
244 ;; The Qt test complains about being unable to load all image plugins, and I
245 ;; notice the available plugins list it shows lacks 'svg'. Adding qtsvg doesn't
246 ;; fix it, so I'm not sure how to fix it. TODO: Fix test and remove this.
247 (setenv "SKIP_QT_BUILD_TEST" "true")
249 (add-after 'build 'build-extra
250 (lambda* (#:key inputs #:allow-other-keys)
251 (invoke "python2" "setup.py" "mathjax""--system-mathjax"
252 "--path-to-mathjax" (string-append
253 (assoc-ref inputs "js-mathjax")
254 "/share/javascript/mathjax"))
255 (invoke "python2" "setup.py" "rapydscript")
257 (add-after 'install 'install-man-pages
258 (lambda* (#:key outputs #:allow-other-keys)
261 (string-append (assoc-ref outputs "out") "/share/man"))
263 ;; The font TTF files are used in some miscellaneous tests, so we
264 ;; unbundle them here to avoid patching the tests.
265 (add-after 'install 'unbundle-font-liberation
266 (lambda* (#:key inputs outputs #:allow-other-keys)
267 (let ((font-dest (string-append (assoc-ref outputs "out")
268 "/share/calibre/fonts/liberation"))
269 (font-src (string-append (assoc-ref inputs "font-liberation")
270 "/share/fonts/truetype")))
271 (delete-file-recursively font-dest)
272 (symlink font-src font-dest))
274 ;; Make run-time dependencies available to the binaries.
275 (add-after 'wrap 'wrap-program
276 (lambda* (#:key inputs outputs #:allow-other-keys)
277 (let ((out (assoc-ref outputs "out"))
278 (qtwebengine (assoc-ref inputs "qtwebengine")))
279 (with-directory-excursion (string-append out "/bin")
283 ;; Make QtWebEngineProcess available.
284 `("QTWEBENGINEPROCESS_PATH" ":" =
285 ,(list (string-append
287 "/lib/qt5/libexec/QtWebEngineProcess")))))
288 ;; Wrap all the binaries shipping with the package, except
289 ;; for the wrappings created during the 'wrap standard
290 ;; phase. This extends existing .calibre-real wrappers
291 ;; rather than create ..calibre-real-real-s. For more
292 ;; information see: https://issues.guix.gnu.org/43249.
293 (find-files "." (lambda (file stat)
294 (not (wrapper? file)))))))
296 (home-page "https://calibre-ebook.com/")
297 (synopsis "E-book library management software")
298 (description "Calibre is an e-book library manager. It can view, convert
299 and catalog e-books in most of the major e-book formats. It can also talk
300 to many e-book reader devices. It can go out to the Internet and fetch
301 metadata for books. It can download newspapers and convert them into
302 e-books for convenient reading.")
303 ;; Calibre is largely GPL3+, but includes a number of components covered
304 ;; by other licenses. See COPYRIGHT for more details.
305 (license (list license:gpl3+
313 license:public-domain
315 license:cc-by-sa3.0))))
317 (define-public liblinebreak
319 (name "liblinebreak")
323 (uri (string-append "mirror://sourceforge/vimgadgets"
324 "/liblinebreak/" version
325 "/liblinebreak-" version ".tar.gz"))
328 "1f36dbq7nc77lln1by2n1yl050g9dc63viawhs3gc3169mavm36x"))))
329 (build-system gnu-build-system)
330 (home-page "http://vimgadgets.sourceforge.net/liblinebreak/")
331 (synopsis "Library for detecting where linebreaks are allowed in text")
332 (description "@code{liblinebreak} is an implementation of the line
333 breaking algorithm as described in Unicode 6.0.0 Standard Annex 14,
334 Revision 26. It breaks lines that contain Unicode characters. It is
335 designed to be used in a generic text renderer.")
336 (license license:zlib)))
338 (define-public fbreader
345 (url "https://github.com/geometer/FBReader")
346 (commit (string-append version "-freebsdport"))))
347 (file-name (git-file-name name version))
350 "0c0s4silpax74kwfz3dfmzn4lkv6jsyb800vfak166vii0hvbv3d"))
351 (patches (search-patches "fbreader-curl-7.62.patch"))))
352 (build-system gnu-build-system)
359 ("libjpeg" ,libjpeg-turbo)
360 ("liblinebreak" ,liblinebreak)
366 ("pkg-config" ,pkg-config)))
368 `(#:tests? #f ; No tests exist.
369 #:make-flags `("CC=gcc" "TARGET_ARCH=desktop" "UI_TYPE=gtk"
370 "TARGET_STATUS=release"
371 ,(string-append "INSTALLDIR="
372 (assoc-ref %outputs "out"))
373 ,(string-append "LDFLAGS=-Wl,-rpath="
374 (assoc-ref %outputs "out") "/lib"))
376 (modify-phases %standard-phases
377 (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
378 (lambda* (#:key inputs #:allow-other-keys)
379 ;; Hide the default GCC from CPLUS_INCLUDE_PATH to prevent a header
380 ;; conflict with the GCC provided in native-inputs.
381 (let ((gcc (assoc-ref inputs "gcc")))
382 (setenv "CPLUS_INCLUDE_PATH"
384 (delete (string-append gcc "/include/c++")
385 (string-split (getenv "CPLUS_INCLUDE_PATH")
390 (add-after 'unpack 'fix-install-locations
391 (lambda* (#:key outputs #:allow-other-keys)
392 (let ((out (assoc-ref outputs "out")))
393 (substitute* "fbreader/desktop/Makefile"
396 (home-page "https://fbreader.org/")
397 (synopsis "E-Book reader")
398 (description "@code{fbreader} is an E-Book reader. It supports the
413 (license license:gpl2+)))
423 (url "https://github.com/geigi/cozy")
425 (file-name (git-file-name name version))
427 (base32 "1f1qydjs8sz39yhlg9qdjf31vrsmdk2pxiimw4fzsy1k2zr5dr34"))))
428 (build-system meson-build-system)
432 (modify-phases %standard-phases
433 (add-after 'unpack 'patch-desktop-file
435 (substitute* "data/com.github.geigi.cozy.desktop.in"
436 (("com.github.geigi.cozy") "cozy"))
438 (add-after 'install 'patch-executable-name
439 (lambda* (#:key outputs #:allow-other-keys)
440 (with-directory-excursion
441 (string-append (assoc-ref outputs "out") "/bin")
442 (rename-file "com.github.geigi.cozy" "cozy"))
444 (add-after 'wrap 'wrap-libs
445 (lambda* (#:key outputs #:allow-other-keys)
446 (let* ((out (assoc-ref outputs "out"))
447 (pylib (string-append
449 ,(version-major+minor
450 (package-version python))
452 (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
453 (gst-plugin-path (getenv "GST_PLUGIN_SYSTEM_PATH"))
454 (libmagic-path (string-append
455 (assoc-ref %build-inputs "file")
457 (python-path (getenv "PYTHONPATH")))
458 (wrap-program (string-append out "/bin/cozy")
459 `("LD_LIBRARY_PATH" ":" prefix (,libmagic-path))
460 `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))
461 `("GST_PLUGIN_SYSTEM_PATH" ":" prefix (,gst-plugin-path))
462 `("PYTHONPATH" ":" prefix (,python-path ,pylib))))
465 `(("desktop-file-utils" ,desktop-file-utils)
466 ("gettext" ,gettext-minimal)
467 ("glib:bin" ,glib "bin")
468 ("gobject-introspection" ,gobject-introspection)
469 ("gtk+:bin" ,gtk+ "bin")
470 ("pkg-config" ,pkg-config)
471 ("python" ,python-wrapper)))
474 ("gsettings-desktop-schemas" ,gsettings-desktop-schemas)
475 ("gst-libav" ,gst-libav)
476 ("gst-plugins-bad" ,gst-plugins-bad)
477 ("gst-plugins-good" ,gst-plugins-good)
478 ("gst-plugins-ugly" ,gst-plugins-ugly)
480 ("python-apsw" ,python-apsw)
481 ("python-distro" ,python-distro)
482 ("python-gst" ,python-gst)
483 ("python-mutagen" ,python-mutagen)
484 ("python-peewee" ,python-peewee)
485 ("python-pycairo" ,python-pycairo)
486 ("python-pygobject" ,python-pygobject)
487 ("python-pytz" ,python-pytz)
488 ("python-requests" ,python-requests)))
489 (home-page "https://cozy.geigi.de/")
490 (synopsis "Modern audiobook player using GTK+")
492 "Cozy is a modern audiobook player written in GTK+.
494 Some of the current features:
497 @item Import your audiobooks into Cozy to browse them comfortably
498 @item Sort your audio books by author, reader & name
499 @item Remembers your playback position
501 @item Playback speed control
502 @item Search your library
504 @item Add multiple storage locations
505 @item Drag & Drop to import new audio books
506 @item Support for DRM free mp3, m4a (aac, ALAC, …), flac, ogg, opus, wav files
507 @item Mpris integration (Media keys & playback info for desktop environment)
509 ;; TODO: Unbundle python-inject.
510 (license (list license:gpl3+ ;cozy
511 license:asl2.0)))) ;python-inject (bundled dependency)
519 (uri (string-append "https://github.com/rzvncj/xCHM"
520 "/releases/download/"
521 version "/xchm-" version ".tar.gz"))
524 "0aw6bysqiwbw75n3ad229ihlmh7chqs1wlxm0398z3lfp2y6n7qf"))))
525 (build-system gnu-build-system)
527 `(("wxwidgets" ,wxwidgets)
530 `(("pkg-config" ,pkg-config)))
531 (home-page "https://github.com/rzvncj/xCHM")
532 (synopsis "CHM file viewer")
533 (description "xCHM is a graphical CHM file viewer. It is a frontend to
534 the CHM library CHMLIB.")
535 (license license:gpl2+)))