| 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, 2019 Brendan Tildesley <mail@brendan.scot> |
| 6 | ;;; Copyright © 2017 Roel Janssen <roel@gnu.org> |
| 7 | ;;; Copyright © 2018, 2019 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 gcc) |
| 41 | #:use-module (gnu packages gtk) |
| 42 | #:use-module (gnu packages gnome) |
| 43 | #:use-module (gnu packages glib) |
| 44 | #:use-module (gnu packages icu4c) |
| 45 | #:use-module (gnu packages image) |
| 46 | #:use-module (gnu packages javascript) |
| 47 | #:use-module (gnu packages libusb) |
| 48 | #:use-module (gnu packages pdf) |
| 49 | #:use-module (gnu packages pkg-config) |
| 50 | #:use-module (gnu packages python) |
| 51 | #:use-module (gnu packages python-web) |
| 52 | #:use-module (gnu packages python-xyz) |
| 53 | #:use-module (gnu packages qt) |
| 54 | #:use-module (gnu packages serialization) |
| 55 | #:use-module (gnu packages sqlite) |
| 56 | #:use-module (gnu packages time) |
| 57 | #:use-module (gnu packages tls) |
| 58 | #:use-module (gnu packages web) |
| 59 | #:use-module (gnu packages xml) |
| 60 | #:use-module (gnu packages xorg) |
| 61 | #:use-module (gnu packages wxwidgets)) |
| 62 | |
| 63 | (define-public chmlib |
| 64 | (package |
| 65 | (name "chmlib") |
| 66 | (version "0.40") |
| 67 | (source (origin |
| 68 | (method url-fetch) |
| 69 | (uri (string-append "http://www.jedrea.com/chmlib/chmlib-" |
| 70 | version ".tar.bz2")) |
| 71 | (sha256 |
| 72 | (base32 |
| 73 | "18zzb4x3z0d7fjh1x5439bs62dmgsi4c1pg3qyr7h5gp1i5xcj9l")) |
| 74 | (patches (search-patches "chmlib-inttypes.patch")))) |
| 75 | (build-system gnu-build-system) |
| 76 | (home-page "http://www.jedrea.com/chmlib/") |
| 77 | (synopsis "Library for CHM files") |
| 78 | (description "CHMLIB is a library for dealing with ITSS/CHM format files.") |
| 79 | (license license:lgpl2.1+))) |
| 80 | |
| 81 | (define-public calibre |
| 82 | (package |
| 83 | (name "calibre") |
| 84 | (version "3.42.0") |
| 85 | (source |
| 86 | (origin |
| 87 | (method url-fetch) |
| 88 | (uri (string-append "http://download.calibre-ebook.com/" |
| 89 | version "/calibre-" |
| 90 | version ".tar.xz")) |
| 91 | (sha256 |
| 92 | (base32 |
| 93 | "0ymdhws3cb44p3fb24vln1wx6s7qnb8rr241jvm6qbj5rnp984dm")) |
| 94 | ;; Unbundle python2-odfpy. |
| 95 | ;; https://lists.gnu.org/archive/html/guix-devel/2015-02/msg00478.html |
| 96 | (modules '((guix build utils))) |
| 97 | (snippet |
| 98 | '(begin |
| 99 | (delete-file-recursively "src/odf") |
| 100 | (delete-file "resources/viewer.js") |
| 101 | (delete-file "resources/viewer.html") |
| 102 | (delete-file "resources/mozilla-ca-certs.pem") |
| 103 | (delete-file "resources/calibre-portable.bat") |
| 104 | (delete-file "resources/calibre-portable.sh") |
| 105 | #t)) |
| 106 | (patches (search-patches "calibre-no-updates-dialog.patch" |
| 107 | "calibre-remove-test-bs4.patch" ; TODO: fix test. |
| 108 | "calibre-remove-test-sqlite.patch" ; TODO: fix test. |
| 109 | "calibre-remove-test-unrar.patch")))) |
| 110 | (build-system python-build-system) |
| 111 | (native-inputs |
| 112 | `(("pkg-config" ,pkg-config) |
| 113 | ("qtbase" ,qtbase) ; for qmake |
| 114 | ("python2-flake8" ,python2-flake8) |
| 115 | ("xdg-utils" ,xdg-utils))) |
| 116 | ;; Beautifulsoup3 is bundled but obsolete and not packaged, so just leave it bundled. |
| 117 | (inputs |
| 118 | `(("chmlib" ,chmlib) |
| 119 | ("fontconfig" ,fontconfig) |
| 120 | ("font-liberation" ,font-liberation) |
| 121 | ("glib" ,glib) |
| 122 | ("icu4c" ,icu4c) |
| 123 | ("js-mathjax" ,js-mathjax) |
| 124 | ("libmtp" ,libmtp) |
| 125 | ("libpng" ,libpng) |
| 126 | ("libusb" ,libusb) |
| 127 | ("openssl" ,openssl) |
| 128 | ("optipng" ,optipng) |
| 129 | ("podofo" ,podofo) |
| 130 | ("poppler" ,poppler) |
| 131 | ("python" ,python-2) |
| 132 | ("python2-apsw" ,python2-apsw) |
| 133 | ("python2-chardet" ,python2-chardet) |
| 134 | ("python2-cssselect" ,python2-cssselect) |
| 135 | ("python2-css-parser" ,python2-css-parser) |
| 136 | ("python2-dateutil" ,python2-dateutil) |
| 137 | ("python2-dbus" ,python2-dbus) |
| 138 | ("python2-dnspython" ,python2-dnspython) |
| 139 | ("python2-dukpy" ,python2-dukpy) |
| 140 | ("python2-feedparser" ,python2-feedparser) |
| 141 | ("python2-html2text" ,python2-html2text) |
| 142 | ("python2-html5-parser" ,python2-html5-parser) |
| 143 | ("python2-html5lib" ,python2-html5lib) |
| 144 | ("python2-lxml" ,python2-lxml) |
| 145 | ("python2-markdown" ,python2-markdown) |
| 146 | ("python2-mechanize" ,python2-mechanize) |
| 147 | ;; python2-msgpack is needed for the network content server to work. |
| 148 | ("python2-msgpack" ,python2-msgpack) |
| 149 | ("python2-netifaces" ,python2-netifaces) |
| 150 | ("python2-odfpy" ,python2-odfpy) |
| 151 | ("python2-pillow" ,python2-pillow) |
| 152 | ("python2-psutil" ,python2-psutil) |
| 153 | ("python2-pygments" ,python2-pygments) |
| 154 | ("python2-pyqt" ,python2-pyqt) |
| 155 | ("python2-sip" ,python2-sip) |
| 156 | ("python2-regex" ,python2-regex) |
| 157 | ("sqlite" ,sqlite))) |
| 158 | (arguments |
| 159 | `(#:python ,python-2 |
| 160 | ;; Calibre is using setuptools by itself, but the setup.py is not |
| 161 | ;; compatible with the shim wrapper (taken from pip) we are using. |
| 162 | #:use-setuptools? #f |
| 163 | #:phases |
| 164 | (modify-phases %standard-phases |
| 165 | (add-after 'unpack 'patch-source |
| 166 | (lambda _ |
| 167 | (substitute* "src/calibre/linux.py" |
| 168 | ;; We can't use the uninstaller in Guix. Don't build it. |
| 169 | (("self\\.create_uninstaller()") "")) |
| 170 | #t)) |
| 171 | (add-after 'unpack 'dont-load-remote-icons |
| 172 | (lambda _ |
| 173 | (substitute* "setup/plugins_mirror.py" |
| 174 | (("href=\"//calibre-ebook.com/favicon.ico\"") |
| 175 | "href=\"favicon.ico\"")) |
| 176 | #t)) |
| 177 | (add-before 'build 'configure |
| 178 | (lambda* (#:key inputs outputs #:allow-other-keys) |
| 179 | (let ((podofo (assoc-ref inputs "podofo")) |
| 180 | (pyqt (assoc-ref inputs "python2-pyqt")) |
| 181 | (out (assoc-ref outputs "out"))) |
| 182 | (substitute* "setup/build_environment.py" |
| 183 | (("sys.prefix") (string-append "'" pyqt "'"))) |
| 184 | (substitute* "src/calibre/ebooks/pdf/pdftohtml.py" |
| 185 | (("PDFTOHTML = 'pdftohtml'") |
| 186 | (string-append "PDFTOHTML = \"" (assoc-ref inputs "poppler") |
| 187 | "/bin/pdftohtml\""))) |
| 188 | |
| 189 | ;; Calibre thinks we are installing desktop files into a home |
| 190 | ;; directory, but here we butcher the script in to installing |
| 191 | ;; to calibres /share directory. |
| 192 | (setenv "XDG_DATA_HOME" (string-append out "/share")) |
| 193 | (substitute* "src/calibre/linux.py" |
| 194 | (("'~/.local/share'") "''")) |
| 195 | |
| 196 | (setenv "PODOFO_INC_DIR" (string-append podofo "/include/podofo")) |
| 197 | (setenv "PODOFO_LIB_DIR" (string-append podofo "/lib")) |
| 198 | ;; This informs the tests we are a continuous integration |
| 199 | ;; environment and thus have no networking. |
| 200 | (setenv "CI" "true") |
| 201 | ;; The Qt test complains about being unable to load all image plugins, and I |
| 202 | ;; notice the available plugins list it shows lacks 'svg'. Adding qtsvg doesn't |
| 203 | ;; fix it, so I'm not sure how to fix it. TODO: Fix test and remove this. |
| 204 | (setenv "SKIP_QT_BUILD_TEST" "true") |
| 205 | #t))) |
| 206 | (add-after 'build 'build-extra |
| 207 | (lambda* (#:key inputs #:allow-other-keys) |
| 208 | (invoke "python2" "setup.py" "mathjax""--system-mathjax" |
| 209 | "--path-to-mathjax" (string-append |
| 210 | (assoc-ref inputs "js-mathjax") |
| 211 | "/share/javascript/mathjax")) |
| 212 | (invoke "python2" "setup.py" "rapydscript"))) |
| 213 | (add-after 'install 'install-man-pages |
| 214 | (lambda* (#:key outputs #:allow-other-keys) |
| 215 | (copy-recursively |
| 216 | "man-pages" |
| 217 | (string-append (assoc-ref outputs "out") "/share/man")) |
| 218 | #t)) |
| 219 | ;; The font TTF files are used in some miscellaneous tests, so we |
| 220 | ;; unbundle them here to avoid patching the tests. |
| 221 | (add-after 'install 'unbundle-font-liberation |
| 222 | (lambda* (#:key inputs outputs #:allow-other-keys) |
| 223 | (let ((font-dest (string-append (assoc-ref outputs "out") |
| 224 | "/share/calibre/fonts/liberation")) |
| 225 | (font-src (string-append (assoc-ref inputs "font-liberation") |
| 226 | "/share/fonts/truetype"))) |
| 227 | (delete-file-recursively font-dest) |
| 228 | (symlink font-src font-dest)) |
| 229 | #t))))) |
| 230 | (home-page "https://calibre-ebook.com/") |
| 231 | (synopsis "E-book library management software") |
| 232 | (description "Calibre is an e-book library manager. It can view, convert |
| 233 | and catalog e-books in most of the major e-book formats. It can also talk |
| 234 | to many e-book reader devices. It can go out to the Internet and fetch |
| 235 | metadata for books. It can download newspapers and convert them into |
| 236 | e-books for convenient reading.") |
| 237 | ;; Calibre is largely GPL3+, but includes a number of components covered |
| 238 | ;; by other licenses. See COPYRIGHT for more details. |
| 239 | (license (list license:gpl3+ |
| 240 | license:gpl2+ |
| 241 | license:lgpl2.1+ |
| 242 | license:lgpl2.1 |
| 243 | license:bsd-3 |
| 244 | license:expat |
| 245 | license:zpl2.1 |
| 246 | license:asl2.0 |
| 247 | license:public-domain |
| 248 | license:silofl1.1 |
| 249 | license:cc-by-sa3.0)))) |
| 250 | |
| 251 | (define-public liblinebreak |
| 252 | (package |
| 253 | (name "liblinebreak") |
| 254 | (version "2.1") |
| 255 | (source (origin |
| 256 | (method url-fetch) |
| 257 | (uri (string-append "mirror://sourceforge/vimgadgets" |
| 258 | "/liblinebreak/" version |
| 259 | "/liblinebreak-" version ".tar.gz")) |
| 260 | (sha256 |
| 261 | (base32 |
| 262 | "1f36dbq7nc77lln1by2n1yl050g9dc63viawhs3gc3169mavm36x")))) |
| 263 | (build-system gnu-build-system) |
| 264 | (home-page "http://vimgadgets.sourceforge.net/liblinebreak/") |
| 265 | (synopsis "Library for detecting where linebreaks are allowed in text") |
| 266 | (description "@code{liblinebreak} is an implementation of the line |
| 267 | breaking algorithm as described in Unicode 6.0.0 Standard Annex 14, |
| 268 | Revision 26. It breaks lines that contain Unicode characters. It is |
| 269 | designed to be used in a generic text renderer.") |
| 270 | (license license:zlib))) |
| 271 | |
| 272 | (define-public fbreader |
| 273 | (package |
| 274 | (name "fbreader") |
| 275 | (version "0.99.6") |
| 276 | (source (origin |
| 277 | (method git-fetch) |
| 278 | (uri (git-reference |
| 279 | (url "https://github.com/geometer/FBReader") |
| 280 | (commit (string-append version "-freebsdport")))) |
| 281 | (file-name (git-file-name name version)) |
| 282 | (sha256 |
| 283 | (base32 |
| 284 | "0c0s4silpax74kwfz3dfmzn4lkv6jsyb800vfak166vii0hvbv3d")) |
| 285 | (patches (search-patches "fbreader-curl-7.62.patch")))) |
| 286 | (build-system gnu-build-system) |
| 287 | (inputs |
| 288 | `(("curl" ,curl) |
| 289 | ("expat" ,expat) |
| 290 | ("fribidi" ,fribidi) |
| 291 | ("glib" ,glib) |
| 292 | ("gtk+-2" ,gtk+-2) |
| 293 | ("libjpeg" ,libjpeg) |
| 294 | ("liblinebreak" ,liblinebreak) |
| 295 | ("libxft" ,libxft) |
| 296 | ("sqlite" ,sqlite) |
| 297 | ("zlib" ,zlib))) |
| 298 | (native-inputs |
| 299 | `(("gcc" ,gcc-5) |
| 300 | ("pkg-config" ,pkg-config))) |
| 301 | (arguments |
| 302 | `(#:tests? #f ; No tests exist. |
| 303 | #:make-flags `("CC=gcc" "TARGET_ARCH=desktop" "UI_TYPE=gtk" |
| 304 | "TARGET_STATUS=release" |
| 305 | ,(string-append "INSTALLDIR=" |
| 306 | (assoc-ref %outputs "out")) |
| 307 | ,(string-append "LDFLAGS=-Wl,-rpath=" |
| 308 | (assoc-ref %outputs "out") "/lib")) |
| 309 | #:phases |
| 310 | (modify-phases %standard-phases |
| 311 | (delete 'configure) |
| 312 | (add-after 'unpack 'fix-install-locations |
| 313 | (lambda* (#:key outputs #:allow-other-keys) |
| 314 | (let ((out (assoc-ref outputs "out"))) |
| 315 | (substitute* "fbreader/desktop/Makefile" |
| 316 | (("/usr") out)) |
| 317 | #t)))))) |
| 318 | (home-page "https://fbreader.org/") |
| 319 | (synopsis "E-Book reader") |
| 320 | (description "@code{fbreader} is an E-Book reader. It supports the |
| 321 | following formats: |
| 322 | |
| 323 | @enumerate |
| 324 | @item CHM |
| 325 | @item Docbook |
| 326 | @item FB2 |
| 327 | @item HTML |
| 328 | @item OEB |
| 329 | @item PDB |
| 330 | @item RTF |
| 331 | @item TCR |
| 332 | @item TXT |
| 333 | @item XHTML |
| 334 | @end enumerate") |
| 335 | (license license:gpl2+))) |
| 336 | |
| 337 | (define-public xchm |
| 338 | (package |
| 339 | (name "xchm") |
| 340 | (version "1.31") |
| 341 | (source (origin |
| 342 | (method url-fetch) |
| 343 | (uri (string-append "https://github.com/rzvncj/xCHM" |
| 344 | "/releases/download/" |
| 345 | version "/xchm-" version ".tar.gz")) |
| 346 | (sha256 |
| 347 | (base32 |
| 348 | "0aw6bysqiwbw75n3ad229ihlmh7chqs1wlxm0398z3lfp2y6n7qf")))) |
| 349 | (build-system gnu-build-system) |
| 350 | (inputs |
| 351 | `(("wxwidgets" ,wxwidgets) |
| 352 | ("chmlib" ,chmlib))) |
| 353 | (native-inputs |
| 354 | `(("pkg-config" ,pkg-config))) |
| 355 | (home-page "https://github.com/rzvncj/xCHM") |
| 356 | (synopsis "CHM file viewer") |
| 357 | (description "xCHM is a graphical CHM file viewer. It is a frontend to |
| 358 | the CHM library CHMLIB.") |
| 359 | (license license:gpl2+))) |