gnu: Update calibre to 3.0.0.
[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 databases)
32 #:use-module (gnu packages fonts)
33 #:use-module (gnu packages fontutils)
34 #:use-module (gnu packages freedesktop)
35 #:use-module (gnu packages gnome)
36 #:use-module (gnu packages glib)
37 #:use-module (gnu packages icu4c)
38 #:use-module (gnu packages image)
39 #:use-module (gnu packages libusb)
40 #:use-module (gnu packages pdf)
41 #:use-module (gnu packages pkg-config)
42 #:use-module (gnu packages python)
43 #:use-module (gnu packages qt)
44 #:use-module (gnu packages tls)
45 #:use-module (gnu packages web)
46 #:use-module (gnu packages xorg))
47
48 (define-public chmlib
49 (package
50 (name "chmlib")
51 (version "0.40")
52 (source (origin
53 (method url-fetch)
54 (uri (string-append "http://www.jedrea.com/chmlib/chmlib-"
55 version ".tar.bz2"))
56 (sha256
57 (base32
58 "18zzb4x3z0d7fjh1x5439bs62dmgsi4c1pg3qyr7h5gp1i5xcj9l"))
59 (patches (search-patches "chmlib-inttypes.patch"))))
60 (build-system gnu-build-system)
61 (home-page "http://www.jedrea.com/chmlib/")
62 (synopsis "Library for CHM files")
63 (description "CHMLIB is a library for dealing with ITSS/CHM format files.")
64 (license license:lgpl2.1+)))
65
66 (define-public calibre
67 (package
68 (name "calibre")
69 (version "3.0.0")
70 (source
71 (origin
72 (method url-fetch)
73 (uri (string-append "http://download.calibre-ebook.com/"
74 version "/calibre-"
75 version ".tar.xz"))
76 (sha256
77 (base32
78 "1zhk7bvgr973dd18x4wp48kzai29qqqi5qcy72sxc4wcbk2sbnkw"))
79 ;; Remove non-free or doubtful code, see
80 ;; https://lists.gnu.org/archive/html/guix-devel/2015-02/msg00478.html
81 (modules '((guix build utils)))
82 (snippet
83 '(begin
84 (delete-file-recursively "src/calibre/ebooks/markdown")
85 (delete-file-recursively "src/unrar")
86 (delete-file "src/odf/thumbnail.py")
87 (delete-file-recursively "resources/fonts/liberation")
88 (substitute* (find-files "." "\\.py")
89 (("calibre\\.ebooks\\.markdown") "markdown"))
90 #t))
91 (patches (search-patches "calibre-drop-unrar.patch"
92 "calibre-use-packaged-feedparser.patch"
93 "calibre-no-updates-dialog.patch"))))
94 (build-system python-build-system)
95 (native-inputs
96 `(("pkg-config" ,pkg-config)
97 ("font-liberation" ,font-liberation)
98 ("qtbase" ,qtbase) ; for qmake
99 ;; xdg-utils is supposed to be used for desktop integration, but it
100 ;; also creates lots of messages
101 ;; mkdir: cannot create directory '/homeless-shelter': Permission denied
102 ("python2-flake8" ,python2-flake8)
103 ("xdg-utils" ,xdg-utils)))
104 ;; Beautifulsoup3 is bundled but obsolete and not packaged, so just leave it bundled.
105 (inputs
106 `(("chmlib" ,chmlib)
107 ("fontconfig" ,fontconfig)
108 ("glib" ,glib)
109 ("icu4c" ,icu4c)
110 ("libmtp" ,libmtp)
111 ("libpng" ,libpng)
112 ("libusb" ,libusb)
113 ("libxrender" ,libxrender)
114 ("openssl" ,openssl)
115 ("podofo" ,podofo)
116 ("poppler" ,poppler)
117 ("python" ,python-2)
118 ("python2-apsw" ,python2-apsw)
119 ("python2-chardet" ,python2-chardet)
120 ("python2-cssselect" ,python2-cssselect)
121 ("python2-cssutils" ,python2-cssutils)
122 ("python2-dateutil" ,python2-dateutil)
123 ("python2-dbus" ,python2-dbus)
124 ("python2-dnspython" ,python2-dnspython)
125 ("python2-feedparser" ,python2-feedparser)
126 ("python2-lxml" ,python2-lxml)
127 ("python2-markdown" ,python2-markdown)
128 ("python2-mechanize" ,python2-mechanize)
129 ("python2-netifaces" ,python2-netifaces)
130 ("python2-pillow" ,python2-pillow)
131 ("python2-pygments" ,python2-pygments)
132 ("python2-pyqt" ,python2-pyqt)
133 ("python2-sip" ,python2-sip)
134 ("python2-regex" ,python2-regex)
135 ("sqlite" ,sqlite)))
136 (arguments
137 `(#:python ,python-2
138 #:test-target "check"
139 #:tests? #f ; FIXME: enable once flake8 is packaged
140 ;; Calibre is using setuptools by itself, but the setup.py is not
141 ;; compatible with the shim wrapper (taken from pip) we are using.
142 #:use-setuptools? #f
143 #:phases
144 (modify-phases %standard-phases
145 (add-after 'unpack 'patch-source
146 (lambda _
147 (substitute* "src/calibre/linux.py"
148 ;; We can't use the uninstaller in Guix. Don't build it.
149 (("self\\.create_uninstaller()") ""))
150 #t))
151 (add-after 'unpack 'dont-load-remote-icons
152 (lambda _
153 (substitute* "setup/plugins_mirror.py"
154 (("href=\"//calibre-ebook.com/favicon.ico\"")
155 "href=\"favicon.ico\""))
156 #t))
157 (add-before 'build 'configure
158 (lambda* (#:key inputs #:allow-other-keys)
159 (let ((podofo (assoc-ref inputs "podofo"))
160 (pyqt (assoc-ref inputs "python2-pyqt")))
161 (substitute* "setup/build_environment.py"
162 (("sys.prefix") (string-append "'" pyqt "'")))
163 (setenv "PODOFO_INC_DIR" (string-append podofo "/include/podofo"))
164 (setenv "PODOFO_LIB_DIR" (string-append podofo "/lib")))))
165 (add-after 'install 'install-font-liberation
166 (lambda* (#:key inputs outputs #:allow-other-keys)
167 (for-each (lambda (file)
168 (install-file file (string-append
169 (assoc-ref outputs "out")
170 "/share/calibre/fonts/liberation")))
171 (find-files (string-append
172 (assoc-ref inputs "font-liberation")
173 "/share/fonts/truetype")))
174 #t)))))
175 (home-page "http://calibre-ebook.com/")
176 (synopsis "E-book library management software")
177 (description "Calibre is an ebook library manager. It can view, convert
178 and catalog ebooks in most of the major ebook formats. It can also talk
179 to many ebook reader devices. It can go out to the Internet and fetch
180 metadata for books. It can download newspapers and convert them into
181 ebooks for convenient reading.")
182 ;; Calibre is largely GPL3+, but includes a number of components covered
183 ;; by other licenses. See COPYRIGHT for more details.
184 (license (list license:gpl3+
185 license:gpl2+
186 license:lgpl2.1+
187 license:lgpl2.1
188 license:bsd-3
189 license:expat
190 license:zpl2.1
191 license:asl2.0
192 license:public-domain
193 license:silofl1.1
194 license:cc-by-sa3.0))))