gnu: calibre: Unbundle liberation fonts.
[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>
9acd40fe 3;;; Copyright © 2016 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>
947ae545
AE
6;;;
7;;; This file is part of GNU Guix.
8;;;
9;;; GNU Guix is free software; you can redistribute it and/or modify it
10;;; under the terms of the GNU General Public License as published by
11;;; the Free Software Foundation; either version 3 of the License, or (at
12;;; your option) any later version.
13;;;
14;;; GNU Guix is distributed in the hope that it will be useful, but
15;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;;; GNU General Public License for more details.
18;;;
19;;; You should have received a copy of the GNU General Public License
20;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22(define-module (gnu packages ebook)
b8ac8c28 23 #:use-module ((guix licenses) #:select (gpl3 lgpl2.1+))
947ae545
AE
24 #:use-module (guix packages)
25 #:use-module (guix download)
a34816ef 26 #:use-module (guix build-system gnu)
b8ac8c28
AE
27 #:use-module (gnu packages)
28 #:use-module (guix build-system python)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages databases)
b3399a09 31 #:use-module (gnu packages fonts)
b8ac8c28
AE
32 #:use-module (gnu packages fontutils)
33 #:use-module (gnu packages freedesktop)
34 #:use-module (gnu packages glib)
35 #:use-module (gnu packages icu4c)
36 #:use-module (gnu packages image)
b8ac8c28
AE
37 #:use-module (gnu packages libusb)
38 #:use-module (gnu packages pdf)
39 #:use-module (gnu packages pkg-config)
40 #:use-module (gnu packages python)
41 #:use-module (gnu packages qt)
cc2b77df 42 #:use-module (gnu packages tls)
d94a99ec 43 #:use-module (gnu packages web)
b8ac8c28 44 #:use-module (gnu packages xorg))
947ae545
AE
45
46(define-public chmlib
47 (package
48 (name "chmlib")
49 (version "0.40")
50 (source (origin
51 (method url-fetch)
52 (uri (string-append "http://www.jedrea.com/chmlib/chmlib-"
53 version ".tar.bz2"))
54 (sha256
55 (base32
a34816ef 56 "18zzb4x3z0d7fjh1x5439bs62dmgsi4c1pg3qyr7h5gp1i5xcj9l"))
fc1adab1 57 (patches (search-patches "chmlib-inttypes.patch"))))
947ae545
AE
58 (build-system gnu-build-system)
59 (home-page "http://www.jedrea.com/chmlib/")
60 (synopsis "Library for CHM files")
61 (description "CHMLIB is a library for dealing with ITSS/CHM format files.")
71e1de33 62 (license lgpl2.1+)))
b8ac8c28
AE
63
64(define-public calibre
65 (package
66 (name "calibre")
cd6171c1 67 (version "2.85.1")
b8ac8c28
AE
68 (source
69 (origin
70 (method url-fetch)
71 (uri (string-append "http://download.calibre-ebook.com/"
72 version "/calibre-"
73 version ".tar.xz"))
74 (sha256
9acd40fe 75 (base32
cd6171c1 76 "1g8s0kp1gj05yysfgqpp2lgrxvzc0fsny1hwzx5jh9hvqn0b53cc"))
b8ac8c28
AE
77 ;; Remove non-free or doubtful code, see
78 ;; https://lists.gnu.org/archive/html/guix-devel/2015-02/msg00478.html
79 (modules '((guix build utils)))
80 (snippet
81 '(begin
29ec0851 82 (delete-file-recursively "src/calibre/ebooks/markdown")
b8ac8c28 83 (delete-file-recursively "src/unrar")
29ec0851 84 (delete-file "src/odf/thumbnail.py")
b3399a09 85 (delete-file-recursively "resources/fonts/liberation")
29ec0851
BT
86 (substitute* (find-files "." "\\.py")
87 (("calibre\\.ebooks\\.markdown") "markdown"))
88 #t))
fc1adab1 89 (patches (search-patches "calibre-drop-unrar.patch"
d94a99ec 90 "calibre-use-packaged-feedparser.patch"
7010d231 91 "calibre-dont-load-remote-icons.patch"
fc1adab1 92 "calibre-no-updates-dialog.patch"))))
b8ac8c28
AE
93 (build-system python-build-system)
94 (native-inputs
95 `(("pkg-config" ,pkg-config)
b3399a09 96 ("font-liberation" ,font-liberation)
c5ea9120 97 ("qtbase" ,qtbase) ; for qmake
b8ac8c28
AE
98 ;; xdg-utils is supposed to be used for desktop integration, but it
99 ;; also creates lots of messages
100 ;; mkdir: cannot create directory '/homeless-shelter': Permission denied
101 ("xdg-utils" ,xdg-utils)))
102 ;; FIXME: The following are missing inputs according to the documentation,
103 ;; but the package can apparently be used without them,
104 ;; They may need to be added if a deficiency is detected.
105 ;; BeautifulSoup >= 3.0.5
106 ;; dnspython >= 1.6.0
107 ;; poppler >= 0.20.2
108 ;; libwmf >= 0.2.8
109 ;; psutil >= 0.6.1
110 ;; python-pygments >= 2.0.1 ; used for ebook editing
111 (inputs
112 `(("chmlib" ,chmlib)
113 ("fontconfig" ,fontconfig)
114 ("glib" ,glib)
115 ("icu4c" ,icu4c)
b8ac8c28
AE
116 ("libmtp" ,libmtp)
117 ("libpng" ,libpng)
118 ("libusb" ,libusb)
119 ("libxrender" ,libxrender)
df00e148 120 ("openssl" ,openssl)
b8ac8c28
AE
121 ("podofo" ,podofo)
122 ("python" ,python-2)
123 ("python2-apsw" ,python2-apsw)
124 ("python2-cssselect" ,python2-cssselect)
125 ("python2-cssutils" ,python2-cssutils)
126 ("python2-dateutil" ,python2-dateutil)
127 ("python2-dbus" ,python2-dbus)
d94a99ec 128 ("python2-feedparser" ,python2-feedparser)
b8ac8c28 129 ("python2-lxml" ,python2-lxml)
29ec0851 130 ("python2-markdown" ,python2-markdown)
b8ac8c28
AE
131 ("python2-mechanize" ,python2-mechanize)
132 ("python2-netifaces" ,python2-netifaces)
2fbec762 133 ("python2-pillow" ,python2-pillow)
c5ea9120 134 ("python2-pyqt" ,python2-pyqt)
b8ac8c28 135 ("python2-sip" ,python2-sip)
b8ac8c28
AE
136 ("sqlite" ,sqlite)))
137 (arguments
138 `(#:python ,python-2
139 #:test-target "check"
140 #:tests? #f ; FIXME: enable once flake8 is packaged
e89aceab
HG
141 ;; Calibre is using setuptools by itself, but the setup.py is not
142 ;; compatible with the shim wrapper (taken from pip) we are using.
143 #:use-setuptools? #f
b8ac8c28 144 #:phases
b111bdb6
AG
145 (modify-phases %standard-phases
146 (add-before 'build 'configure
b8ac8c28
AE
147 (lambda* (#:key inputs #:allow-other-keys)
148 (let ((podofo (assoc-ref inputs "podofo"))
149 (pyqt (assoc-ref inputs "python2-pyqt")))
150 (substitute* "setup/build_environment.py"
151 (("sys.prefix") (string-append "'" pyqt "'")))
152 (setenv "PODOFO_INC_DIR" (string-append podofo "/include/podofo"))
b3399a09
BT
153 (setenv "PODOFO_LIB_DIR" (string-append podofo "/lib")))))
154 (add-after 'install 'install-font-liberation
155 (lambda* (#:key inputs outputs #:allow-other-keys)
156 (for-each (lambda (file)
157 (install-file file (string-append
158 (assoc-ref outputs "out")
159 "/share/calibre/fonts/liberation")))
160 (find-files (string-append
161 (assoc-ref inputs "font-liberation")
162 "/share/fonts/truetype")))
163 #t)))))
b8ac8c28
AE
164 (home-page "http://calibre-ebook.com/")
165 (synopsis "E-book library management software")
166 (description "Calibre is an ebook library manager. It can view, convert
167and catalog ebooks in most of the major ebook formats. It can also talk
168to many ebook reader devices. It can go out to the Internet and fetch
169metadata for books. It can download newspapers and convert them into
170ebooks for convenient reading.")
171 (license gpl3))) ; some files are under various other licenses, see COPYRIGHT