ebook.scm 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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. (define-module (gnu packages ebook)
  24. #:use-module ((guix licenses) #:prefix license:)
  25. #:use-module (guix packages)
  26. #:use-module (guix download)
  27. #:use-module (guix git-download)
  28. #:use-module (guix build-system gnu)
  29. #:use-module (gnu packages)
  30. #:use-module (guix build-system python)
  31. #:use-module (gnu packages)
  32. #:use-module (gnu packages compression)
  33. #:use-module (gnu packages curl)
  34. #:use-module (gnu packages databases)
  35. #:use-module (gnu packages fonts)
  36. #:use-module (gnu packages fontutils)
  37. #:use-module (gnu packages freedesktop)
  38. #:use-module (gnu packages fribidi)
  39. #:use-module (gnu packages gtk)
  40. #:use-module (gnu packages gnome)
  41. #:use-module (gnu packages glib)
  42. #:use-module (gnu packages icu4c)
  43. #:use-module (gnu packages image)
  44. #:use-module (gnu packages libusb)
  45. #:use-module (gnu packages pdf)
  46. #:use-module (gnu packages pkg-config)
  47. #:use-module (gnu packages python)
  48. #:use-module (gnu packages python-web)
  49. #:use-module (gnu packages python-xyz)
  50. #:use-module (gnu packages qt)
  51. #:use-module (gnu packages serialization)
  52. #:use-module (gnu packages sqlite)
  53. #:use-module (gnu packages time)
  54. #:use-module (gnu packages tls)
  55. #:use-module (gnu packages web)
  56. #:use-module (gnu packages xml)
  57. #:use-module (gnu packages xorg))
  58. (define-public chmlib
  59. (package
  60. (name "chmlib")
  61. (version "0.40")
  62. (source (origin
  63. (method url-fetch)
  64. (uri (string-append "http://www.jedrea.com/chmlib/chmlib-"
  65. version ".tar.bz2"))
  66. (sha256
  67. (base32
  68. "18zzb4x3z0d7fjh1x5439bs62dmgsi4c1pg3qyr7h5gp1i5xcj9l"))
  69. (patches (search-patches "chmlib-inttypes.patch"))))
  70. (build-system gnu-build-system)
  71. (home-page "http://www.jedrea.com/chmlib/")
  72. (synopsis "Library for CHM files")
  73. (description "CHMLIB is a library for dealing with ITSS/CHM format files.")
  74. (license license:lgpl2.1+)))
  75. (define-public calibre
  76. (package
  77. (name "calibre")
  78. (version "3.35.0")
  79. (source
  80. (origin
  81. (method url-fetch)
  82. (uri (string-append "http://download.calibre-ebook.com/"
  83. version "/calibre-"
  84. version ".tar.xz"))
  85. (sha256
  86. (base32
  87. "1gd15wjz4fhcra6d44xiy3hwbyk0miwb66a1pq5yldyy0hlb271z"))
  88. ;; Remove non-free or doubtful code, see
  89. ;; https://lists.gnu.org/archive/html/guix-devel/2015-02/msg00478.html
  90. (modules '((guix build utils)))
  91. (snippet
  92. '(begin
  93. (delete-file-recursively "src/calibre/ebooks/markdown")
  94. (delete-file "src/odf/thumbnail.py")
  95. (delete-file-recursively "resources/fonts/liberation")
  96. (substitute* (find-files "." "\\.py")
  97. (("calibre\\.ebooks\\.markdown") "markdown"))
  98. #t))
  99. (patches (search-patches "calibre-use-packaged-feedparser.patch"
  100. "calibre-no-updates-dialog.patch"))))
  101. (build-system python-build-system)
  102. (native-inputs
  103. `(("pkg-config" ,pkg-config)
  104. ("font-liberation" ,font-liberation)
  105. ("qtbase" ,qtbase) ; for qmake
  106. ;; xdg-utils is supposed to be used for desktop integration, but it
  107. ;; also creates lots of messages
  108. ;; mkdir: cannot create directory '/homeless-shelter': Permission denied
  109. ("python2-flake8" ,python2-flake8)
  110. ("xdg-utils" ,xdg-utils)))
  111. ;; Beautifulsoup3 is bundled but obsolete and not packaged, so just leave it bundled.
  112. (inputs
  113. `(("chmlib" ,chmlib)
  114. ("fontconfig" ,fontconfig)
  115. ("glib" ,glib)
  116. ("icu4c" ,icu4c)
  117. ("libmtp" ,libmtp)
  118. ("libpng" ,libpng)
  119. ("libusb" ,libusb)
  120. ("libxrender" ,libxrender)
  121. ("openssl" ,openssl)
  122. ("optipng" ,optipng)
  123. ("podofo" ,podofo)
  124. ("poppler" ,poppler)
  125. ("python" ,python-2)
  126. ("python2-apsw" ,python2-apsw)
  127. ("python2-chardet" ,python2-chardet)
  128. ("python2-cssselect" ,python2-cssselect)
  129. ("python2-cssutils" ,python2-cssutils)
  130. ("python2-dateutil" ,python2-dateutil)
  131. ("python2-dbus" ,python2-dbus)
  132. ("python2-dnspython" ,python2-dnspython)
  133. ("python2-dukpy" ,python2-dukpy)
  134. ("python2-feedparser" ,python2-feedparser)
  135. ("python2-html5-parser" ,python2-html5-parser)
  136. ("python2-lxml" ,python2-lxml)
  137. ("python2-markdown" ,python2-markdown)
  138. ("python2-mechanize" ,python2-mechanize)
  139. ;; python2-msgpack is needed for the network content server to work.
  140. ("python2-msgpack" ,python2-msgpack)
  141. ("python2-netifaces" ,python2-netifaces)
  142. ("python2-pillow" ,python2-pillow)
  143. ("python2-pygments" ,python2-pygments)
  144. ("python2-pyqt" ,python2-pyqt)
  145. ("python2-sip" ,python2-sip)
  146. ("python2-regex" ,python2-regex)
  147. ;; python2-unrardll is needed for decompressing RAR files.
  148. ;; A program called 'pdf2html' is needed for reading PDF books
  149. ;; in the web interface.
  150. ("sqlite" ,sqlite)))
  151. (arguments
  152. `(#:python ,python-2
  153. #:test-target "check"
  154. #:tests? #f ; FIXME: enable once flake8 is packaged
  155. ;; Calibre is using setuptools by itself, but the setup.py is not
  156. ;; compatible with the shim wrapper (taken from pip) we are using.
  157. #:use-setuptools? #f
  158. #:phases
  159. (modify-phases %standard-phases
  160. (add-after 'unpack 'patch-source
  161. (lambda _
  162. (substitute* "src/calibre/linux.py"
  163. ;; We can't use the uninstaller in Guix. Don't build it.
  164. (("self\\.create_uninstaller()") ""))
  165. #t))
  166. (add-after 'unpack 'dont-load-remote-icons
  167. (lambda _
  168. (substitute* "setup/plugins_mirror.py"
  169. (("href=\"//calibre-ebook.com/favicon.ico\"")
  170. "href=\"favicon.ico\""))
  171. #t))
  172. (add-before 'build 'configure
  173. (lambda* (#:key inputs #:allow-other-keys)
  174. (let ((podofo (assoc-ref inputs "podofo"))
  175. (pyqt (assoc-ref inputs "python2-pyqt")))
  176. (substitute* "setup/build_environment.py"
  177. (("sys.prefix") (string-append "'" pyqt "'")))
  178. (substitute* "src/calibre/ebooks/pdf/pdftohtml.py"
  179. (("PDFTOHTML = 'pdftohtml'")
  180. (string-append "PDFTOHTML = \"" (assoc-ref inputs "poppler")
  181. "/bin/pdftohtml\"")))
  182. (setenv "PODOFO_INC_DIR" (string-append podofo "/include/podofo"))
  183. (setenv "PODOFO_LIB_DIR" (string-append podofo "/lib"))
  184. #t)))
  185. (add-after 'install 'install-font-liberation
  186. (lambda* (#:key inputs outputs #:allow-other-keys)
  187. (for-each (lambda (file)
  188. (install-file file (string-append
  189. (assoc-ref outputs "out")
  190. "/share/calibre/fonts/liberation")))
  191. (find-files (string-append
  192. (assoc-ref inputs "font-liberation")
  193. "/share/fonts/truetype")))
  194. #t))
  195. (add-after 'install-font-liberation 'install-mimetypes
  196. (lambda* (#:key outputs #:allow-other-keys)
  197. (install-file "resources/calibre-mimetypes.xml"
  198. (string-append (assoc-ref outputs "out")
  199. "/share/mime/packages"))
  200. #t)))))
  201. (home-page "http://calibre-ebook.com/")
  202. (synopsis "E-book library management software")
  203. (description "Calibre is an e-book library manager. It can view, convert
  204. and catalog e-books in most of the major e-book formats. It can also talk
  205. to many e-book reader devices. It can go out to the Internet and fetch
  206. metadata for books. It can download newspapers and convert them into
  207. e-books for convenient reading.")
  208. ;; Calibre is largely GPL3+, but includes a number of components covered
  209. ;; by other licenses. See COPYRIGHT for more details.
  210. (license (list license:gpl3+
  211. license:gpl2+
  212. license:lgpl2.1+
  213. license:lgpl2.1
  214. license:bsd-3
  215. license:expat
  216. license:zpl2.1
  217. license:asl2.0
  218. license:public-domain
  219. license:silofl1.1
  220. license:cc-by-sa3.0))))
  221. (define-public liblinebreak
  222. (package
  223. (name "liblinebreak")
  224. (version "2.1")
  225. (source (origin
  226. (method url-fetch)
  227. (uri (string-append "mirror://sourceforge/vimgadgets"
  228. "/liblinebreak/" version
  229. "/liblinebreak-" version ".tar.gz"))
  230. (sha256
  231. (base32
  232. "1f36dbq7nc77lln1by2n1yl050g9dc63viawhs3gc3169mavm36x"))))
  233. (build-system gnu-build-system)
  234. (home-page "http://vimgadgets.sourceforge.net/liblinebreak/")
  235. (synopsis "Library for detecting where linebreaks are allowed in text")
  236. (description "@code{liblinebreak} is an implementation of the line
  237. breaking algorithm as described in Unicode 6.0.0 Standard Annex 14,
  238. Revision 26. It breaks lines that contain Unicode characters. It is
  239. designed to be used in a generic text renderer.")
  240. (license license:zlib)))
  241. (define-public fbreader
  242. (package
  243. (name "fbreader")
  244. (version "0.99.6")
  245. (source (origin
  246. (method git-fetch)
  247. (uri (git-reference
  248. (url "https://github.com/geometer/FBReader")
  249. (commit (string-append version "-freebsdport"))))
  250. (file-name (git-file-name name version))
  251. (sha256
  252. (base32
  253. "0c0s4silpax74kwfz3dfmzn4lkv6jsyb800vfak166vii0hvbv3d"))
  254. (patches (search-patches "fbreader-curl-7.62.patch"))))
  255. (build-system gnu-build-system)
  256. (inputs
  257. `(("curl" ,curl)
  258. ("expat" ,expat)
  259. ("fribidi" ,fribidi)
  260. ("glib" ,glib)
  261. ("gtk+-2" ,gtk+-2)
  262. ("libjpeg" ,libjpeg)
  263. ("liblinebreak" ,liblinebreak)
  264. ("libxft" ,libxft)
  265. ("sqlite" ,sqlite)
  266. ("zlib" ,zlib)))
  267. (native-inputs
  268. `(("pkg-config" ,pkg-config)))
  269. (arguments
  270. `(#:tests? #f ; No tests exist.
  271. #:make-flags `("CC=gcc" "TARGET_ARCH=desktop" "UI_TYPE=gtk"
  272. "TARGET_STATUS=release"
  273. ,(string-append "INSTALLDIR="
  274. (assoc-ref %outputs "out"))
  275. ,(string-append "LDFLAGS=-Wl,-rpath="
  276. (assoc-ref %outputs "out") "/lib"))
  277. #:phases
  278. (modify-phases %standard-phases
  279. (delete 'configure)
  280. (add-after 'unpack 'fix-install-locations
  281. (lambda* (#:key outputs #:allow-other-keys)
  282. (let ((out (assoc-ref outputs "out")))
  283. (substitute* "fbreader/desktop/Makefile"
  284. (("/usr") out))
  285. #t))))))
  286. (home-page "https://fbreader.org/")
  287. (synopsis "E-Book reader")
  288. (description "@code{fbreader} is an E-Book reader. It supports the
  289. following formats:
  290. @enumerate
  291. @item CHM
  292. @item Docbook
  293. @item FB2
  294. @item HTML
  295. @item OEB
  296. @item PDB
  297. @item RTF
  298. @item TCR
  299. @item TXT
  300. @item XHTML
  301. @end enumerate")
  302. (license license:gpl2+)))