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