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