gnu: linux-libre 5.19: Update to 5.19.14.
[jackhill/guix/guix.git] / gnu / packages / scanner.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 John Darrington <jmd@gnu.org>
3 ;;; Copyright © 2015 Andy Wingo <wingo@igalia.com>
4 ;;; Copyright © 2016 Andy Patterson <ajpatter@uwaterloo.ca>
5 ;;; Copyright © 2017, 2019, 2020, 2022 Tobias Geerinckx-Rice <me@tobias.gr>
6 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2022 João Gabriel <joaog.bastos@protonmail.ch>
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
24 (define-module (gnu packages scanner)
25 #:use-module (gnu packages)
26 #:use-module (gnu packages autotools)
27 #:use-module (gnu packages avahi)
28 #:use-module (gnu packages boost)
29 #:use-module (gnu packages compression)
30 #:use-module (gnu packages freedesktop)
31 #:use-module (gnu packages gettext)
32 #:use-module (gnu packages ghostscript)
33 #:use-module (gnu packages glib)
34 #:use-module (gnu packages gtk)
35 #:use-module (gnu packages image)
36 #:use-module (gnu packages imagemagick)
37 #:use-module (gnu packages libusb)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages pkg-config)
40 #:use-module (gnu packages python)
41 #:use-module (gnu packages textutils)
42 #:use-module (gnu packages tls)
43 #:use-module (gnu packages xml)
44 #:use-module (guix build-system gnu)
45 #:use-module (guix download)
46 #:use-module (guix git-download)
47 #:use-module (guix gexp)
48 #:use-module ((guix licenses)
49 #:prefix license:)
50 #:use-module (guix packages)
51 #:use-module (guix utils))
52
53 (define-public sane-airscan
54 (package
55 (name "sane-airscan")
56 (version "0.99.27")
57 (source
58 (origin
59 (method git-fetch)
60 (uri (git-reference
61 (url "https://github.com/alexpevzner/sane-airscan")
62 (commit version)))
63 (file-name (git-file-name name version))
64 (sha256
65 (base32 "1syxsih1kdnz9slsg5a92bqnllagm4cybqk4n2y6mbkqn6h0zlnv"))))
66 (build-system gnu-build-system)
67 (arguments
68 (list #:make-flags
69 #~(list (string-append "prefix=" #$output)
70 (string-append "libdir=$(prefix)/lib"))
71 #:phases
72 #~(modify-phases %standard-phases
73 (delete 'configure )))) ; no configure script
74 (native-inputs
75 (list pkg-config))
76 (inputs
77 (list avahi
78 gnutls
79 libjpeg-turbo
80 libpng
81 libxml2
82 sane-backends))
83 (home-page "https://github.com/alexpevzner/sane-airscan")
84 (synopsis "SANE backend for eSCL (AirScan) and WSD document scanners")
85 (description ; no @acronym{eSCL} because the meaning isn't officially known
86 "This SANE backend lets you scan documents and images from scanners and
87 multi-function printers that speak eSCL (marketed as ``AirScan'') or
88 @acronym{WSD, Web Services for Devices} (or ``WS-Scan'').
89
90 Both are vendor-neutral protocols that allow ``driverless'' scanning over IPv4
91 and IPv6 networks without the vendor-specific drivers that make up most of the
92 sane-backends collection. This is similar to how most contemporary printers
93 speak the universal @acronym{IPP, Internet Printing Protocol}.
94
95 Only scanners that support eSCL will also work over USB. This requires a
96 suitable IPP-over-USB daemon like ipp-usb to be installed and configured.
97
98 Any eSCL or WSD-capable scanner should just work. sane-airscan automatically
99 discovers and configures devices, including which protocol to use. It was
100 successfully tested with many devices from Brother, Canon, Dell, Kyocera,
101 Lexmark, Epson, HP, OKI, Panasonic, Pantum, Ricoh, Samsung, and Xerox, with both
102 WSD and eSCL.")
103 (license (list license:gpl2+ ; the combined work
104 license:expat)))) ; http_parser.[ch]
105
106 (define-public sane-backends-minimal
107 (package
108 (name "sane-backends-minimal")
109 (version "1.0.32")
110 (source (origin
111 (method git-fetch)
112 (uri (git-reference
113 (url "https://gitlab.com/sane-project/backends")
114 (commit version)))
115 (file-name (git-file-name name version))
116 (sha256
117 (base32 "13jlqdp7n7z2n78v6idl3ri5idk7ddk9j8wrmh73lba8l9y8xnsi"))
118 (modules '((guix build utils)))
119 (snippet
120 ;; Generated HTML files and udev rules normally embed a
121 ;; timestamp. Work around that to build things reproducibly.
122 '(begin
123 (substitute* "tools/sane-desc.c"
124 (("asctime \\(localtime \\(&current_time\\)\\)")
125 "\"1970-01-01\""))))))
126 (build-system gnu-build-system)
127 (native-inputs
128 `(("autoconf" ,autoconf)
129 ("autoconf-archive" ,autoconf-archive)
130 ("automake" ,automake)
131 ("gettext" ,gettext-minimal)
132 ("libtool" ,libtool)
133 ("pkg-config" ,pkg-config)
134 ;; For scripts/pixma_gen_options.py.
135 ("python" ,python-wrapper)))
136 (inputs
137 (list libusb))
138 (arguments
139 `(#:phases
140 (modify-phases %standard-phases
141 (add-before 'bootstrap 'zap-unnecessary-git-dependency
142 (lambda _
143 ;; This runs before default patch-shebangs phase.
144 (substitute* "tools/git-version-gen"
145 (("/bin/sh") (which "sh")))
146 (with-output-to-file ".tarball-version"
147 (lambda _ (format #t ,version)))))
148 (add-before 'configure 'disable-backends
149 (lambda _
150 (setenv "BACKENDS" " ")
151
152 ;; Disable tests that may require back ends to be built.
153 (substitute* "testsuite/Makefile.in"
154 ((" backend ") " "))))
155 (add-before 'configure 'disable-failing-tests
156 (lambda _
157 ;; Disable unmaintained tests that that fail with errors resembling:
158 ;;
159 ;; < # by sane-desc 3.5 from sane-backends 1.0.24git on Jul 31 2013
160 ;; ---
161 ;; > # by sane-desc 3.5 from sane-backends 1.0.27 on 1970-01-01#
162 ;; FAIL: sane-desc -m usermap -s ./data
163 (for-each
164 (lambda (pattern)
165 (substitute* "testsuite/tools/Makefile.in"
166 (((string-append " " pattern " ")) " ")))
167 (list "usermap" "db" "udev" "udev\\+acl" "udev\\+hwdb" "hwdb"))
168
169 ;; Disable tests that try to connect to actual USB hardware & fail
170 ;; with the following error when no USB access is allowed at all:
171 ;;
172 ;; sanei_usb_test: sanei_usb_test.c:849: main: Assertion
173 ;; `test_init (1)' failed.
174 (substitute* "testsuite/sanei/Makefile.in"
175 (("sanei_usb_test\\$\\(EXEEXT\\) ") ""))))
176 (add-before 'build 'build-pixma_sane_options.c
177 ;; "No rule to make target '../backend/pixma/pixma_sane_options.c',
178 ;; needed by 'sane-backends.pot-update'."
179 (lambda _
180 (invoke "make" "-C" "backend" "pixma/pixma_sane_options.c")))
181 (add-after 'install 'install-udev-rules
182 (lambda* (#:key outputs #:allow-other-keys)
183 (let ((out (assoc-ref outputs "out")))
184 (mkdir-p (string-append out "/lib/udev/rules.d"))
185 (copy-file "tools/udev/libsane.rules"
186 (string-append out
187 "/lib/udev/rules.d/"
188 "60-libsane.rules")))))
189 (add-after 'install 'make-reproducible
190 ;; XXX Work around an old bug <https://issues.guix.gnu.org/26247>.
191 ;; Then work around "Throw to key `decoding-error' ..." by using sed.
192 (lambda* (#:key outputs #:allow-other-keys)
193 (let* ((out (assoc-ref outputs "out"))
194 (locale (string-append out "/share/locale")))
195 (with-directory-excursion locale
196 (for-each (lambda (file)
197 (invoke "sed" "-i" "/^PO-Revision-Date:/d" file))
198 (list "en@boldquot/LC_MESSAGES/sane-backends.mo"
199 "en@quot/LC_MESSAGES/sane-backends.mo")))))))))
200 (home-page "http://www.sane-project.org")
201 (synopsis
202 "Raster image scanner library and drivers, without scanner support")
203 (description "SANE stands for \"Scanner Access Now Easy\" and is an API
204 proving access to any raster image scanner hardware (flatbed scanner,
205 hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The
206 package contains the library, but no drivers.")
207 (license license:gpl2+))) ; plus linking exception
208
209 ;; This variant links in the hpaio backend provided by hplip, which adds
210 ;; support for HP scanners whose backends are not maintained by the SANE
211 ;; project, and builds all of those backends.
212 (define-public sane-backends
213 (package/inherit sane-backends-minimal
214 (name "sane-backends")
215 (inputs
216 `(("hplip" ,(@ (gnu packages cups) hplip-minimal))
217 ("libjpeg" ,libjpeg-turbo) ; for pixma/epsonds/other back ends
218 ("libpng" ,libpng) ; support ‘scanimage --format=png’
219 ("libxml2" ,libxml2) ; for pixma back end
220 ,@(package-inputs sane-backends-minimal)))
221 (arguments
222 (substitute-keyword-arguments (package-arguments sane-backends-minimal)
223 ((#:phases phases)
224 `(modify-phases ,phases
225 (delete 'disable-backends)
226 (add-after 'disable-failing-tests 'disable-failing-backend-tests
227 (lambda _
228 ;; Disable test that fails on i686:
229 ;; <https://bugs.gnu.org/39449>
230 (substitute* "testsuite/backend/genesys/Makefile.in"
231 ((" genesys_unit_tests\\$\\(EXEEXT\\)") ""))
232 #t))
233 (add-after 'unpack 'add-backends
234 (lambda _
235 (substitute* "backend/dll.conf.in"
236 (("hp5590" all) (format #f "~a~%~a" all "hpaio")))
237 #t))
238 (add-after 'install 'install-hpaio
239 (lambda* (#:key inputs outputs #:allow-other-keys)
240 (define hplip (string-append (assoc-ref inputs "hplip")
241 "/lib/sane"))
242 (define out (string-append (assoc-ref outputs "out")
243 "/lib/sane"))
244 (for-each
245 (lambda (file)
246 (symlink file (string-append out "/" (basename file))))
247 (find-files hplip))
248 #t))))))
249 (synopsis
250 "Raster image scanner library and drivers, with scanner support")
251 (description "SANE stands for \"Scanner Access Now Easy\" and is an API
252 proving access to any raster image scanner hardware (flatbed scanner,
253 hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The
254 package contains the library and drivers.")))
255
256 (define-public utsushi
257 (let ((commit "839d06a5a80b353cb604eb9f7d352a1648ab1fdf"))
258 (package
259 (name "utsushi")
260 (version (git-version "0.65.0" "1" commit))
261 (source (origin
262 (method git-fetch)
263 (uri (git-reference
264 (url "https://gitlab.com/utsushi/utsushi")
265 (commit commit)))
266 (file-name (git-file-name name version))
267 (sha256
268 (base32
269 "0i6ipqy61abbsmqqqy5sii0vlib146snvp975sgjmv4nzy9mwf24"))))
270 (build-system gnu-build-system)
271 (arguments
272 (list #:tests? #f
273 #:configure-flags
274 #~(list (string-append "--with-boost-libdir="
275 #$(this-package-input "boost") "/lib")
276 "CXXFLAGS=-Wno-error")
277 #:phases
278 #~(modify-phases %standard-phases
279 (add-before 'bootstrap 'zap-unnecessary-git-dependency
280 (lambda _
281 (substitute* "configure.ac"
282 (("-m4_esyscmd_s\\(\\[git describe --always\\]\\)") ""))))
283 (add-after 'install 'install-udev-rules
284 (lambda* (#:key outputs #:allow-other-keys)
285 (mkdir-p (string-append #$output "/lib/udev/rules.d"))
286 (install-file "drivers/esci/utsushi-esci.rules"
287 (string-append #$output
288 "/lib/udev/rules.d")))))))
289 (inputs (list boost
290 eudev
291 sane-backends-minimal
292 libusb
293 libjpeg-turbo
294 imagemagick
295 libtiff
296 zlib))
297 (native-inputs (list util-linux
298 autoconf
299 autoconf-archive
300 automake
301 gettext-minimal
302 libtool
303 libxslt
304 pkg-config))
305 (home-page "https://gitlab.com/utsushi/utsushi")
306 (synopsis "Image scanning software for EPSON devices")
307 (description
308 "Utsushi is a set of applications for image scanning with
309 support for a number of EPSON scanners, including a compatibility driver to
310 interface with software built around the @acronym{SANE, Scanner Access Now Easy}
311 standard.")
312 (license license:gpl3+))))
313
314 (define-public scanbd
315 (package
316 (name "scanbd")
317 (version "1.5.1")
318 (source
319 (origin
320 (method url-fetch)
321 (uri (string-append "mirror://sourceforge/scanbd/releases/"
322 "scanbd-" version ".tgz"))
323 (sha256
324 (base32 "0pvy4qirfjdfm8aj6x5rkbgl7hk3jfa2s21qkk8ic5dqfjjab75n"))))
325 (build-system gnu-build-system)
326 (arguments
327 (list #:configure-flags
328 #~(list "--disable-debug"
329 "--sysconfdir=/etc"
330 "CFLAGS=-Wno-error") ; warnings should never be fatal
331 #:phases
332 #~(modify-phases %standard-phases
333 (replace 'install
334 (lambda* (#:key make-flags #:allow-other-keys)
335 (let ((conf (string-append #$output "/etc/scanbd")))
336 (apply invoke "make" "install"
337 ;; Install example configuration to the store, not
338 ;; /etc. These don't inherit from each other, so
339 ;; we need both.
340 (string-append "scanbdconfdir=" conf)
341 (string-append "scannerconfdir=" conf "/scanner.d")
342 make-flags))))
343 (add-after 'install 'install-extra-documentation
344 ;; The README provides more detailed set-up instructions than
345 ;; the man page.
346 (lambda _
347 (let ((doc (string-append #$output "/share/doc/"
348 #$name "-" #$version)))
349 (install-file "doc/README.txt" doc)))))))
350 (native-inputs
351 (list pkg-config))
352 (inputs
353 `(("dbus" ,dbus)
354 ("libconfuse" ,libconfuse)
355 ("sane-backends" ,sane-backends)
356 ("udev" ,eudev)
357 ("zlib" ,zlib)))
358 (home-page "https://scanbd.sourceforge.io")
359 (synopsis "Configurable scanner button monitor")
360 (description "Scanbd stands for scanner button daemon. It regularly polls
361 scanners for pressed buttons, function knob changes, or other events such
362 as (un)plugging the scanner or inserting and removing paper. Then it performs
363 the desired action(s) such as saving, copying, or e-mailing the image.
364
365 Actions can be fully customized through scripts, based on any combination of
366 switch or knob settings. Events are also signaled over D-Bus and scans can
367 even be triggered over D-Bus from foreign applications.
368
369 Scanbd talks to scanners through the @acronym{SANE, Scanner Access Now Easy}
370 back-end library. This means that it supports almost all existing scanners,
371 provided the driver also exposes the buttons.")
372 (license license:gpl2+)))
373
374 (define-public xsane
375 (package
376 (name "xsane")
377 (version "0.999")
378 (source
379 (origin
380 (method git-fetch)
381 (uri (git-reference
382 (url "https://gitlab.com/sane-project/frontend/xsane.git")
383 (commit version)))
384 (file-name (git-file-name name version))
385 (sha256
386 (base32 "08zvxj7i1s88ckrsqldmsrikc3g62a6p3s3i5b5x4krcfpi3vs50"))
387 ;; Apply some important-looking fixes. There are many more unreleased
388 ;; commits upstream. A 1.0 release is planned.
389 (patches (search-patches "xsane-fix-memory-leak.patch"
390 "xsane-fix-pdf-floats.patch"
391 "xsane-fix-snprintf-buffer-length.patch"
392 "xsane-support-ipv6.patch"
393 "xsane-tighten-default-umask.patch"))
394 (modules '((guix build utils)))
395 (snippet
396 '(begin
397 ;; Remove ancient bundled lprng code under a non-free licence. See
398 ;; <https://trisquel.info/en/issues/10713>, which solves the problem
399 ;; by replacing it with a newer (free) copy. We let the build fall
400 ;; back to the system version instead, which appears to work fine.
401 (delete-file "lib/snprintf.c")
402 (substitute* "lib/Makefile.in"
403 (("snprintf\\.o ") ""))
404 #t))))
405 (build-system gnu-build-system)
406 (arguments
407 `(#:make-flags
408 (list (string-append "xsanedocdir=" (assoc-ref %outputs "out")
409 "/share/doc/" ,name "-" ,version))
410 #:tests? #f ; no test suite
411 #:phases
412 (modify-phases %standard-phases
413 (add-after 'unpack 'patch-invalid-dereference
414 ;; Fix the following compilation error with libpng:
415 ;; xsane-save.c: In function ‘xsane_save_png’:
416 ;; xsane-save.c:4913:21: error: dereferencing pointer to
417 ;; incomplete type ‘png_struct {aka struct png_struct_def}’
418 ;; if (setjmp(png_ptr->jmpbuf))
419 ;; ^
420 (lambda _
421 (substitute* "src/xsane-save.c"
422 (("png_ptr->jmpbuf") "png_jmpbuf(png_ptr)"))
423 #t))
424 (add-after 'unpack 'use-sane-help-browser
425 (lambda _
426 (substitute* "src/xsane.h"
427 (("netscape") (which "xdg-open")))
428 #t))
429 (add-after 'install 'delete-empty-/sbin
430 (lambda* (#:key outputs #:allow-other-keys)
431 (let ((out (assoc-ref outputs "out")))
432 (rmdir (string-append out "/sbin"))
433 #t))))))
434 (native-inputs
435 (list pkg-config))
436 (inputs
437 `(("gtk+" ,gtk+-2)
438 ("lcms" ,lcms)
439 ("libjpeg" ,libjpeg-turbo)
440 ("libtiff" ,libtiff)
441 ("sane-backends" ,sane-backends)
442
443 ;; To open the manual from the Help menu.
444 ("xdg-utils" ,xdg-utils)))
445 (home-page "https://gitlab.com/sane-project/frontend/xsane")
446 (synopsis "Featureful graphical interface for document and image scanners")
447 (description
448 "XSane is a graphical interface for controlling a scanner and acquiring
449 images from it. You can photocopy multi-page documents and save, fax, print,
450 or e-mail your scanned images. It is highly configurable and exposes all
451 device settings, letting you fine-tune the final result. It can also be used
452 as a GIMP plugin to acquire images directly from a scanner.
453
454 XSane talks to scanners through the @acronym{SANE, Scanner Access Now Easy}
455 back-end library, which supports almost all existing scanners.")
456 (license license:gpl2+)))