gnu: calibre: Remove unrar test.
[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 Brendan Tildesley <brendan.tildesley@openmailbox.org>
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
61 (define-public chmlib
62 (package
63 (name "chmlib")
64 (version "0.40")
65 (source (origin
66 (method url-fetch)
67 (uri (string-append "http://www.jedrea.com/chmlib/chmlib-"
68 version ".tar.bz2"))
69 (sha256
70 (base32
71 "18zzb4x3z0d7fjh1x5439bs62dmgsi4c1pg3qyr7h5gp1i5xcj9l"))
72 (patches (search-patches "chmlib-inttypes.patch"))))
73 (build-system gnu-build-system)
74 (home-page "http://www.jedrea.com/chmlib/")
75 (synopsis "Library for CHM files")
76 (description "CHMLIB is a library for dealing with ITSS/CHM format files.")
77 (license license:lgpl2.1+)))
78
79 (define-public calibre
80 (package
81 (name "calibre")
82 (version "3.41.3")
83 (source
84 (origin
85 (method url-fetch)
86 (uri (string-append "http://download.calibre-ebook.com/"
87 version "/calibre-"
88 version ".tar.xz"))
89 (sha256
90 (base32
91 "167hhv4wimkjnyfgqkyqmaiixhicbxacy6190gps98jyj4csi8ra"))
92 ;; Remove non-free or doubtful code, see
93 ;; https://lists.gnu.org/archive/html/guix-devel/2015-02/msg00478.html
94 (modules '((guix build utils)))
95 (snippet
96 '(begin
97 (delete-file "src/odf/thumbnail.py")
98 #t))
99 (patches (search-patches "calibre-no-updates-dialog.patch"
100 "calibre-remove-test-unrar.patch"))))
101 (build-system python-build-system)
102 (native-inputs
103 `(("pkg-config" ,pkg-config)
104 ("qtbase" ,qtbase) ; for qmake
105 ;; xdg-utils is supposed to be used for desktop integration, but it
106 ;; also creates lots of messages
107 ;; mkdir: cannot create directory '/homeless-shelter': Permission denied
108 ("python2-flake8" ,python2-flake8)
109 ("xdg-utils" ,xdg-utils)))
110 ;; Beautifulsoup3 is bundled but obsolete and not packaged, so just leave it bundled.
111 (inputs
112 `(("chmlib" ,chmlib)
113 ("fontconfig" ,fontconfig)
114 ("font-liberation" ,font-liberation)
115 ("glib" ,glib)
116 ("icu4c" ,icu4c)
117 ("js-mathjax" ,js-mathjax)
118 ("libmtp" ,libmtp)
119 ("libpng" ,libpng)
120 ("libusb" ,libusb)
121 ("libxrender" ,libxrender)
122 ("openssl" ,openssl)
123 ("optipng" ,optipng)
124 ("podofo" ,podofo)
125 ("poppler" ,poppler)
126 ("python" ,python-2)
127 ("python2-apsw" ,python2-apsw)
128 ("python2-chardet" ,python2-chardet)
129 ("python2-cssselect" ,python2-cssselect)
130 ("python2-css-parser" ,python2-css-parser)
131 ("python2-dateutil" ,python2-dateutil)
132 ("python2-dbus" ,python2-dbus)
133 ("python2-dnspython" ,python2-dnspython)
134 ("python2-dukpy" ,python2-dukpy)
135 ("python2-feedparser" ,python2-feedparser)
136 ("python2-html2text" ,python2-html2text)
137 ("python2-html5-parser" ,python2-html5-parser)
138 ("python2-html5lib" ,python2-html5lib)
139 ("python2-lxml" ,python2-lxml)
140 ("python2-markdown" ,python2-markdown)
141 ("python2-mechanize" ,python2-mechanize)
142 ;; python2-msgpack is needed for the network content server to work.
143 ("python2-msgpack" ,python2-msgpack)
144 ("python2-netifaces" ,python2-netifaces)
145 ("python2-pillow" ,python2-pillow)
146 ("python2-psutil" ,python2-psutil)
147 ("python2-pygments" ,python2-pygments)
148 ("python2-pyqt" ,python2-pyqt)
149 ("python2-sip" ,python2-sip)
150 ("python2-regex" ,python2-regex)
151 ;; python2-unrardll is needed for decompressing RAR files.
152 ;; A program called 'pdf2html' is needed for reading PDF books
153 ;; in the web interface.
154 ("sqlite" ,sqlite)))
155 (arguments
156 `(#:python ,python-2
157 #:test-target "check"
158 #:tests? #f ; FIXME: enable once flake8 is packaged
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 #:allow-other-keys)
178 (let ((podofo (assoc-ref inputs "podofo"))
179 (pyqt (assoc-ref inputs "python2-pyqt")))
180 (substitute* "setup/build_environment.py"
181 (("sys.prefix") (string-append "'" pyqt "'")))
182 (substitute* "src/calibre/ebooks/pdf/pdftohtml.py"
183 (("PDFTOHTML = 'pdftohtml'")
184 (string-append "PDFTOHTML = \"" (assoc-ref inputs "poppler")
185 "/bin/pdftohtml\"")))
186 (setenv "PODOFO_INC_DIR" (string-append podofo "/include/podofo"))
187 (setenv "PODOFO_LIB_DIR" (string-append podofo "/lib"))
188 #t)))
189 (add-after 'build 'build-extra
190 (lambda* (#:key inputs #:allow-other-keys)
191 (invoke "python2" "setup.py" "mathjax""--system-mathjax" "--path-to-mathjax"
192 (string-append (assoc-ref inputs "js-mathjax") "/share/javascript/mathjax"))
193 (invoke "python2" "setup.py" "rapydscript")))
194 ;; The font TTF files are used in some miscellaneous tests, so we
195 ;; unbundle them here to avoid patching the tests.
196 (add-after 'install 'unbundle-font-liberation
197 (lambda* (#:key inputs outputs #:allow-other-keys)
198 (let ((font-dest (string-append (assoc-ref outputs "out")
199 "/share/calibre/fonts/liberation"))
200 (font-src (string-append (assoc-ref inputs "font-liberation")
201 "/share/fonts/truetype")))
202 (delete-file-recursively font-dest)
203 (symlink font-src font-dest))
204 #t))
205 (add-after 'unbundle-font-liberation 'install-mimetypes
206 (lambda* (#:key outputs #:allow-other-keys)
207 (install-file "resources/calibre-mimetypes.xml"
208 (string-append (assoc-ref outputs "out")
209 "/share/mime/packages"))
210 #t)))))
211 (home-page "http://calibre-ebook.com/")
212 (synopsis "E-book library management software")
213 (description "Calibre is an e-book library manager. It can view, convert
214 and catalog e-books in most of the major e-book formats. It can also talk
215 to many e-book reader devices. It can go out to the Internet and fetch
216 metadata for books. It can download newspapers and convert them into
217 e-books for convenient reading.")
218 ;; Calibre is largely GPL3+, but includes a number of components covered
219 ;; by other licenses. See COPYRIGHT for more details.
220 (license (list license:gpl3+
221 license:gpl2+
222 license:lgpl2.1+
223 license:lgpl2.1
224 license:bsd-3
225 license:expat
226 license:zpl2.1
227 license:asl2.0
228 license:public-domain
229 license:silofl1.1
230 license:cc-by-sa3.0))))
231
232 (define-public liblinebreak
233 (package
234 (name "liblinebreak")
235 (version "2.1")
236 (source (origin
237 (method url-fetch)
238 (uri (string-append "mirror://sourceforge/vimgadgets"
239 "/liblinebreak/" version
240 "/liblinebreak-" version ".tar.gz"))
241 (sha256
242 (base32
243 "1f36dbq7nc77lln1by2n1yl050g9dc63viawhs3gc3169mavm36x"))))
244 (build-system gnu-build-system)
245 (home-page "http://vimgadgets.sourceforge.net/liblinebreak/")
246 (synopsis "Library for detecting where linebreaks are allowed in text")
247 (description "@code{liblinebreak} is an implementation of the line
248 breaking algorithm as described in Unicode 6.0.0 Standard Annex 14,
249 Revision 26. It breaks lines that contain Unicode characters. It is
250 designed to be used in a generic text renderer.")
251 (license license:zlib)))
252
253 (define-public fbreader
254 (package
255 (name "fbreader")
256 (version "0.99.6")
257 (source (origin
258 (method git-fetch)
259 (uri (git-reference
260 (url "https://github.com/geometer/FBReader")
261 (commit (string-append version "-freebsdport"))))
262 (file-name (git-file-name name version))
263 (sha256
264 (base32
265 "0c0s4silpax74kwfz3dfmzn4lkv6jsyb800vfak166vii0hvbv3d"))
266 (patches (search-patches "fbreader-curl-7.62.patch"))))
267 (build-system gnu-build-system)
268 (inputs
269 `(("curl" ,curl)
270 ("expat" ,expat)
271 ("fribidi" ,fribidi)
272 ("glib" ,glib)
273 ("gtk+-2" ,gtk+-2)
274 ("libjpeg" ,libjpeg)
275 ("liblinebreak" ,liblinebreak)
276 ("libxft" ,libxft)
277 ("sqlite" ,sqlite)
278 ("zlib" ,zlib)))
279 (native-inputs
280 `(("pkg-config" ,pkg-config)))
281 (arguments
282 `(#:tests? #f ; No tests exist.
283 #:make-flags `("CC=gcc" "TARGET_ARCH=desktop" "UI_TYPE=gtk"
284 "TARGET_STATUS=release"
285 ,(string-append "INSTALLDIR="
286 (assoc-ref %outputs "out"))
287 ,(string-append "LDFLAGS=-Wl,-rpath="
288 (assoc-ref %outputs "out") "/lib"))
289 #:phases
290 (modify-phases %standard-phases
291 (delete 'configure)
292 (add-after 'unpack 'fix-install-locations
293 (lambda* (#:key outputs #:allow-other-keys)
294 (let ((out (assoc-ref outputs "out")))
295 (substitute* "fbreader/desktop/Makefile"
296 (("/usr") out))
297 #t))))))
298 (home-page "https://fbreader.org/")
299 (synopsis "E-Book reader")
300 (description "@code{fbreader} is an E-Book reader. It supports the
301 following formats:
302
303 @enumerate
304 @item CHM
305 @item Docbook
306 @item FB2
307 @item HTML
308 @item OEB
309 @item PDB
310 @item RTF
311 @item TCR
312 @item TXT
313 @item XHTML
314 @end enumerate")
315 (license license:gpl2+)))