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