djvu.scm 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015 Paul van der Walt <paul@denknerd.org>
  3. ;;; Copyright © 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
  4. ;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
  5. ;;; Copyright © 2020, 2021 Guillaume Le Vaillant <glv@posteo.net>
  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. (define-module (gnu packages djvu)
  22. #:use-module ((guix licenses) #:prefix license:)
  23. #:use-module (guix utils)
  24. #:use-module (guix packages)
  25. #:use-module (guix download)
  26. #:use-module (guix git-download)
  27. #:use-module (guix build-system gnu)
  28. #:use-module (guix build-system python)
  29. #:use-module (gnu packages autotools)
  30. #:use-module (gnu packages base)
  31. #:use-module (gnu packages check)
  32. #:use-module (gnu packages compression)
  33. #:use-module (gnu packages gawk)
  34. #:use-module (gnu packages gettext)
  35. #:use-module (gnu packages ghostscript)
  36. #:use-module (gnu packages glib)
  37. #:use-module (gnu packages image)
  38. #:use-module (gnu packages imagemagick)
  39. #:use-module (gnu packages linux)
  40. #:use-module (gnu packages ncurses)
  41. #:use-module (gnu packages ocr)
  42. #:use-module (gnu packages pdf)
  43. #:use-module (gnu packages pkg-config)
  44. #:use-module (gnu packages python)
  45. #:use-module (gnu packages python-web)
  46. #:use-module (gnu packages python-xyz)
  47. #:use-module (gnu packages qt)
  48. #:use-module (gnu packages wxwidgets)
  49. #:use-module (gnu packages xml)
  50. #:use-module (gnu packages xorg))
  51. (define-public djvulibre
  52. (package
  53. (name "djvulibre")
  54. (version "3.5.28")
  55. (source
  56. (origin
  57. (method url-fetch)
  58. (uri (string-append "mirror://sourceforge/djvu/DjVuLibre/"
  59. (string-replace-substring version "." ",")
  60. "/djvulibre-" version ".tar.gz"))
  61. (sha256
  62. (base32 "0manxn1ly5n8nqamv47hz7akxi6v0rzwc9j1c3x99vngrjlr5qw2"))
  63. (modules '((guix build utils)))
  64. (snippet
  65. '(begin
  66. ;; This bundles software (e.g., zlib) and is entirely superfluous.
  67. (delete-file-recursively "win32")
  68. #t))))
  69. (build-system gnu-build-system)
  70. (native-inputs
  71. ;; The 3.5.28 release tarball isn't bootstrapped.
  72. `(("autoconf" ,autoconf)
  73. ("automake" ,automake)
  74. ("libtool" ,libtool)))
  75. (inputs
  76. `(("libjpeg-turbo" ,libjpeg-turbo)
  77. ("libtiff" ,libtiff)
  78. ("zlib" ,zlib)))
  79. (arguments
  80. `(#:phases
  81. (modify-phases %standard-phases
  82. (add-after 'bootstrap 'make-reproducible
  83. (lambda _
  84. ;; Ensure there are no timestamps in .svgz files.
  85. (substitute* "desktopfiles/Makefile.am"
  86. (("gzip") "gzip -n"))
  87. #t)))))
  88. (home-page "http://djvu.sourceforge.net/")
  89. (synopsis "Implementation of DjVu, the document format")
  90. (description "DjVuLibre is an implementation of DjVu,
  91. including viewers, browser plugins, decoders, simple encoders, and
  92. utilities.")
  93. (license license:gpl2+)))
  94. (define-public djview
  95. (package
  96. (name "djview")
  97. (version "4.12")
  98. (source
  99. (origin
  100. (method git-fetch)
  101. (uri (git-reference
  102. (url "https://git.code.sf.net/p/djvu/djview-git")
  103. (commit (string-append "release." version))))
  104. (sha256
  105. (base32 "0mn9ywjbc7iga50lbjclrk892g0x0rap0dmb6ybzjyarybdhhcxp"))
  106. (file-name (git-file-name name version))))
  107. (build-system gnu-build-system)
  108. (native-inputs
  109. `(("autoconf" ,autoconf)
  110. ("automake" ,automake)
  111. ("libtool" ,libtool)
  112. ("pkg-config" ,pkg-config)
  113. ("qttools" ,qttools)))
  114. (inputs
  115. `(("djvulibre" ,djvulibre)
  116. ("glib" ,glib)
  117. ("libxt" ,libxt)
  118. ("libtiff" ,libtiff)
  119. ("qtbase" ,qtbase-5)))
  120. (arguments
  121. `(#:phases
  122. (modify-phases %standard-phases
  123. (add-after 'unpack 'fix-desktop-file
  124. ;; Executable is "djview", not "djview4".
  125. (lambda _
  126. (substitute* "desktopfiles/djvulibre-djview4.desktop"
  127. (("Exec=djview4 %f") "Exec=djview %f"))
  128. #t))
  129. (add-after 'unpack 'make-files-writable
  130. (lambda _
  131. (for-each make-file-writable
  132. (find-files "."))
  133. #t)))))
  134. (home-page "http://djvu.sourceforge.net/djview4.html")
  135. (synopsis "Viewer for the DjVu image format")
  136. (description "DjView is a standalone viewer for DjVu files.
  137. Its features include navigating documents, zooming and panning page images,
  138. producing and displaying thumbnails, displaying document outlines, searching
  139. documents for particular words in the hidden text layer, copying hidden text
  140. to the clipboard, saving pages and documents as bundled or indirect multi-page
  141. files, and printing page and documents.
  142. The viewer can simultaneously display several pages using a side-by-side or
  143. a continuous layout.")
  144. (license license:gpl2+)))
  145. (define-public pdf2djvu
  146. (package
  147. (name "pdf2djvu")
  148. (version "0.9.18")
  149. (source
  150. (origin
  151. (method url-fetch)
  152. (uri (string-append
  153. "https://github.com/jwilk/pdf2djvu/releases/download/" version
  154. "/pdf2djvu-" version ".tar.xz"))
  155. (sha256
  156. (base32 "0vxa0b3g7zhflc5m6ln4f0hi0shsqyqc3344y7azlllibxc5ba22"))))
  157. (build-system gnu-build-system)
  158. (native-inputs
  159. `(("gettext" ,gettext-minimal)
  160. ("pkg-config" ,pkg-config)
  161. ("python2" ,python-2)
  162. ("python2-nose" ,python2-nose)))
  163. (inputs
  164. `(("djvulibre" ,djvulibre)
  165. ("exiv2" ,exiv2)
  166. ("graphicsmagick" ,graphicsmagick)
  167. ("poppler" ,poppler)
  168. ("poppler-data" ,poppler-data)
  169. ("util-linux-lib" ,util-linux "lib"))) ; for libuuid
  170. (arguments
  171. `(#:test-target "test"
  172. #:phases
  173. (modify-phases %standard-phases
  174. (add-before 'check 'set-home-for-tests
  175. (lambda _
  176. (setenv "HOME" "/tmp"))))))
  177. (synopsis "PDF to DjVu converter")
  178. (description
  179. "@code{pdf2djvu} creates DjVu files from PDF files.
  180. It is able to extract:
  181. @itemize
  182. @item graphics,
  183. @item text layer,
  184. @item hyperlinks,
  185. @item document outline (bookmarks),
  186. @item metadata (including XMP metadata).
  187. @end itemize\n")
  188. (home-page "https://jwilk.net/software/pdf2djvu")
  189. (license license:gpl2)))
  190. (define-public djvu2pdf
  191. (package
  192. (name "djvu2pdf")
  193. (version "0.9.2")
  194. (source
  195. (origin
  196. (method url-fetch)
  197. (uri (string-append "https://0x2a.at/site/projects/djvu2pdf/djvu2pdf-"
  198. version ".tar.gz"))
  199. (sha256
  200. (base32 "0v2ax30m7j1yi4m02nzn9rc4sn4vzqh5vywdh96r64j4pwvn5s5g"))))
  201. (build-system gnu-build-system)
  202. (inputs
  203. `(("djvulibre" ,djvulibre)
  204. ("gawk" ,gawk)
  205. ("ghostscript" ,ghostscript)
  206. ("grep" ,grep)
  207. ("ncurses" ,ncurses)
  208. ("which" ,which)))
  209. (arguments
  210. `(#:tests? #f ; No test suite
  211. #:phases
  212. (modify-phases %standard-phases
  213. (add-after 'unpack 'fix-paths
  214. (lambda* (#:key inputs #:allow-other-keys)
  215. (let ((djvulibre (assoc-ref inputs "djvulibre"))
  216. (gawk (assoc-ref inputs "gawk"))
  217. (ghostscript (assoc-ref inputs "ghostscript"))
  218. (grep (assoc-ref inputs "grep"))
  219. (ncurses (assoc-ref inputs "ncurses"))
  220. (which (assoc-ref inputs "which")))
  221. (substitute* "djvu2pdf"
  222. (("awk")
  223. (string-append gawk "/bin/awk"))
  224. (("ddjvu")
  225. (string-append djvulibre "/bin/ddjvu"))
  226. (("djvudump")
  227. (string-append djvulibre "/bin/djvudump"))
  228. (("grep")
  229. (string-append grep "/bin/grep"))
  230. (("gs")
  231. (string-append ghostscript "/bin/gs"))
  232. (("tput ")
  233. (string-append ncurses "/bin/tput "))
  234. (("which")
  235. (string-append which "/bin/which"))))
  236. #t))
  237. (delete 'configure)
  238. (delete 'build)
  239. (replace 'install
  240. (lambda* (#:key outputs #:allow-other-keys)
  241. (let ((out (assoc-ref %outputs "out")))
  242. (install-file "djvu2pdf"
  243. (string-append out "/bin"))
  244. (install-file "djvu2pdf.1.gz"
  245. (string-append out "/share/man/man1"))
  246. #t))))))
  247. (synopsis "DjVu to PDF converter")
  248. (description "This is a small tool to convert DjVu files to PDF files.")
  249. (home-page "https://0x2a.at/site/projects/djvu2pdf/")
  250. (license license:gpl2+)))
  251. (define-public minidjvu
  252. (package
  253. (name "minidjvu")
  254. (version "0.8")
  255. (source
  256. (origin
  257. (method url-fetch)
  258. (uri (string-append "mirror://sourceforge/minidjvu/minidjvu/"
  259. version "/minidjvu-" version ".tar.gz"))
  260. (sha256
  261. (base32 "0jmpvy4g68k6xgplj9zsl6brg6vi81mx3nx2x9hfbr1f4zh95j79"))))
  262. (build-system gnu-build-system)
  263. (native-inputs
  264. `(("gettext" ,gettext-minimal)))
  265. (inputs
  266. `(("libjpeg-turbo" ,libjpeg-turbo)
  267. ("libtiff" ,libtiff)
  268. ("zlib" ,zlib)))
  269. (arguments
  270. '(#:configure-flags '("--disable-static")
  271. #:parallel-build? #f
  272. #:tests? #f ; No test suite
  273. #:phases
  274. (modify-phases %standard-phases
  275. (add-after 'unpack 'fix-paths
  276. (lambda _
  277. (substitute* "Makefile.in"
  278. (("/usr/bin/gzip")
  279. "gzip"))
  280. #t))
  281. (add-before 'install 'make-lib-directory
  282. (lambda* (#:key outputs #:allow-other-keys)
  283. (mkdir-p (string-append (assoc-ref outputs "out") "/lib"))
  284. #t)))))
  285. (synopsis "Black and white DjVu encoder")
  286. (description
  287. "@code{minidjvu} is a multipage DjVu encoder and single page
  288. encoder/decoder. It doesn't support colors or grayscales, just black
  289. and white.")
  290. (home-page "https://sourceforge.net/projects/minidjvu/")
  291. (license license:gpl2)))
  292. (define-public djvusmooth
  293. (package
  294. (name "djvusmooth")
  295. (version "0.3")
  296. (source
  297. (origin
  298. (method url-fetch)
  299. (uri (string-append
  300. "https://github.com/jwilk/djvusmooth/releases/download/" version
  301. "/djvusmooth-" version ".tar.gz"))
  302. (sha256
  303. (base32 "0z403cklvxzz0qaczgv83ax0nknrd9h8micp04j9kjfdxk2sgval"))))
  304. (build-system python-build-system)
  305. (inputs
  306. `(("djvulibre" ,djvulibre)
  307. ("python2-djvulibre" ,python2-djvulibre)
  308. ("python2-subprocess32" ,python2-subprocess32)
  309. ("python2-wxpython" ,python2-wxpython)))
  310. (arguments
  311. `(#:python ,python-2
  312. #:phases
  313. (modify-phases %standard-phases
  314. (add-after 'unpack 'fix-paths
  315. (lambda* (#:key inputs #:allow-other-keys)
  316. (substitute* "lib/djvused.py"
  317. (("djvused_path = 'djvused'")
  318. (string-append "djvused_path = '"
  319. (assoc-ref inputs "djvulibre")
  320. "/bin/djvused'"))))))))
  321. (synopsis "Graphical editor for DjVu documents")
  322. (description
  323. "@code{djvusmooth} is a graphical editor for DjVu_ documents.
  324. It is able to:
  325. @itemize
  326. @item edit document metadata,
  327. @item edit document outline (bookmarks),
  328. @item add, remove or edit hyperlinks,
  329. @item correct occasional errors in the hidden text layer.
  330. @end itemize\n")
  331. (home-page "https://jwilk.net/software/djvusmooth")
  332. (license license:gpl2)))
  333. (define-public didjvu
  334. (package
  335. (name "didjvu")
  336. (version "0.9")
  337. (source
  338. (origin
  339. (method url-fetch)
  340. (uri (string-append
  341. "https://github.com/jwilk/didjvu/releases/download/" version
  342. "/didjvu-" version ".tar.gz"))
  343. (sha256
  344. (base32 "0xyrnk8d2khi7q1zr28gjkjq6frz4mkb5jdl8821yzf12k7c8pbv"))))
  345. (build-system gnu-build-system)
  346. (native-inputs
  347. `(("python2-nose" ,python2-nose)))
  348. (inputs
  349. `(("djvulibre" ,djvulibre)
  350. ("minidjvu" ,minidjvu)
  351. ("python" ,python-2)
  352. ("python2-gamera" ,python2-gamera)
  353. ("python2-pillow" ,python2-pillow)))
  354. (arguments
  355. `(#:modules ((guix build gnu-build-system)
  356. ((guix build python-build-system) #:prefix python:)
  357. (guix build utils))
  358. #:imported-modules (,@%gnu-build-system-modules
  359. (guix build python-build-system))
  360. #:test-target "test"
  361. #:phases
  362. (modify-phases %standard-phases
  363. (delete 'configure)
  364. (add-before 'check 'disable-failing-test
  365. (lambda _
  366. (substitute* "tests/test_ipc.py"
  367. ;; test_wait_signal gets stuck forever
  368. (("yield self\\._test_signal, name")
  369. "return True")
  370. ;; test_path fails to find a file it should have created
  371. (("path = os\\.getenv\\('PATH'\\)\\.split\\(':'\\)")
  372. "return True"))
  373. (substitute* "tests/test_timestamp.py"
  374. ;; test_timezones fails with:
  375. ;; '2009-12-18T21:25:14Z' != '2009-12-18T22:25:14+01:00'
  376. (("@fork_isolation")
  377. "return True"))))
  378. (replace 'install
  379. (lambda* (#:key outputs #:allow-other-keys)
  380. (let ((out (assoc-ref outputs "out")))
  381. (invoke "make"
  382. "DESTDIR="
  383. (string-append "PREFIX=" out)
  384. "install"))))
  385. (add-after 'install 'wrap-python
  386. (assoc-ref python:%standard-phases 'wrap))
  387. (add-after 'wrap-python 'wrap-path
  388. (lambda* (#:key inputs outputs #:allow-other-keys)
  389. (let ((out (assoc-ref outputs "out"))
  390. (djvulibre (assoc-ref inputs "djvulibre")))
  391. (wrap-program (string-append out "/bin/didjvu")
  392. `("PATH" ":" prefix (,(string-append djvulibre "/bin"))))))))))
  393. (synopsis "DjVu encoder with foreground/background separation")
  394. (description
  395. "@code{didjvu} uses the @code{Gamera} framework to separate the foreground
  396. and background layers of images, which can then be encoded into a DjVu file.")
  397. (home-page "https://jwilk.net/software/didjvu")
  398. (license license:gpl2)))
  399. (define-public ocrodjvu
  400. (package
  401. (name "ocrodjvu")
  402. (version "0.12")
  403. (source
  404. (origin
  405. (method url-fetch)
  406. (uri (string-append
  407. "https://github.com/jwilk/ocrodjvu/releases/download/" version
  408. "/ocrodjvu-" version ".tar.xz"))
  409. (sha256
  410. (base32 "09w9rqr7z2jd5kwp178zz2yrsc82mxs7gksipg92znxzgzhmw2ng"))))
  411. (build-system gnu-build-system)
  412. (native-inputs
  413. `(("libxml2" ,libxml2)
  414. ("python2-nose" ,python2-nose)
  415. ("python2-pillow" ,python2-pillow)))
  416. (inputs
  417. `(("djvulibre" ,djvulibre)
  418. ("ocrad" ,ocrad)
  419. ("python" ,python-2)
  420. ("python2-djvulibre" ,python2-djvulibre)
  421. ("python2-html5lib" ,python2-html5lib)
  422. ("python2-lxml" ,python2-lxml)
  423. ("python2-pyicu" ,python2-pyicu)
  424. ("python2-subprocess32" ,python2-subprocess32)
  425. ("tesseract-ocr" ,tesseract-ocr)))
  426. (arguments
  427. `(#:modules ((guix build gnu-build-system)
  428. ((guix build python-build-system) #:prefix python:)
  429. (guix build utils))
  430. #:imported-modules (,@%gnu-build-system-modules
  431. (guix build python-build-system))
  432. #:test-target "test"
  433. #:phases
  434. (modify-phases %standard-phases
  435. (delete 'configure)
  436. (add-before 'check 'disable-failing-test
  437. (lambda _
  438. (substitute* "tests/test_ipc.py"
  439. ;; test_wait_signal gets stuck forever
  440. (("yield self\\._test_signal, name")
  441. "return True")
  442. ;; test_path fails to find a file it should have created
  443. (("path = os\\.getenv\\('PATH'\\)\\.split\\(':'\\)")
  444. "return True"))
  445. ;; Disable tests with tesseract. They can't work without
  446. ;; the language files that must downloaded by the final user
  447. ;; as they are not packaged in Guix.
  448. (substitute* "tests/ocrodjvu/test.py"
  449. (("engines = stdout\\.getvalue\\(\\)\\.splitlines\\(\\)")
  450. "engines = ['ocrad']"))
  451. (substitute* "tests/ocrodjvu/test_integration.py"
  452. (("engines = 'tesseract', 'cuneiform', 'gocr', 'ocrad'")
  453. "engines = 'ocrad'"))))
  454. (replace 'install
  455. (lambda* (#:key outputs #:allow-other-keys)
  456. (let ((out (assoc-ref outputs "out")))
  457. (invoke "make"
  458. "DESTDIR="
  459. (string-append "PREFIX=" out)
  460. "install"))))
  461. (add-after 'install 'wrap-python
  462. (assoc-ref python:%standard-phases 'wrap))
  463. (add-after 'wrap-python 'wrap-path
  464. (lambda* (#:key inputs outputs #:allow-other-keys)
  465. (let ((out (assoc-ref outputs "out"))
  466. (djvulibre (assoc-ref inputs "djvulibre"))
  467. (ocrad (assoc-ref inputs "ocrad"))
  468. (tesseract (assoc-ref inputs "tesseract-ocr")))
  469. (for-each (lambda (file)
  470. (wrap-program (string-append out "/bin/" file)
  471. `("PATH" ":" prefix
  472. (,(string-append djvulibre "/bin:"
  473. ocrad "/bin:"
  474. tesseract "/bin")))))
  475. '("djvu2hocr"
  476. "hocr2djvused"
  477. "ocrodjvu"))))))))
  478. (synopsis "Program to perform OCR on DjVu files")
  479. (description
  480. "@code{ocrodjvu} is a wrapper for OCR systems, that allows you to perform
  481. OCR on DjVu files.")
  482. (home-page "https://jwilk.net/software/ocrodjvu")
  483. (license license:gpl2)))