gnu: Add qtwayland, version 6.3.1.
[jackhill/guix/guix.git] / gnu / packages / djvu.scm
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>
7 ;;;
8 ;;; This file is part of GNU Guix.
9 ;;;
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.
14 ;;;
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.
19 ;;;
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/>.
22
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))
54
55 (define-public djvulibre
56 (package
57 (name "djvulibre")
58 (version "3.5.28")
59 (source
60 (origin
61 (method url-fetch)
62 (uri (string-append "mirror://sourceforge/djvu/DjVuLibre/"
63 (string-replace-substring version "." ",")
64 "/djvulibre-" version ".tar.gz"))
65 (sha256
66 (base32 "0manxn1ly5n8nqamv47hz7akxi6v0rzwc9j1c3x99vngrjlr5qw2"))
67 (modules '((guix build utils)))
68 (snippet
69 '(begin
70 ;; This bundles software (e.g., zlib) and is entirely superfluous.
71 (delete-file-recursively "win32")
72 #t))))
73 (build-system gnu-build-system)
74 (native-inputs
75 ;; The 3.5.28 release tarball isn't bootstrapped.
76 (list autoconf automake libtool))
77 (inputs
78 (list libjpeg-turbo libtiff 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
95 (define-public djview
96 (package
97 (name "djview")
98 (version "4.12")
99 (source
100 (origin
101 (method git-fetch)
102 (uri (git-reference
103 (url "https://git.code.sf.net/p/djvu/djview-git")
104 (commit (string-append "release." version))))
105 (sha256
106 (base32 "0mn9ywjbc7iga50lbjclrk892g0x0rap0dmb6ybzjyarybdhhcxp"))
107 (file-name (git-file-name name version))))
108 (build-system gnu-build-system)
109 (native-inputs
110 (list autoconf automake libtool pkg-config qttools-5))
111 (inputs
112 (list djvulibre glib libxt libtiff qtbase-5))
113 (arguments
114 `(#:phases
115 (modify-phases %standard-phases
116 (add-after 'unpack 'fix-desktop-file
117 ;; Executable is "djview", not "djview4".
118 (lambda _
119 (substitute* "desktopfiles/djvulibre-djview4.desktop"
120 (("Exec=djview4 %f") "Exec=djview %f"))
121 #t))
122 (add-after 'unpack 'make-files-writable
123 (lambda _
124 (for-each make-file-writable
125 (find-files "."))
126 #t)))))
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.
130
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.
136
137 The viewer can simultaneously display several pages using a side-by-side or
138 a continuous layout.")
139 (license license:gpl2+)))
140
141 (define-public pdf2djvu
142 (package
143 (name "pdf2djvu")
144 (version "0.9.18.1")
145 (source
146 (origin
147 (method url-fetch)
148 (uri (string-append
149 "https://github.com/jwilk/pdf2djvu/releases/download/" version
150 "/pdf2djvu-" version ".tar.xz"))
151 (sha256
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))
156 (inputs
157 (list djvulibre
158 exiv2
159 graphicsmagick
160 poppler
161 poppler-data
162 `(,util-linux "lib"))) ;for libuuid
163 (synopsis "PDF to DjVu converter")
164 (description
165 "@code{pdf2djvu} creates DjVu files from PDF files.
166 It is able to extract:
167 @itemize
168 @item graphics,
169 @item text layer,
170 @item hyperlinks,
171 @item document outline (bookmarks),
172 @item metadata (including XMP metadata).
173 @end itemize\n")
174 (home-page "https://jwilk.net/software/pdf2djvu")
175 (license license:gpl2)))
176
177 (define-public djvu2pdf
178 (package
179 (name "djvu2pdf")
180 (version "0.9.2")
181 (source
182 (origin
183 (method url-fetch)
184 (uri (string-append "https://0x2a.at/site/projects/djvu2pdf/djvu2pdf-"
185 version ".tar.gz"))
186 (sha256
187 (base32 "0v2ax30m7j1yi4m02nzn9rc4sn4vzqh5vywdh96r64j4pwvn5s5g"))))
188 (build-system gnu-build-system)
189 (inputs
190 (list djvulibre
191 gawk
192 ghostscript
193 grep
194 ncurses
195 which))
196 (arguments
197 `(#:tests? #f ; No test suite
198 #:phases
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"
209 (("awk")
210 (string-append gawk "/bin/awk"))
211 (("ddjvu")
212 (string-append djvulibre "/bin/ddjvu"))
213 (("djvudump")
214 (string-append djvulibre "/bin/djvudump"))
215 (("grep")
216 (string-append grep "/bin/grep"))
217 (("gs")
218 (string-append ghostscript "/bin/gs"))
219 (("tput ")
220 (string-append ncurses "/bin/tput "))
221 (("which")
222 (string-append which "/bin/which"))))
223 #t))
224 (delete 'configure)
225 (delete 'build)
226 (replace 'install
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"))
233 #t))))))
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+)))
238
239 (define-public minidjvu
240 (package
241 (name "minidjvu")
242 (version "0.8")
243 (source
244 (origin
245 (method url-fetch)
246 (uri (string-append "mirror://sourceforge/minidjvu/minidjvu/"
247 version "/minidjvu-" version ".tar.gz"))
248 (sha256
249 (base32 "0jmpvy4g68k6xgplj9zsl6brg6vi81mx3nx2x9hfbr1f4zh95j79"))))
250 (build-system gnu-build-system)
251 (native-inputs
252 `(("gettext" ,gettext-minimal)))
253 (inputs
254 (list libjpeg-turbo libtiff zlib))
255 (arguments
256 '(#:configure-flags '("--disable-static")
257 #:parallel-build? #f
258 #:tests? #f ; No test suite
259 #:phases
260 (modify-phases %standard-phases
261 (add-after 'unpack 'fix-paths
262 (lambda _
263 (substitute* "Makefile.in"
264 (("/usr/bin/gzip")
265 "gzip"))
266 #t))
267 (add-before 'install 'make-lib-directory
268 (lambda* (#:key outputs #:allow-other-keys)
269 (mkdir-p (string-append (assoc-ref outputs "out") "/lib"))
270 #t)))))
271 (synopsis "Black and white DjVu encoder")
272 (description
273 "@code{minidjvu} is a multipage DjVu encoder and single page
274 encoder/decoder. It doesn't support colors or grayscales, just black
275 and white.")
276 (home-page "https://sourceforge.net/projects/minidjvu/")
277 (license license:gpl2)))
278
279 (define-public didjvu
280 (let ((revision "0")
281 (commit "c792d61e85fbe5b6e678bc7d686b0208717c587b"))
282 (package
283 (name "didjvu")
284 (version (git-version "0.9" revision commit))
285 (source (origin
286 (method git-fetch)
287 (uri (git-reference
288 (url "https://github.com/FriedrichFroebel/didjvu")
289 (commit commit)))
290 (file-name (git-file-name name version))
291 (sha256
292 (base32
293 "09lwfwirmfl93062i2rvdcrgwp9fj95ny07059bxq7dl6z0z35qj"))))
294 (build-system gnu-build-system)
295 (arguments
296 `(#:modules ((guix build gnu-build-system)
297 ((guix build python-build-system) #:prefix python:)
298 (guix build utils))
299 #:imported-modules (,@%gnu-build-system-modules
300 (guix build python-build-system))
301 #:test-target "test"
302 #:phases
303 (modify-phases %standard-phases
304 (delete 'configure)
305 (add-before 'check 'disable-failing-test
306 (lambda _
307 (substitute* "tests/test_ipc.py"
308 ;; test_wait_signal gets stuck forever
309 (("yield self\\._test_signal, name")
310 "return True")
311 ;; test_path fails to find a file it should have created
312 (("path = os\\.getenv\\('PATH'\\)\\.split\\(':'\\)")
313 "return True"))
314 (substitute* "tests/test_timestamp.py"
315 ;; test_timezones fails with:
316 ;; '2009-12-18T21:25:14Z' != '2009-12-18T22:25:14+01:00'
317 (("@fork_isolation")
318 "return True"))))
319 (replace 'install
320 (lambda* (#:key outputs #:allow-other-keys)
321 (let ((out (assoc-ref outputs "out")))
322 (invoke "make"
323 "DESTDIR="
324 (string-append "PREFIX=" out)
325 "install"))))
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))
335 (inputs
336 (list djvulibre
337 minidjvu
338 python-gamera
339 python-pillow
340 python-wrapper))
341 (synopsis "DjVu encoder with foreground/background separation")
342 (description
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))))
347
348 (define-public ocrodjvu
349 (let ((revision "0")
350 (commit "0dd3364462fc77d5674b4457fcc8230835323c30"))
351 (package
352 (name "ocrodjvu")
353 (version (git-version "0.12" revision commit))
354 (source (origin
355 (method git-fetch)
356 (uri (git-reference
357 ;; Use the following fork repository, as upstream
358 ;; doesn't seem too concerned with Python 3
359 ;; compatibility.
360 (url "https://github.com/rmast/ocrodjvu")
361 (commit commit)))
362 (file-name (git-file-name name version))
363 (sha256
364 (base32
365 "0x64hg9ysrk8sismxb4jgk0sq7r9j90v2i9765xhmxpiy6f0lpni"))))
366 (build-system gnu-build-system)
367 (native-inputs
368 (list libxml2 python-nose python-pillow))
369 (inputs
370 (list djvulibre
371 ocrad
372 python-djvulibre
373 python-future
374 python-html5lib
375 python-lxml
376 python-pyicu
377 python-regex
378 python-wrapper
379 tesseract-ocr))
380 (arguments
381 (list
382 #:modules '((guix build gnu-build-system)
383 ((guix build python-build-system) #:prefix python:)
384 (guix build utils))
385 #:imported-modules `(,@%gnu-build-system-modules
386 (guix build python-build-system))
387 #:test-target "test"
388 #:phases
389 #~(modify-phases %standard-phases
390 (delete 'configure)
391 (add-before 'check 'disable-failing-test
392 (lambda _
393 (substitute* "tests/test_ipc.py"
394 ;; test_wait_signal gets stuck forever
395 (("yield self\\._test_signal, name")
396 "return True")
397 ;; test_path fails to find a file it should have created
398 (("path = os\\.getenv\\('PATH'\\)\\.split\\(':'\\)")
399 "return True"))
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'"))))
409 (replace 'install
410 (lambda _
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)
419 `("PATH" ":" prefix
420 (,(string-append
421 #$(this-package-input "djvulibre") "/bin:"
422 #$(this-package-input "ocrad") "/bin:"
423 #$(this-package-input "tesseract-ocr")
424 "/bin")))))
425 '("bin/djvu2hocr"
426 "bin/hocr2djvused"
427 "bin/ocrodjvu")))))))
428 (synopsis "Program to perform OCR on DjVu files")
429 (description
430 "@code{ocrodjvu} is a wrapper for OCR systems, that allows you to perform
431 OCR on DjVu files.")
432 (home-page "https://jwilk.net/software/ocrodjvu")
433 (license license:gpl2))))