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