gnu: Add fbreader.
[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.0.0")
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 "1zhk7bvgr973dd18x4wp48kzai29qqqi5qcy72sxc4wcbk2sbnkw"))
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-recursively "src/unrar")
92 (delete-file "src/odf/thumbnail.py")
93 (delete-file-recursively "resources/fonts/liberation")
94 (substitute* (find-files "." "\\.py")
95 (("calibre\\.ebooks\\.markdown") "markdown"))
96 #t))
97 (patches (search-patches "calibre-drop-unrar.patch"
98 "calibre-use-packaged-feedparser.patch"
99 "calibre-no-updates-dialog.patch"))))
100 (build-system python-build-system)
101 (native-inputs
102 `(("pkg-config" ,pkg-config)
103 ("font-liberation" ,font-liberation)
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 ("glib" ,glib)
115 ("icu4c" ,icu4c)
116 ("libmtp" ,libmtp)
117 ("libpng" ,libpng)
118 ("libusb" ,libusb)
119 ("libxrender" ,libxrender)
120 ("openssl" ,openssl)
121 ("podofo" ,podofo)
122 ("poppler" ,poppler)
123 ("python" ,python-2)
124 ("python2-apsw" ,python2-apsw)
125 ("python2-chardet" ,python2-chardet)
126 ("python2-cssselect" ,python2-cssselect)
127 ("python2-cssutils" ,python2-cssutils)
128 ("python2-dateutil" ,python2-dateutil)
129 ("python2-dbus" ,python2-dbus)
130 ("python2-dnspython" ,python2-dnspython)
131 ("python2-feedparser" ,python2-feedparser)
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 ("sqlite" ,sqlite)))
144 (arguments
145 `(#:python ,python-2
146 #:test-target "check"
147 #:tests? #f ; FIXME: enable once flake8 is packaged
148 ;; Calibre is using setuptools by itself, but the setup.py is not
149 ;; compatible with the shim wrapper (taken from pip) we are using.
150 #:use-setuptools? #f
151 #:phases
152 (modify-phases %standard-phases
153 (add-after 'unpack 'patch-source
154 (lambda _
155 (substitute* "src/calibre/linux.py"
156 ;; We can't use the uninstaller in Guix. Don't build it.
157 (("self\\.create_uninstaller()") ""))
158 #t))
159 (add-after 'unpack 'dont-load-remote-icons
160 (lambda _
161 (substitute* "setup/plugins_mirror.py"
162 (("href=\"//calibre-ebook.com/favicon.ico\"")
163 "href=\"favicon.ico\""))
164 #t))
165 (add-before 'build 'configure
166 (lambda* (#:key inputs #:allow-other-keys)
167 (let ((podofo (assoc-ref inputs "podofo"))
168 (pyqt (assoc-ref inputs "python2-pyqt")))
169 (substitute* "setup/build_environment.py"
170 (("sys.prefix") (string-append "'" pyqt "'")))
171 (setenv "PODOFO_INC_DIR" (string-append podofo "/include/podofo"))
172 (setenv "PODOFO_LIB_DIR" (string-append podofo "/lib")))))
173 (add-after 'install 'install-font-liberation
174 (lambda* (#:key inputs outputs #:allow-other-keys)
175 (for-each (lambda (file)
176 (install-file file (string-append
177 (assoc-ref outputs "out")
178 "/share/calibre/fonts/liberation")))
179 (find-files (string-append
180 (assoc-ref inputs "font-liberation")
181 "/share/fonts/truetype")))
182 #t)))))
183 (home-page "http://calibre-ebook.com/")
184 (synopsis "E-book library management software")
185 (description "Calibre is an ebook library manager. It can view, convert
186 and catalog ebooks in most of the major ebook formats. It can also talk
187 to many ebook reader devices. It can go out to the Internet and fetch
188 metadata for books. It can download newspapers and convert them into
189 ebooks for convenient reading.")
190 ;; Calibre is largely GPL3+, but includes a number of components covered
191 ;; by other licenses. See COPYRIGHT for more details.
192 (license (list license:gpl3+
193 license:gpl2+
194 license:lgpl2.1+
195 license:lgpl2.1
196 license:bsd-3
197 license:expat
198 license:zpl2.1
199 license:asl2.0
200 license:public-domain
201 license:silofl1.1
202 license:cc-by-sa3.0))))
203
204 (define-public liblinebreak
205 (package
206 (name "liblinebreak")
207 (version "2.1")
208 (source (origin
209 (method url-fetch)
210 (uri (string-append "mirror://sourceforge/vimgadgets"
211 "/liblinebreak/" version
212 "/liblinebreak-" version ".tar.gz"))
213 (sha256
214 (base32
215 "1f36dbq7nc77lln1by2n1yl050g9dc63viawhs3gc3169mavm36x"))))
216 (build-system gnu-build-system)
217 (home-page "http://vimgadgets.sourceforge.net/liblinebreak/")
218 (synopsis "Library for detecting where linebreaks are allowed in text")
219 (description "@code{liblinebreak} is an implementation of the line
220 breaking algorithm as described in Unicode 6.0.0 Standard Annex 14,
221 Revision 26. It breaks lines that contain Unicode characters. It is
222 designed to be used in a generic text renderer.")
223 (license license:zlib)))
224
225 (define-public fbreader
226 (package
227 (name "fbreader")
228 (version "0.99.6")
229 (source (origin
230 (method url-fetch)
231 (uri (string-append "https://github.com/geometer/FBReader/"
232 "archive/" version "-freebsdport.tar.gz"))
233 (file-name (string-append name "-" version ".tar.gz"))
234 (sha256
235 (base32
236 "0gf1nl562fqkwlzcn6rgkp1j8jcixzmfsnwxbc0sm49zh8n3zqib"))))
237 (build-system gnu-build-system)
238 (inputs
239 `(("curl" ,curl)
240 ("expat" ,expat)
241 ("fribidi" ,fribidi)
242 ("glib" ,glib)
243 ("gtk+-2" ,gtk+-2)
244 ("libjpeg" ,libjpeg)
245 ("liblinebreak" ,liblinebreak)
246 ("libxft" ,libxft)
247 ("sqlite" ,sqlite)
248 ("zlib" ,zlib)))
249 (native-inputs
250 `(("pkg-config" ,pkg-config)))
251 (arguments
252 `(#:tests? #f ; No tests exist.
253 #:make-flags `("CC=gcc" "TARGET_ARCH=desktop" "UI_TYPE=gtk"
254 "TARGET_STATUS=release"
255 ,(string-append "INSTALLDIR="
256 (assoc-ref %outputs "out"))
257 ,(string-append "LDFLAGS=-Wl,-rpath="
258 (assoc-ref %outputs "out") "/lib"))
259 #:phases
260 (modify-phases %standard-phases
261 (delete 'configure))))
262 (home-page "https://fbreader.org/")
263 (synopsis "E-Book reader")
264 (description "@code{fbreader} is an E-Book reader. It supports the
265 following formats:
266
267 @enumerate
268 @item CHM
269 @item Docbook
270 @item FB2
271 @item HTML
272 @item OEB
273 @item PDB
274 @item RTF
275 @item TCR
276 @item TXT
277 @item XHTML
278 @end enumerate")
279 (license license:gpl2+)))