gnu: calibre: Fix build with python-msgpack >= 1.0.
[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>
947ae545
AE
8;;;
9;;; This file is part of GNU Guix.
10;;;
11;;; GNU Guix is free software; you can redistribute it and/or modify it
12;;; under the terms of the GNU General Public License as published by
13;;; the Free Software Foundation; either version 3 of the License, or (at
14;;; your option) any later version.
15;;;
16;;; GNU Guix is distributed in the hope that it will be useful, but
17;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;;; GNU General Public License for more details.
20;;;
21;;; You should have received a copy of the GNU General Public License
22;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24(define-module (gnu packages ebook)
affaf98f 25 #:use-module ((guix licenses) #:prefix license:)
947ae545
AE
26 #:use-module (guix packages)
27 #:use-module (guix download)
6f0ae143 28 #:use-module (guix git-download)
a34816ef 29 #:use-module (guix build-system gnu)
b8ac8c28
AE
30 #:use-module (gnu packages)
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
AE
47 #:use-module (gnu packages libusb)
48 #:use-module (gnu packages pdf)
49 #:use-module (gnu packages pkg-config)
50 #:use-module (gnu packages python)
1b2f753d 51 #:use-module (gnu packages python-web)
44d10b1f 52 #:use-module (gnu packages python-xyz)
b8ac8c28 53 #:use-module (gnu packages qt)
9ef5940c 54 #:use-module (gnu packages serialization)
cd0322a3 55 #:use-module (gnu packages sqlite)
33dc54b0 56 #:use-module (gnu packages time)
cc2b77df 57 #:use-module (gnu packages tls)
d94a99ec 58 #:use-module (gnu packages web)
d6ef422f 59 #:use-module (gnu packages xml)
7c041187
JL
60 #:use-module (gnu packages xorg)
61 #:use-module (gnu packages wxwidgets))
947ae545
AE
62
63(define-public chmlib
64 (package
65 (name "chmlib")
66 (version "0.40")
67 (source (origin
68 (method url-fetch)
69 (uri (string-append "http://www.jedrea.com/chmlib/chmlib-"
70 version ".tar.bz2"))
71 (sha256
72 (base32
a34816ef 73 "18zzb4x3z0d7fjh1x5439bs62dmgsi4c1pg3qyr7h5gp1i5xcj9l"))
fc1adab1 74 (patches (search-patches "chmlib-inttypes.patch"))))
947ae545
AE
75 (build-system gnu-build-system)
76 (home-page "http://www.jedrea.com/chmlib/")
77 (synopsis "Library for CHM files")
78 (description "CHMLIB is a library for dealing with ITSS/CHM format files.")
affaf98f 79 (license license:lgpl2.1+)))
b8ac8c28
AE
80
81(define-public calibre
82 (package
83 (name "calibre")
ee3ce0d7 84 (version "3.42.0")
b8ac8c28
AE
85 (source
86 (origin
87 (method url-fetch)
88 (uri (string-append "http://download.calibre-ebook.com/"
89 version "/calibre-"
90 version ".tar.xz"))
91 (sha256
9acd40fe 92 (base32
ee3ce0d7 93 "0ymdhws3cb44p3fb24vln1wx6s7qnb8rr241jvm6qbj5rnp984dm"))
68435a7f 94 ;; Unbundle python2-odfpy.
b8ac8c28
AE
95 ;; https://lists.gnu.org/archive/html/guix-devel/2015-02/msg00478.html
96 (modules '((guix build utils)))
97 (snippet
98 '(begin
68435a7f 99 (delete-file-recursively "src/odf")
f3f017db
BT
100 (delete-file "resources/viewer.js")
101 (delete-file "resources/viewer.html")
102 (delete-file "resources/mozilla-ca-certs.pem")
103 (delete-file "resources/calibre-portable.bat")
104 (delete-file "resources/calibre-portable.sh")
68435a7f 105 #t))
15871b40 106 (patches (search-patches "calibre-no-updates-dialog.patch"
3e4ce1cc 107 "calibre-msgpack-compat.patch"
f89f5aba 108 "calibre-remove-test-bs4.patch" ; TODO: fix test.
cbe399e7 109 "calibre-remove-test-sqlite.patch" ; TODO: fix test.
15871b40 110 "calibre-remove-test-unrar.patch"))))
b8ac8c28
AE
111 (build-system python-build-system)
112 (native-inputs
113 `(("pkg-config" ,pkg-config)
c5ea9120 114 ("qtbase" ,qtbase) ; for qmake
9b7dcc27 115 ("python2-flake8" ,python2-flake8)
b8ac8c28 116 ("xdg-utils" ,xdg-utils)))
9b7dcc27 117 ;; Beautifulsoup3 is bundled but obsolete and not packaged, so just leave it bundled.
b8ac8c28
AE
118 (inputs
119 `(("chmlib" ,chmlib)
120 ("fontconfig" ,fontconfig)
13068a8c 121 ("font-liberation" ,font-liberation)
b8ac8c28
AE
122 ("glib" ,glib)
123 ("icu4c" ,icu4c)
d243b41d 124 ("js-mathjax" ,js-mathjax)
b8ac8c28
AE
125 ("libmtp" ,libmtp)
126 ("libpng" ,libpng)
127 ("libusb" ,libusb)
df00e148 128 ("openssl" ,openssl)
9132212f 129 ("optipng" ,optipng)
b8ac8c28 130 ("podofo" ,podofo)
9b7dcc27 131 ("poppler" ,poppler)
b8ac8c28
AE
132 ("python" ,python-2)
133 ("python2-apsw" ,python2-apsw)
eeba7d3a 134 ("python2-chardet" ,python2-chardet)
b8ac8c28 135 ("python2-cssselect" ,python2-cssselect)
4e6f8a14 136 ("python2-css-parser" ,python2-css-parser)
b8ac8c28
AE
137 ("python2-dateutil" ,python2-dateutil)
138 ("python2-dbus" ,python2-dbus)
9b7dcc27 139 ("python2-dnspython" ,python2-dnspython)
bf4a40db 140 ("python2-dukpy" ,python2-dukpy)
d94a99ec 141 ("python2-feedparser" ,python2-feedparser)
adc25b68 142 ("python2-html2text" ,python2-html2text)
026ebc14 143 ("python2-html5-parser" ,python2-html5-parser)
4f299020 144 ("python2-html5lib" ,python2-html5lib)
b8ac8c28 145 ("python2-lxml" ,python2-lxml)
29ec0851 146 ("python2-markdown" ,python2-markdown)
b8ac8c28 147 ("python2-mechanize" ,python2-mechanize)
9ef5940c
MR
148 ;; python2-msgpack is needed for the network content server to work.
149 ("python2-msgpack" ,python2-msgpack)
b8ac8c28 150 ("python2-netifaces" ,python2-netifaces)
68435a7f 151 ("python2-odfpy" ,python2-odfpy)
2fbec762 152 ("python2-pillow" ,python2-pillow)
4f299020 153 ("python2-psutil" ,python2-psutil)
9b7dcc27 154 ("python2-pygments" ,python2-pygments)
c5ea9120 155 ("python2-pyqt" ,python2-pyqt)
b8ac8c28 156 ("python2-sip" ,python2-sip)
f70f3407 157 ("python2-regex" ,python2-regex)
b8ac8c28
AE
158 ("sqlite" ,sqlite)))
159 (arguments
160 `(#:python ,python-2
e89aceab
HG
161 ;; Calibre is using setuptools by itself, but the setup.py is not
162 ;; compatible with the shim wrapper (taken from pip) we are using.
163 #:use-setuptools? #f
b8ac8c28 164 #:phases
b111bdb6 165 (modify-phases %standard-phases
1326166e
BT
166 (add-after 'unpack 'patch-source
167 (lambda _
168 (substitute* "src/calibre/linux.py"
169 ;; We can't use the uninstaller in Guix. Don't build it.
170 (("self\\.create_uninstaller()") ""))
171 #t))
f70f3407
RJ
172 (add-after 'unpack 'dont-load-remote-icons
173 (lambda _
174 (substitute* "setup/plugins_mirror.py"
175 (("href=\"//calibre-ebook.com/favicon.ico\"")
176 "href=\"favicon.ico\""))
177 #t))
b111bdb6 178 (add-before 'build 'configure
6e1ab5fa 179 (lambda* (#:key inputs outputs #:allow-other-keys)
b8ac8c28 180 (let ((podofo (assoc-ref inputs "podofo"))
6e1ab5fa
BT
181 (pyqt (assoc-ref inputs "python2-pyqt"))
182 (out (assoc-ref outputs "out")))
b8ac8c28
AE
183 (substitute* "setup/build_environment.py"
184 (("sys.prefix") (string-append "'" pyqt "'")))
b65b78ff
MO
185 (substitute* "src/calibre/ebooks/pdf/pdftohtml.py"
186 (("PDFTOHTML = 'pdftohtml'")
187 (string-append "PDFTOHTML = \"" (assoc-ref inputs "poppler")
6e1ab5fa
BT
188 "/bin/pdftohtml\"")))
189
190 ;; Calibre thinks we are installing desktop files into a home
191 ;; directory, but here we butcher the script in to installing
192 ;; to calibres /share directory.
193 (setenv "XDG_DATA_HOME" (string-append out "/share"))
194 (substitute* "src/calibre/linux.py"
195 (("'~/.local/share'") "''"))
196
b8ac8c28 197 (setenv "PODOFO_INC_DIR" (string-append podofo "/include/podofo"))
ae16afe9 198 (setenv "PODOFO_LIB_DIR" (string-append podofo "/lib"))
b01cde1a
BT
199 ;; This informs the tests we are a continuous integration
200 ;; environment and thus have no networking.
201 (setenv "CI" "true")
4bcd0647
BT
202 ;; The Qt test complains about being unable to load all image plugins, and I
203 ;; notice the available plugins list it shows lacks 'svg'. Adding qtsvg doesn't
204 ;; fix it, so I'm not sure how to fix it. TODO: Fix test and remove this.
205 (setenv "SKIP_QT_BUILD_TEST" "true")
ae16afe9 206 #t)))
d243b41d
BT
207 (add-after 'build 'build-extra
208 (lambda* (#:key inputs #:allow-other-keys)
421c5e92
BT
209 (invoke "python2" "setup.py" "mathjax""--system-mathjax"
210 "--path-to-mathjax" (string-append
211 (assoc-ref inputs "js-mathjax")
212 "/share/javascript/mathjax"))
b0038957 213 (invoke "python2" "setup.py" "rapydscript")))
d6dfe8b6
BT
214 (add-after 'install 'install-man-pages
215 (lambda* (#:key outputs #:allow-other-keys)
216 (copy-recursively
217 "man-pages"
218 (string-append (assoc-ref outputs "out") "/share/man"))
219 #t))
13068a8c
BT
220 ;; The font TTF files are used in some miscellaneous tests, so we
221 ;; unbundle them here to avoid patching the tests.
222 (add-after 'install 'unbundle-font-liberation
b3399a09 223 (lambda* (#:key inputs outputs #:allow-other-keys)
13068a8c
BT
224 (let ((font-dest (string-append (assoc-ref outputs "out")
225 "/share/calibre/fonts/liberation"))
226 (font-src (string-append (assoc-ref inputs "font-liberation")
227 "/share/fonts/truetype")))
228 (delete-file-recursively font-dest)
229 (symlink font-src font-dest))
b3399a09 230 #t)))))
2ea6d499 231 (home-page "https://calibre-ebook.com/")
b8ac8c28 232 (synopsis "E-book library management software")
8572adb2
TGR
233 (description "Calibre is an e-book library manager. It can view, convert
234and catalog e-books in most of the major e-book formats. It can also talk
235to many e-book reader devices. It can go out to the Internet and fetch
b8ac8c28 236metadata for books. It can download newspapers and convert them into
8572adb2 237e-books for convenient reading.")
affaf98f
BT
238 ;; Calibre is largely GPL3+, but includes a number of components covered
239 ;; by other licenses. See COPYRIGHT for more details.
240 (license (list license:gpl3+
241 license:gpl2+
242 license:lgpl2.1+
243 license:lgpl2.1
244 license:bsd-3
245 license:expat
246 license:zpl2.1
247 license:asl2.0
248 license:public-domain
249 license:silofl1.1
250 license:cc-by-sa3.0))))
84a52639
DM
251
252(define-public liblinebreak
253 (package
254 (name "liblinebreak")
255 (version "2.1")
256 (source (origin
257 (method url-fetch)
258 (uri (string-append "mirror://sourceforge/vimgadgets"
259 "/liblinebreak/" version
260 "/liblinebreak-" version ".tar.gz"))
261 (sha256
262 (base32
263 "1f36dbq7nc77lln1by2n1yl050g9dc63viawhs3gc3169mavm36x"))))
264 (build-system gnu-build-system)
265 (home-page "http://vimgadgets.sourceforge.net/liblinebreak/")
266 (synopsis "Library for detecting where linebreaks are allowed in text")
267 (description "@code{liblinebreak} is an implementation of the line
268breaking algorithm as described in Unicode 6.0.0 Standard Annex 14,
269Revision 26. It breaks lines that contain Unicode characters. It is
270designed to be used in a generic text renderer.")
271 (license license:zlib)))
d6ef422f
DM
272
273(define-public fbreader
274 (package
275 (name "fbreader")
276 (version "0.99.6")
277 (source (origin
6f0ae143
EF
278 (method git-fetch)
279 (uri (git-reference
280 (url "https://github.com/geometer/FBReader")
281 (commit (string-append version "-freebsdport"))))
282 (file-name (git-file-name name version))
d6ef422f
DM
283 (sha256
284 (base32
6f0ae143 285 "0c0s4silpax74kwfz3dfmzn4lkv6jsyb800vfak166vii0hvbv3d"))
152d6bf0 286 (patches (search-patches "fbreader-curl-7.62.patch"))))
d6ef422f
DM
287 (build-system gnu-build-system)
288 (inputs
289 `(("curl" ,curl)
290 ("expat" ,expat)
291 ("fribidi" ,fribidi)
292 ("glib" ,glib)
293 ("gtk+-2" ,gtk+-2)
294 ("libjpeg" ,libjpeg)
295 ("liblinebreak" ,liblinebreak)
296 ("libxft" ,libxft)
297 ("sqlite" ,sqlite)
298 ("zlib" ,zlib)))
299 (native-inputs
04842543
RH
300 `(("gcc" ,gcc-5)
301 ("pkg-config" ,pkg-config)))
d6ef422f
DM
302 (arguments
303 `(#:tests? #f ; No tests exist.
304 #:make-flags `("CC=gcc" "TARGET_ARCH=desktop" "UI_TYPE=gtk"
305 "TARGET_STATUS=release"
306 ,(string-append "INSTALLDIR="
307 (assoc-ref %outputs "out"))
308 ,(string-append "LDFLAGS=-Wl,-rpath="
309 (assoc-ref %outputs "out") "/lib"))
310 #:phases
311 (modify-phases %standard-phases
5dc5c5ea
EF
312 (delete 'configure)
313 (add-after 'unpack 'fix-install-locations
314 (lambda* (#:key outputs #:allow-other-keys)
315 (let ((out (assoc-ref outputs "out")))
316 (substitute* "fbreader/desktop/Makefile"
317 (("/usr") out))
318 #t))))))
d6ef422f
DM
319 (home-page "https://fbreader.org/")
320 (synopsis "E-Book reader")
321 (description "@code{fbreader} is an E-Book reader. It supports the
322following formats:
323
324@enumerate
325@item CHM
326@item Docbook
327@item FB2
328@item HTML
329@item OEB
330@item PDB
331@item RTF
332@item TCR
333@item TXT
334@item XHTML
335@end enumerate")
336 (license license:gpl2+)))
7c041187
JL
337
338(define-public xchm
339 (package
340 (name "xchm")
8cd23410 341 (version "1.31")
7c041187
JL
342 (source (origin
343 (method url-fetch)
344 (uri (string-append "https://github.com/rzvncj/xCHM"
345 "/releases/download/"
346 version "/xchm-" version ".tar.gz"))
347 (sha256
348 (base32
8cd23410 349 "0aw6bysqiwbw75n3ad229ihlmh7chqs1wlxm0398z3lfp2y6n7qf"))))
7c041187
JL
350 (build-system gnu-build-system)
351 (inputs
352 `(("wxwidgets" ,wxwidgets)
353 ("chmlib" ,chmlib)))
354 (native-inputs
355 `(("pkg-config" ,pkg-config)))
356 (home-page "https://github.com/rzvncj/xCHM")
357 (synopsis "CHM file viewer")
358 (description "xCHM is a graphical CHM file viewer. It is a frontend to
359the CHM library CHMLIB.")
360 (license license:gpl2+)))