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