| 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2015, 2016 Andreas Enge <andreas@enge.fr> |
| 3 | ;;; Copyright © 2016, 2018 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 | ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
| 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) |
| 25 | #:use-module ((guix licenses) #:prefix license:) |
| 26 | #:use-module (guix packages) |
| 27 | #:use-module (guix download) |
| 28 | #:use-module (guix git-download) |
| 29 | #:use-module (guix build-system gnu) |
| 30 | #:use-module (gnu packages) |
| 31 | #:use-module (guix build-system python) |
| 32 | #:use-module (gnu packages) |
| 33 | #:use-module (gnu packages compression) |
| 34 | #:use-module (gnu packages curl) |
| 35 | #:use-module (gnu packages databases) |
| 36 | #:use-module (gnu packages fonts) |
| 37 | #:use-module (gnu packages fontutils) |
| 38 | #:use-module (gnu packages freedesktop) |
| 39 | #:use-module (gnu packages fribidi) |
| 40 | #:use-module (gnu packages gtk) |
| 41 | #:use-module (gnu packages gnome) |
| 42 | #:use-module (gnu packages glib) |
| 43 | #:use-module (gnu packages icu4c) |
| 44 | #:use-module (gnu packages image) |
| 45 | #:use-module (gnu packages javascript) |
| 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) |
| 50 | #:use-module (gnu packages python-web) |
| 51 | #:use-module (gnu packages python-xyz) |
| 52 | #:use-module (gnu packages qt) |
| 53 | #:use-module (gnu packages serialization) |
| 54 | #:use-module (gnu packages sqlite) |
| 55 | #:use-module (gnu packages time) |
| 56 | #:use-module (gnu packages tls) |
| 57 | #:use-module (gnu packages web) |
| 58 | #:use-module (gnu packages xml) |
| 59 | #:use-module (gnu packages xorg)) |
| 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 |
| 71 | "18zzb4x3z0d7fjh1x5439bs62dmgsi4c1pg3qyr7h5gp1i5xcj9l")) |
| 72 | (patches (search-patches "chmlib-inttypes.patch")))) |
| 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.") |
| 77 | (license license:lgpl2.1+))) |
| 78 | |
| 79 | (define-public calibre |
| 80 | (package |
| 81 | (name "calibre") |
| 82 | (version "3.41.3") |
| 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 |
| 90 | (base32 |
| 91 | "167hhv4wimkjnyfgqkyqmaiixhicbxacy6190gps98jyj4csi8ra")) |
| 92 | ;; Unbundle python2-odfpy. |
| 93 | ;; https://lists.gnu.org/archive/html/guix-devel/2015-02/msg00478.html |
| 94 | (modules '((guix build utils))) |
| 95 | (snippet |
| 96 | '(begin |
| 97 | (delete-file-recursively "src/odf") |
| 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") |
| 103 | #t)) |
| 104 | (patches (search-patches "calibre-no-updates-dialog.patch" |
| 105 | "calibre-remove-test-bs4.patch" ; TODO: fix test. |
| 106 | "calibre-remove-test-sqlite.patch" ; TODO: fix test. |
| 107 | "calibre-remove-test-unrar.patch")))) |
| 108 | (build-system python-build-system) |
| 109 | (native-inputs |
| 110 | `(("pkg-config" ,pkg-config) |
| 111 | ("qtbase" ,qtbase) ; for qmake |
| 112 | ("python2-flake8" ,python2-flake8) |
| 113 | ("xdg-utils" ,xdg-utils))) |
| 114 | ;; Beautifulsoup3 is bundled but obsolete and not packaged, so just leave it bundled. |
| 115 | (inputs |
| 116 | `(("chmlib" ,chmlib) |
| 117 | ("fontconfig" ,fontconfig) |
| 118 | ("font-liberation" ,font-liberation) |
| 119 | ("glib" ,glib) |
| 120 | ("icu4c" ,icu4c) |
| 121 | ("js-mathjax" ,js-mathjax) |
| 122 | ("libmtp" ,libmtp) |
| 123 | ("libpng" ,libpng) |
| 124 | ("libusb" ,libusb) |
| 125 | ("openssl" ,openssl) |
| 126 | ("optipng" ,optipng) |
| 127 | ("podofo" ,podofo) |
| 128 | ("poppler" ,poppler) |
| 129 | ("python" ,python-2) |
| 130 | ("python2-apsw" ,python2-apsw) |
| 131 | ("python2-chardet" ,python2-chardet) |
| 132 | ("python2-cssselect" ,python2-cssselect) |
| 133 | ("python2-css-parser" ,python2-css-parser) |
| 134 | ("python2-dateutil" ,python2-dateutil) |
| 135 | ("python2-dbus" ,python2-dbus) |
| 136 | ("python2-dnspython" ,python2-dnspython) |
| 137 | ("python2-dukpy" ,python2-dukpy) |
| 138 | ("python2-feedparser" ,python2-feedparser) |
| 139 | ("python2-html2text" ,python2-html2text) |
| 140 | ("python2-html5-parser" ,python2-html5-parser) |
| 141 | ("python2-html5lib" ,python2-html5lib) |
| 142 | ("python2-lxml" ,python2-lxml) |
| 143 | ("python2-markdown" ,python2-markdown) |
| 144 | ("python2-mechanize" ,python2-mechanize) |
| 145 | ;; python2-msgpack is needed for the network content server to work. |
| 146 | ("python2-msgpack" ,python2-msgpack) |
| 147 | ("python2-netifaces" ,python2-netifaces) |
| 148 | ("python2-odfpy" ,python2-odfpy) |
| 149 | ("python2-pillow" ,python2-pillow) |
| 150 | ("python2-psutil" ,python2-psutil) |
| 151 | ("python2-pygments" ,python2-pygments) |
| 152 | ("python2-pyqt" ,python2-pyqt) |
| 153 | ("python2-sip" ,python2-sip) |
| 154 | ("python2-regex" ,python2-regex) |
| 155 | ("sqlite" ,sqlite))) |
| 156 | (arguments |
| 157 | `(#:python ,python-2 |
| 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 |
| 161 | #:phases |
| 162 | (modify-phases %standard-phases |
| 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)) |
| 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)) |
| 175 | (add-before 'build 'configure |
| 176 | (lambda* (#:key inputs outputs #:allow-other-keys) |
| 177 | (let ((podofo (assoc-ref inputs "podofo")) |
| 178 | (pyqt (assoc-ref inputs "python2-pyqt")) |
| 179 | (out (assoc-ref outputs "out"))) |
| 180 | (substitute* "setup/build_environment.py" |
| 181 | (("sys.prefix") (string-append "'" pyqt "'"))) |
| 182 | (substitute* "src/calibre/ebooks/pdf/pdftohtml.py" |
| 183 | (("PDFTOHTML = 'pdftohtml'") |
| 184 | (string-append "PDFTOHTML = \"" (assoc-ref inputs "poppler") |
| 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 | |
| 194 | (setenv "PODOFO_INC_DIR" (string-append podofo "/include/podofo")) |
| 195 | (setenv "PODOFO_LIB_DIR" (string-append podofo "/lib")) |
| 196 | ;; This informs the tests we are a continuous integration |
| 197 | ;; environment and thus have no networking. |
| 198 | (setenv "CI" "true") |
| 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") |
| 203 | #t))) |
| 204 | (add-after 'build 'build-extra |
| 205 | (lambda* (#:key inputs #:allow-other-keys) |
| 206 | (invoke "python2" "setup.py" "mathjax""--system-mathjax" "--path-to-mathjax" |
| 207 | (string-append (assoc-ref inputs "js-mathjax") "/share/javascript/mathjax")) |
| 208 | (invoke "python2" "setup.py" "rapydscript"))) |
| 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 |
| 212 | (lambda* (#:key inputs outputs #:allow-other-keys) |
| 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)) |
| 219 | #t))))) |
| 220 | (home-page "http://calibre-ebook.com/") |
| 221 | (synopsis "E-book library management software") |
| 222 | (description "Calibre is an e-book library manager. It can view, convert |
| 223 | and catalog e-books in most of the major e-book formats. It can also talk |
| 224 | to many e-book reader devices. It can go out to the Internet and fetch |
| 225 | metadata for books. It can download newspapers and convert them into |
| 226 | e-books for convenient reading.") |
| 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)))) |
| 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 |
| 257 | breaking algorithm as described in Unicode 6.0.0 Standard Annex 14, |
| 258 | Revision 26. It breaks lines that contain Unicode characters. It is |
| 259 | designed to be used in a generic text renderer.") |
| 260 | (license license:zlib))) |
| 261 | |
| 262 | (define-public fbreader |
| 263 | (package |
| 264 | (name "fbreader") |
| 265 | (version "0.99.6") |
| 266 | (source (origin |
| 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)) |
| 272 | (sha256 |
| 273 | (base32 |
| 274 | "0c0s4silpax74kwfz3dfmzn4lkv6jsyb800vfak166vii0hvbv3d")) |
| 275 | (patches (search-patches "fbreader-curl-7.62.patch")))) |
| 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 |
| 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)))))) |
| 307 | (home-page "https://fbreader.org/") |
| 308 | (synopsis "E-Book reader") |
| 309 | (description "@code{fbreader} is an E-Book reader. It supports the |
| 310 | following 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+))) |