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 Guillaume Le Vaillant <glv@posteo.net>
7 ;;; This file is part of GNU Guix.
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.
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.
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/>.
22 (define-module (gnu packages djvu)
23 #:use-module ((guix licenses) #:prefix license:)
24 #:use-module (guix utils)
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 (guix build-system python)
30 #:use-module (gnu packages autotools)
31 #:use-module (gnu packages base)
32 #:use-module (gnu packages check)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages gawk)
35 #:use-module (gnu packages gettext)
36 #:use-module (gnu packages ghostscript)
37 #:use-module (gnu packages glib)
38 #:use-module (gnu packages image)
39 #:use-module (gnu packages imagemagick)
40 #:use-module (gnu packages linux)
41 #:use-module (gnu packages ncurses)
42 #:use-module (gnu packages ocr)
43 #:use-module (gnu packages pdf)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages python)
46 #:use-module (gnu packages python-web)
47 #:use-module (gnu packages python-xyz)
48 #:use-module (gnu packages qt)
49 #:use-module (gnu packages wxwidgets)
50 #:use-module (gnu packages xml)
51 #:use-module (gnu packages xorg))
53 (define-public djvulibre
60 (uri (string-append "mirror://sourceforge/djvu/DjVuLibre/"
61 (string-replace-substring version "." ",")
62 "/djvulibre-" version ".tar.gz"))
64 (base32 "0manxn1ly5n8nqamv47hz7akxi6v0rzwc9j1c3x99vngrjlr5qw2"))
65 (modules '((guix build utils)))
68 ;; This bundles software (e.g., zlib) and is entirely superfluous.
69 (delete-file-recursively "win32")
71 (build-system gnu-build-system)
73 ;; The 3.5.28 release tarball isn't bootstrapped.
74 `(("autoconf" ,autoconf)
75 ("automake" ,automake)
76 ("libtool" ,libtool)))
78 `(("libjpeg-turbo" ,libjpeg-turbo)
83 (modify-phases %standard-phases
84 (add-after 'bootstrap 'make-reproducible
86 ;; Ensure there are no timestamps in .svgz files.
87 (substitute* "desktopfiles/Makefile.am"
90 (home-page "http://djvu.sourceforge.net/")
91 (synopsis "Implementation of DjVu, the document format")
92 (description "DjVuLibre is an implementation of DjVu,
93 including viewers, browser plugins, decoders, simple encoders, and
95 (license license:gpl2+)))
105 (url "https://git.code.sf.net/p/djvu/djview-git")
106 (commit (string-append "release." version))))
108 (base32 "0mn9ywjbc7iga50lbjclrk892g0x0rap0dmb6ybzjyarybdhhcxp"))
109 (file-name (git-file-name name version))))
110 (build-system gnu-build-system)
112 `(("autoconf" ,autoconf)
113 ("automake" ,automake)
115 ("pkg-config" ,pkg-config)
116 ("qttools" ,qttools)))
118 `(("djvulibre" ,djvulibre)
125 (modify-phases %standard-phases
126 (add-after 'unpack 'fix-desktop-file
127 ;; Executable is "djview", not "djview4".
129 (substitute* "desktopfiles/djvulibre-djview4.desktop"
130 (("Exec=djview4 %f") "Exec=djview %f"))
132 (add-after 'unpack 'make-files-writable
134 (for-each make-file-writable
137 (home-page "http://djvu.sourceforge.net/djview4.html")
138 (synopsis "Viewer for the DjVu image format")
139 (description "DjView is a standalone viewer for DjVu files.
141 Its features include navigating documents, zooming and panning page images,
142 producing and displaying thumbnails, displaying document outlines, searching
143 documents for particular words in the hidden text layer, copying hidden text
144 to the clipboard, saving pages and documents as bundled or indirect multi-page
145 files, and printing page and documents.
147 The viewer can simultaneously display several pages using a side-by-side or
148 a continuous layout.")
149 (license license:gpl2+)))
151 (define-public pdf2djvu
159 "https://github.com/jwilk/pdf2djvu/releases/download/" version
160 "/pdf2djvu-" version ".tar.xz"))
162 (base32 "18r648kna6ccw0m0nfxxnsmz541k69d0w9zzqvm1x2l5qyyvgfsv"))))
163 (build-system gnu-build-system)
165 `(("gettext" ,gettext-minimal)
166 ("pkg-config" ,pkg-config)
167 ("python2" ,python-2)
168 ("python2-nose" ,python2-nose)))
170 `(("djvulibre" ,djvulibre)
172 ("graphicsmagick" ,graphicsmagick)
174 ("poppler-data" ,poppler-data)
175 ("util-linux-lib" ,util-linux "lib"))) ; for libuuid
177 `(#:test-target "test"))
178 (synopsis "PDF to DjVu converter")
180 "@code{pdf2djvu} creates DjVu files from PDF files.
181 It is able to extract:
186 @item document outline (bookmarks),
187 @item metadata (including XMP metadata).
189 (home-page "https://jwilk.net/software/pdf2djvu")
190 (license license:gpl2)))
192 (define-public djvu2pdf
199 (uri (string-append "https://0x2a.at/site/projects/djvu2pdf/djvu2pdf-"
202 (base32 "0v2ax30m7j1yi4m02nzn9rc4sn4vzqh5vywdh96r64j4pwvn5s5g"))))
203 (build-system gnu-build-system)
205 `(("djvulibre" ,djvulibre)
207 ("ghostscript" ,ghostscript)
212 `(#:tests? #f ; No test suite
214 (modify-phases %standard-phases
215 (add-after 'unpack 'fix-paths
216 (lambda* (#:key inputs #:allow-other-keys)
217 (let ((djvulibre (assoc-ref inputs "djvulibre"))
218 (gawk (assoc-ref inputs "gawk"))
219 (ghostscript (assoc-ref inputs "ghostscript"))
220 (grep (assoc-ref inputs "grep"))
221 (ncurses (assoc-ref inputs "ncurses"))
222 (which (assoc-ref inputs "which")))
223 (substitute* "djvu2pdf"
225 (string-append gawk "/bin/awk"))
227 (string-append djvulibre "/bin/ddjvu"))
229 (string-append djvulibre "/bin/djvudump"))
231 (string-append grep "/bin/grep"))
233 (string-append ghostscript "/bin/gs"))
235 (string-append ncurses "/bin/tput "))
237 (string-append which "/bin/which"))))
242 (lambda* (#:key outputs #:allow-other-keys)
243 (let ((out (assoc-ref %outputs "out")))
244 (install-file "djvu2pdf"
245 (string-append out "/bin"))
246 (install-file "djvu2pdf.1.gz"
247 (string-append out "/share/man/man1"))
249 (synopsis "DjVu to PDF converter")
250 (description "This is a small tool to convert DjVu files to PDF files.")
251 (home-page "https://0x2a.at/site/projects/djvu2pdf/")
252 (license license:gpl2+)))
254 (define-public minidjvu
261 (uri (string-append "mirror://sourceforge/minidjvu/minidjvu/"
262 version "/minidjvu-" version ".tar.gz"))
264 (base32 "0jmpvy4g68k6xgplj9zsl6brg6vi81mx3nx2x9hfbr1f4zh95j79"))))
265 (build-system gnu-build-system)
267 `(("gettext" ,gettext-minimal)))
269 `(("libjpeg-turbo" ,libjpeg-turbo)
273 '(#:configure-flags '("--disable-static")
275 #:tests? #f ; No test suite
277 (modify-phases %standard-phases
278 (add-after 'unpack 'fix-paths
280 (substitute* "Makefile.in"
284 (add-before 'install 'make-lib-directory
285 (lambda* (#:key outputs #:allow-other-keys)
286 (mkdir-p (string-append (assoc-ref outputs "out") "/lib"))
288 (synopsis "Black and white DjVu encoder")
290 "@code{minidjvu} is a multipage DjVu encoder and single page
291 encoder/decoder. It doesn't support colors or grayscales, just black
293 (home-page "https://sourceforge.net/projects/minidjvu/")
294 (license license:gpl2)))
296 (define-public djvusmooth
304 "https://github.com/jwilk/djvusmooth/releases/download/" version
305 "/djvusmooth-" version ".tar.gz"))
307 (base32 "0z403cklvxzz0qaczgv83ax0nknrd9h8micp04j9kjfdxk2sgval"))))
308 (build-system python-build-system)
310 `(("djvulibre" ,djvulibre)
311 ("python2-djvulibre" ,python2-djvulibre)
312 ("python2-subprocess32" ,python2-subprocess32)
313 ("python2-wxpython" ,python2-wxpython)))
317 (modify-phases %standard-phases
318 (add-after 'unpack 'fix-paths
319 (lambda* (#:key inputs #:allow-other-keys)
320 (substitute* "lib/djvused.py"
321 (("djvused_path = 'djvused'")
322 (string-append "djvused_path = '"
323 (assoc-ref inputs "djvulibre")
324 "/bin/djvused'"))))))))
325 (synopsis "Graphical editor for DjVu documents")
327 "@code{djvusmooth} is a graphical editor for DjVu_ documents.
330 @item edit document metadata,
331 @item edit document outline (bookmarks),
332 @item add, remove or edit hyperlinks,
333 @item correct occasional errors in the hidden text layer.
335 (home-page "https://jwilk.net/software/djvusmooth")
336 (license license:gpl2)))
338 (define-public didjvu
346 "https://github.com/jwilk/didjvu/releases/download/" version
347 "/didjvu-" version ".tar.gz"))
349 (base32 "0xyrnk8d2khi7q1zr28gjkjq6frz4mkb5jdl8821yzf12k7c8pbv"))))
350 (build-system gnu-build-system)
352 `(("python2-nose" ,python2-nose)))
354 `(("djvulibre" ,djvulibre)
355 ("minidjvu" ,minidjvu)
357 ("python2-gamera" ,python2-gamera)
358 ("python2-pillow" ,python2-pillow)))
360 `(#:modules ((guix build gnu-build-system)
361 ((guix build python-build-system) #:prefix python:)
363 #:imported-modules (,@%gnu-build-system-modules
364 (guix build python-build-system))
367 (modify-phases %standard-phases
369 (add-before 'check 'disable-failing-test
371 (substitute* "tests/test_ipc.py"
372 ;; test_wait_signal gets stuck forever
373 (("yield self\\._test_signal, name")
375 ;; test_path fails to find a file it should have created
376 (("path = os\\.getenv\\('PATH'\\)\\.split\\(':'\\)")
378 (substitute* "tests/test_timestamp.py"
379 ;; test_timezones fails with:
380 ;; '2009-12-18T21:25:14Z' != '2009-12-18T22:25:14+01:00'
384 (lambda* (#:key outputs #:allow-other-keys)
385 (let ((out (assoc-ref outputs "out")))
388 (string-append "PREFIX=" out)
390 (add-after 'install 'wrap-python
391 (assoc-ref python:%standard-phases 'wrap))
392 (add-after 'wrap-python 'wrap-path
393 (lambda* (#:key inputs outputs #:allow-other-keys)
394 (let ((out (assoc-ref outputs "out"))
395 (djvulibre (assoc-ref inputs "djvulibre")))
396 (wrap-program (string-append out "/bin/didjvu")
397 `("PATH" ":" prefix (,(string-append djvulibre "/bin"))))))))))
398 (synopsis "DjVu encoder with foreground/background separation")
400 "@code{didjvu} uses the @code{Gamera} framework to separate the foreground
401 and background layers of images, which can then be encoded into a DjVu file.")
402 (home-page "https://jwilk.net/software/didjvu")
403 (license license:gpl2)))
405 (define-public ocrodjvu
413 "https://github.com/jwilk/ocrodjvu/releases/download/" version
414 "/ocrodjvu-" version ".tar.xz"))
416 (base32 "09w9rqr7z2jd5kwp178zz2yrsc82mxs7gksipg92znxzgzhmw2ng"))))
417 (build-system gnu-build-system)
419 `(("libxml2" ,libxml2)
420 ("python2-nose" ,python2-nose)
421 ("python2-pillow" ,python2-pillow)))
423 `(("djvulibre" ,djvulibre)
426 ("python2-djvulibre" ,python2-djvulibre)
427 ("python2-html5lib" ,python2-html5lib)
428 ("python2-lxml" ,python2-lxml)
429 ("python2-pyicu" ,python2-pyicu)
430 ("python2-subprocess32" ,python2-subprocess32)
431 ("tesseract-ocr" ,tesseract-ocr)))
433 `(#:modules ((guix build gnu-build-system)
434 ((guix build python-build-system) #:prefix python:)
436 #:imported-modules (,@%gnu-build-system-modules
437 (guix build python-build-system))
440 (modify-phases %standard-phases
442 (add-before 'check 'disable-failing-test
444 (substitute* "tests/test_ipc.py"
445 ;; test_wait_signal gets stuck forever
446 (("yield self\\._test_signal, name")
448 ;; test_path fails to find a file it should have created
449 (("path = os\\.getenv\\('PATH'\\)\\.split\\(':'\\)")
451 ;; Disable tests with tesseract. They can't work without
452 ;; the language files that must downloaded by the final user
453 ;; as they are not packaged in Guix.
454 (substitute* "tests/ocrodjvu/test.py"
455 (("engines = stdout\\.getvalue\\(\\)\\.splitlines\\(\\)")
456 "engines = ['ocrad']"))
457 (substitute* "tests/ocrodjvu/test_integration.py"
458 (("engines = 'tesseract', 'cuneiform', 'gocr', 'ocrad'")
459 "engines = 'ocrad'"))))
461 (lambda* (#:key outputs #:allow-other-keys)
462 (let ((out (assoc-ref outputs "out")))
465 (string-append "PREFIX=" out)
467 (add-after 'install 'wrap-python
468 (assoc-ref python:%standard-phases 'wrap))
469 (add-after 'wrap-python 'wrap-path
470 (lambda* (#:key inputs outputs #:allow-other-keys)
471 (let ((out (assoc-ref outputs "out"))
472 (djvulibre (assoc-ref inputs "djvulibre"))
473 (ocrad (assoc-ref inputs "ocrad"))
474 (tesseract (assoc-ref inputs "tesseract-ocr")))
475 (for-each (lambda (file)
476 (wrap-program (string-append out "/bin/" file)
478 (,(string-append djvulibre "/bin:"
480 tesseract "/bin")))))
484 (synopsis "Program to perform OCR on DjVu files")
486 "@code{ocrodjvu} is a wrapper for OCR systems, that allows you to perform
488 (home-page "https://jwilk.net/software/ocrodjvu")
489 (license license:gpl2)))