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 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
8 ;;; This file is part of GNU Guix.
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23 (define-module (gnu packages djvu)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (guix utils)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix gexp)
29 #:use-module (guix git-download)
30 #:use-module (guix build-system gnu)
31 #:use-module (guix build-system python)
32 #:use-module (gnu packages autotools)
33 #:use-module (gnu packages base)
34 #:use-module (gnu packages check)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages gawk)
37 #:use-module (gnu packages gettext)
38 #:use-module (gnu packages ghostscript)
39 #:use-module (gnu packages glib)
40 #:use-module (gnu packages image)
41 #:use-module (gnu packages imagemagick)
42 #:use-module (gnu packages linux)
43 #:use-module (gnu packages ncurses)
44 #:use-module (gnu packages ocr)
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 wxwidgets)
52 #:use-module (gnu packages xml)
53 #:use-module (gnu packages xorg))
55 (define-public djvulibre
62 (uri (string-append "mirror://sourceforge/djvu/DjVuLibre/"
63 (string-replace-substring version "." ",")
64 "/djvulibre-" version ".tar.gz"))
66 (base32 "0manxn1ly5n8nqamv47hz7akxi6v0rzwc9j1c3x99vngrjlr5qw2"))
67 (modules '((guix build utils)))
70 ;; This bundles software (e.g., zlib) and is entirely superfluous.
71 (delete-file-recursively "win32")
73 (build-system gnu-build-system)
75 ;; The 3.5.28 release tarball isn't bootstrapped.
76 (list autoconf automake libtool))
78 (list libjpeg-turbo libtiff zlib))
81 (modify-phases %standard-phases
82 (add-after 'bootstrap 'make-reproducible
84 ;; Ensure there are no timestamps in .svgz files.
85 (substitute* "desktopfiles/Makefile.am"
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
93 (license license:gpl2+)))
103 (url "https://git.code.sf.net/p/djvu/djview-git")
104 (commit (string-append "release." version))))
106 (base32 "0mn9ywjbc7iga50lbjclrk892g0x0rap0dmb6ybzjyarybdhhcxp"))
107 (file-name (git-file-name name version))))
108 (build-system gnu-build-system)
110 (list autoconf automake libtool pkg-config qttools-5))
112 (list djvulibre glib libxt libtiff qtbase-5))
115 (modify-phases %standard-phases
116 (add-after 'unpack 'fix-desktop-file
117 ;; Executable is "djview", not "djview4".
119 (substitute* "desktopfiles/djvulibre-djview4.desktop"
120 (("Exec=djview4 %f") "Exec=djview %f"))
122 (add-after 'unpack 'make-files-writable
124 (for-each make-file-writable
127 (home-page "http://djvu.sourceforge.net/djview4.html")
128 (synopsis "Viewer for the DjVu image format")
129 (description "DjView is a standalone viewer for DjVu files.
131 Its features include navigating documents, zooming and panning page images,
132 producing and displaying thumbnails, displaying document outlines, searching
133 documents for particular words in the hidden text layer, copying hidden text
134 to the clipboard, saving pages and documents as bundled or indirect multi-page
135 files, and printing page and documents.
137 The viewer can simultaneously display several pages using a side-by-side or
138 a continuous layout.")
139 (license license:gpl2+)))
141 (define-public pdf2djvu
149 "https://github.com/jwilk/pdf2djvu/releases/download/" version
150 "/pdf2djvu-" version ".tar.xz"))
152 (base32 "0c595yziz81c9izf9s5sskd00qmgz2n1hp2vdcgg0dx81g3xfidb"))))
153 (build-system gnu-build-system)
154 (arguments (list #:tests? #f)) ;requires Python 2
155 (native-inputs (list gettext-minimal pkg-config))
162 `(,util-linux "lib"))) ;for libuuid
163 (synopsis "PDF to DjVu converter")
165 "@code{pdf2djvu} creates DjVu files from PDF files.
166 It is able to extract:
171 @item document outline (bookmarks),
172 @item metadata (including XMP metadata).
174 (home-page "https://jwilk.net/software/pdf2djvu")
175 (license license:gpl2)))
177 (define-public djvu2pdf
184 (uri (string-append "https://0x2a.at/site/projects/djvu2pdf/djvu2pdf-"
187 (base32 "0v2ax30m7j1yi4m02nzn9rc4sn4vzqh5vywdh96r64j4pwvn5s5g"))))
188 (build-system gnu-build-system)
197 `(#:tests? #f ; No test suite
199 (modify-phases %standard-phases
200 (add-after 'unpack 'fix-paths
201 (lambda* (#:key inputs #:allow-other-keys)
202 (let ((djvulibre (assoc-ref inputs "djvulibre"))
203 (gawk (assoc-ref inputs "gawk"))
204 (ghostscript (assoc-ref inputs "ghostscript"))
205 (grep (assoc-ref inputs "grep"))
206 (ncurses (assoc-ref inputs "ncurses"))
207 (which (assoc-ref inputs "which")))
208 (substitute* "djvu2pdf"
210 (string-append gawk "/bin/awk"))
212 (string-append djvulibre "/bin/ddjvu"))
214 (string-append djvulibre "/bin/djvudump"))
216 (string-append grep "/bin/grep"))
218 (string-append ghostscript "/bin/gs"))
220 (string-append ncurses "/bin/tput "))
222 (string-append which "/bin/which"))))
227 (lambda* (#:key outputs #:allow-other-keys)
228 (let ((out (assoc-ref %outputs "out")))
229 (install-file "djvu2pdf"
230 (string-append out "/bin"))
231 (install-file "djvu2pdf.1.gz"
232 (string-append out "/share/man/man1"))
234 (synopsis "DjVu to PDF converter")
235 (description "This is a small tool to convert DjVu files to PDF files.")
236 (home-page "https://0x2a.at/site/projects/djvu2pdf/")
237 (license license:gpl2+)))
239 (define-public minidjvu
246 (uri (string-append "mirror://sourceforge/minidjvu/minidjvu/"
247 version "/minidjvu-" version ".tar.gz"))
249 (base32 "0jmpvy4g68k6xgplj9zsl6brg6vi81mx3nx2x9hfbr1f4zh95j79"))))
250 (build-system gnu-build-system)
252 `(("gettext" ,gettext-minimal)))
254 (list libjpeg-turbo libtiff zlib))
256 '(#:configure-flags '("--disable-static")
258 #:tests? #f ; No test suite
260 (modify-phases %standard-phases
261 (add-after 'unpack 'fix-paths
263 (substitute* "Makefile.in"
267 (add-before 'install 'make-lib-directory
268 (lambda* (#:key outputs #:allow-other-keys)
269 (mkdir-p (string-append (assoc-ref outputs "out") "/lib"))
271 (synopsis "Black and white DjVu encoder")
273 "@code{minidjvu} is a multipage DjVu encoder and single page
274 encoder/decoder. It doesn't support colors or grayscales, just black
276 (home-page "https://sourceforge.net/projects/minidjvu/")
277 (license license:gpl2)))
279 (define-public didjvu
281 (commit "c792d61e85fbe5b6e678bc7d686b0208717c587b"))
284 (version (git-version "0.9" revision commit))
288 (url "https://github.com/FriedrichFroebel/didjvu")
290 (file-name (git-file-name name version))
293 "09lwfwirmfl93062i2rvdcrgwp9fj95ny07059bxq7dl6z0z35qj"))))
294 (build-system gnu-build-system)
296 `(#:modules ((guix build gnu-build-system)
297 ((guix build python-build-system) #:prefix python:)
299 #:imported-modules (,@%gnu-build-system-modules
300 (guix build python-build-system))
303 (modify-phases %standard-phases
305 (add-before 'check 'disable-failing-test
307 (substitute* "tests/test_ipc.py"
308 ;; test_wait_signal gets stuck forever
309 (("yield self\\._test_signal, name")
311 ;; test_path fails to find a file it should have created
312 (("path = os\\.getenv\\('PATH'\\)\\.split\\(':'\\)")
314 (substitute* "tests/test_timestamp.py"
315 ;; test_timezones fails with:
316 ;; '2009-12-18T21:25:14Z' != '2009-12-18T22:25:14+01:00'
320 (lambda* (#:key outputs #:allow-other-keys)
321 (let ((out (assoc-ref outputs "out")))
324 (string-append "PREFIX=" out)
326 (add-after 'install 'wrap-python
327 (assoc-ref python:%standard-phases 'wrap))
328 (add-after 'wrap-python 'wrap-path
329 (lambda* (#:key inputs outputs #:allow-other-keys)
330 (let ((out (assoc-ref outputs "out"))
331 (djvulibre (assoc-ref inputs "djvulibre")))
332 (wrap-program (string-append out "/bin/didjvu")
333 `("PATH" ":" prefix (,(string-append djvulibre "/bin"))))))))))
334 (native-inputs (list python-nose))
341 (synopsis "DjVu encoder with foreground/background separation")
343 "@code{didjvu} uses the @code{Gamera} framework to separate the foreground
344 and background layers of images, which can then be encoded into a DjVu file.")
345 (home-page "https://jwilk.net/software/didjvu")
346 (license license:gpl2))))
348 (define-public ocrodjvu
350 (commit "0dd3364462fc77d5674b4457fcc8230835323c30"))
353 (version (git-version "0.12" revision commit))
357 ;; Use the following fork repository, as upstream
358 ;; doesn't seem too concerned with Python 3
360 (url "https://github.com/rmast/ocrodjvu")
362 (file-name (git-file-name name version))
365 "0x64hg9ysrk8sismxb4jgk0sq7r9j90v2i9765xhmxpiy6f0lpni"))))
366 (build-system gnu-build-system)
368 (list libxml2 python-nose python-pillow))
382 #:modules '((guix build gnu-build-system)
383 ((guix build python-build-system) #:prefix python:)
385 #:imported-modules `(,@%gnu-build-system-modules
386 (guix build python-build-system))
389 #~(modify-phases %standard-phases
391 (add-before 'check 'disable-failing-test
393 (substitute* "tests/test_ipc.py"
394 ;; test_wait_signal gets stuck forever
395 (("yield self\\._test_signal, name")
397 ;; test_path fails to find a file it should have created
398 (("path = os\\.getenv\\('PATH'\\)\\.split\\(':'\\)")
400 ;; Disable tests with tesseract. They can't work without
401 ;; the language files that must downloaded by the final user
402 ;; as they are not packaged in Guix.
403 (substitute* "tests/ocrodjvu/test.py"
404 (("engines = stdout\\.getvalue\\(\\)\\.splitlines\\(\\)")
405 "engines = ['ocrad']"))
406 (substitute* "tests/ocrodjvu/test_integration.py"
407 (("engines = 'tesseract', 'cuneiform', 'gocr', 'ocrad'")
408 "engines = 'ocrad'"))))
411 (invoke "make" "install"
412 "DESTDIR=" (string-append "PREFIX=" #$output))))
413 (add-after 'install 'wrap-python
414 (assoc-ref python:%standard-phases 'wrap))
415 (add-after 'wrap-python 'wrap-path
416 (lambda* (#:key outputs #:allow-other-keys)
417 (for-each (lambda (file)
418 (wrap-program (search-input-file outputs file)
421 #$(this-package-input "djvulibre") "/bin:"
422 #$(this-package-input "ocrad") "/bin:"
423 #$(this-package-input "tesseract-ocr")
427 "bin/ocrodjvu")))))))
428 (synopsis "Program to perform OCR on DjVu files")
430 "@code{ocrodjvu} is a wrapper for OCR systems, that allows you to perform
432 (home-page "https://jwilk.net/software/ocrodjvu")
433 (license license:gpl2))))