gnu: calibre: Add python2-dukpy as an input.
[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 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 ;;;
8 ;;; This file is part of GNU Guix.
9 ;;;
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
14 ;;;
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
19 ;;;
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23 (define-module (gnu packages ebook)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix build-system gnu)
28 #:use-module (gnu packages)
29 #:use-module (guix build-system python)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages curl)
33 #:use-module (gnu packages databases)
34 #:use-module (gnu packages fonts)
35 #:use-module (gnu packages fontutils)
36 #:use-module (gnu packages freedesktop)
37 #:use-module (gnu packages fribidi)
38 #:use-module (gnu packages gtk)
39 #:use-module (gnu packages gnome)
40 #:use-module (gnu packages glib)
41 #:use-module (gnu packages icu4c)
42 #:use-module (gnu packages image)
43 #:use-module (gnu packages libusb)
44 #:use-module (gnu packages pdf)
45 #:use-module (gnu packages pkg-config)
46 #:use-module (gnu packages python)
47 #:use-module (gnu packages qt)
48 #:use-module (gnu packages serialization)
49 #:use-module (gnu packages tls)
50 #:use-module (gnu packages web)
51 #:use-module (gnu packages xml)
52 #:use-module (gnu packages xorg))
53
54 (define-public chmlib
55 (package
56 (name "chmlib")
57 (version "0.40")
58 (source (origin
59 (method url-fetch)
60 (uri (string-append "http://www.jedrea.com/chmlib/chmlib-"
61 version ".tar.bz2"))
62 (sha256
63 (base32
64 "18zzb4x3z0d7fjh1x5439bs62dmgsi4c1pg3qyr7h5gp1i5xcj9l"))
65 (patches (search-patches "chmlib-inttypes.patch"))))
66 (build-system gnu-build-system)
67 (home-page "http://www.jedrea.com/chmlib/")
68 (synopsis "Library for CHM files")
69 (description "CHMLIB is a library for dealing with ITSS/CHM format files.")
70 (license license:lgpl2.1+)))
71
72 (define-public calibre
73 (package
74 (name "calibre")
75 (version "3.11.1")
76 (source
77 (origin
78 (method url-fetch)
79 (uri (string-append "http://download.calibre-ebook.com/"
80 version "/calibre-"
81 version ".tar.xz"))
82 (sha256
83 (base32
84 "0kwza7iyyyfhq476z5fk9962iyd0qpgmzm1k36nqcy8sfjbk8mrl"))
85 ;; Remove non-free or doubtful code, see
86 ;; https://lists.gnu.org/archive/html/guix-devel/2015-02/msg00478.html
87 (modules '((guix build utils)))
88 (snippet
89 '(begin
90 (delete-file-recursively "src/calibre/ebooks/markdown")
91 (delete-file "src/odf/thumbnail.py")
92 (delete-file-recursively "resources/fonts/liberation")
93 (substitute* (find-files "." "\\.py")
94 (("calibre\\.ebooks\\.markdown") "markdown"))
95 #t))
96 (patches (search-patches "calibre-use-packaged-feedparser.patch"
97 "calibre-no-updates-dialog.patch"))))
98 (build-system python-build-system)
99 (native-inputs
100 `(("pkg-config" ,pkg-config)
101 ("font-liberation" ,font-liberation)
102 ("qtbase" ,qtbase) ; for qmake
103 ;; xdg-utils is supposed to be used for desktop integration, but it
104 ;; also creates lots of messages
105 ;; mkdir: cannot create directory '/homeless-shelter': Permission denied
106 ("python2-flake8" ,python2-flake8)
107 ("xdg-utils" ,xdg-utils)))
108 ;; Beautifulsoup3 is bundled but obsolete and not packaged, so just leave it bundled.
109 (inputs
110 `(("chmlib" ,chmlib)
111 ("fontconfig" ,fontconfig)
112 ("glib" ,glib)
113 ("icu4c" ,icu4c)
114 ("libmtp" ,libmtp)
115 ("libpng" ,libpng)
116 ("libusb" ,libusb)
117 ("libxrender" ,libxrender)
118 ("openssl" ,openssl)
119 ("podofo" ,podofo)
120 ("poppler" ,poppler)
121 ("python" ,python-2)
122 ("python2-apsw" ,python2-apsw)
123 ("python2-chardet" ,python2-chardet)
124 ("python2-cssselect" ,python2-cssselect)
125 ("python2-cssutils" ,python2-cssutils)
126 ("python2-dateutil" ,python2-dateutil)
127 ("python2-dbus" ,python2-dbus)
128 ("python2-dnspython" ,python2-dnspython)
129 ("python2-dukpy" ,python2-dukpy)
130 ("python2-feedparser" ,python2-feedparser)
131 ("python2-html5-parser" ,python2-html5-parser)
132 ("python2-lxml" ,python2-lxml)
133 ("python2-markdown" ,python2-markdown)
134 ("python2-mechanize" ,python2-mechanize)
135 ;; python2-msgpack is needed for the network content server to work.
136 ("python2-msgpack" ,python2-msgpack)
137 ("python2-netifaces" ,python2-netifaces)
138 ("python2-pillow" ,python2-pillow)
139 ("python2-pygments" ,python2-pygments)
140 ("python2-pyqt" ,python2-pyqt)
141 ("python2-sip" ,python2-sip)
142 ("python2-regex" ,python2-regex)
143 ;; python2-unrardll is needed for decompressing RAR files.
144 ;; A program called 'pdf2html' is needed for reading PDF books
145 ;; in the web interface.
146 ("sqlite" ,sqlite)))
147 (arguments
148 `(#:python ,python-2
149 #:test-target "check"
150 #:tests? #f ; FIXME: enable once flake8 is packaged
151 ;; Calibre is using setuptools by itself, but the setup.py is not
152 ;; compatible with the shim wrapper (taken from pip) we are using.
153 #:use-setuptools? #f
154 #:phases
155 (modify-phases %standard-phases
156 (add-after 'unpack 'patch-source
157 (lambda _
158 (substitute* "src/calibre/linux.py"
159 ;; We can't use the uninstaller in Guix. Don't build it.
160 (("self\\.create_uninstaller()") ""))
161 #t))
162 (add-after 'unpack 'dont-load-remote-icons
163 (lambda _
164 (substitute* "setup/plugins_mirror.py"
165 (("href=\"//calibre-ebook.com/favicon.ico\"")
166 "href=\"favicon.ico\""))
167 #t))
168 (add-before 'build 'configure
169 (lambda* (#:key inputs #:allow-other-keys)
170 (let ((podofo (assoc-ref inputs "podofo"))
171 (pyqt (assoc-ref inputs "python2-pyqt")))
172 (substitute* "setup/build_environment.py"
173 (("sys.prefix") (string-append "'" pyqt "'")))
174 (setenv "PODOFO_INC_DIR" (string-append podofo "/include/podofo"))
175 (setenv "PODOFO_LIB_DIR" (string-append podofo "/lib")))))
176 (add-after 'install 'install-font-liberation
177 (lambda* (#:key inputs outputs #:allow-other-keys)
178 (for-each (lambda (file)
179 (install-file file (string-append
180 (assoc-ref outputs "out")
181 "/share/calibre/fonts/liberation")))
182 (find-files (string-append
183 (assoc-ref inputs "font-liberation")
184 "/share/fonts/truetype")))
185 #t)))))
186 (home-page "http://calibre-ebook.com/")
187 (synopsis "E-book library management software")
188 (description "Calibre is an ebook library manager. It can view, convert
189 and catalog ebooks in most of the major ebook formats. It can also talk
190 to many ebook reader devices. It can go out to the Internet and fetch
191 metadata for books. It can download newspapers and convert them into
192 ebooks for convenient reading.")
193 ;; Calibre is largely GPL3+, but includes a number of components covered
194 ;; by other licenses. See COPYRIGHT for more details.
195 (license (list license:gpl3+
196 license:gpl2+
197 license:lgpl2.1+
198 license:lgpl2.1
199 license:bsd-3
200 license:expat
201 license:zpl2.1
202 license:asl2.0
203 license:public-domain
204 license:silofl1.1
205 license:cc-by-sa3.0))))
206
207 (define-public liblinebreak
208 (package
209 (name "liblinebreak")
210 (version "2.1")
211 (source (origin
212 (method url-fetch)
213 (uri (string-append "mirror://sourceforge/vimgadgets"
214 "/liblinebreak/" version
215 "/liblinebreak-" version ".tar.gz"))
216 (sha256
217 (base32
218 "1f36dbq7nc77lln1by2n1yl050g9dc63viawhs3gc3169mavm36x"))))
219 (build-system gnu-build-system)
220 (home-page "http://vimgadgets.sourceforge.net/liblinebreak/")
221 (synopsis "Library for detecting where linebreaks are allowed in text")
222 (description "@code{liblinebreak} is an implementation of the line
223 breaking algorithm as described in Unicode 6.0.0 Standard Annex 14,
224 Revision 26. It breaks lines that contain Unicode characters. It is
225 designed to be used in a generic text renderer.")
226 (license license:zlib)))
227
228 (define-public fbreader
229 (package
230 (name "fbreader")
231 (version "0.99.6")
232 (source (origin
233 (method url-fetch)
234 (uri (string-append "https://github.com/geometer/FBReader/"
235 "archive/" version "-freebsdport.tar.gz"))
236 (file-name (string-append name "-" version ".tar.gz"))
237 (sha256
238 (base32
239 "0gf1nl562fqkwlzcn6rgkp1j8jcixzmfsnwxbc0sm49zh8n3zqib"))))
240 (build-system gnu-build-system)
241 (inputs
242 `(("curl" ,curl)
243 ("expat" ,expat)
244 ("fribidi" ,fribidi)
245 ("glib" ,glib)
246 ("gtk+-2" ,gtk+-2)
247 ("libjpeg" ,libjpeg)
248 ("liblinebreak" ,liblinebreak)
249 ("libxft" ,libxft)
250 ("sqlite" ,sqlite)
251 ("zlib" ,zlib)))
252 (native-inputs
253 `(("pkg-config" ,pkg-config)))
254 (arguments
255 `(#:tests? #f ; No tests exist.
256 #:make-flags `("CC=gcc" "TARGET_ARCH=desktop" "UI_TYPE=gtk"
257 "TARGET_STATUS=release"
258 ,(string-append "INSTALLDIR="
259 (assoc-ref %outputs "out"))
260 ,(string-append "LDFLAGS=-Wl,-rpath="
261 (assoc-ref %outputs "out") "/lib"))
262 #:phases
263 (modify-phases %standard-phases
264 (delete 'configure))))
265 (home-page "https://fbreader.org/")
266 (synopsis "E-Book reader")
267 (description "@code{fbreader} is an E-Book reader. It supports the
268 following formats:
269
270 @enumerate
271 @item CHM
272 @item Docbook
273 @item FB2
274 @item HTML
275 @item OEB
276 @item PDB
277 @item RTF
278 @item TCR
279 @item TXT
280 @item XHTML
281 @end enumerate")
282 (license license:gpl2+)))