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>
9 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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)
50 #:use-module (guix packages)
51 #:use-module (guix utils))
53 (define-public sane-airscan
61 (url "https://github.com/alexpevzner/sane-airscan")
63 (file-name (git-file-name name version))
65 (base32 "1syxsih1kdnz9slsg5a92bqnllagm4cybqk4n2y6mbkqn6h0zlnv"))))
66 (build-system gnu-build-system)
69 #~(list (string-append "prefix=" #$output)
70 (string-append "libdir=$(prefix)/lib"))
72 #~(modify-phases %standard-phases
73 (delete 'configure )))) ; no configure script
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'').
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}.
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.
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
103 (license (list license:gpl2+ ; the combined work
104 license:expat)))) ; http_parser.[ch]
106 (define-public sane-backends-minimal
108 (name "sane-backends-minimal")
113 (url "https://gitlab.com/sane-project/backends")
115 (file-name (git-file-name name version))
117 (base32 "13jlqdp7n7z2n78v6idl3ri5idk7ddk9j8wrmh73lba8l9y8xnsi"))
118 (modules '((guix build utils)))
120 ;; Generated HTML files and udev rules normally embed a
121 ;; timestamp. Work around that to build things reproducibly.
123 (substitute* "tools/sane-desc.c"
124 (("asctime \\(localtime \\(¤t_time\\)\\)")
125 "\"1970-01-01\""))))))
126 (build-system gnu-build-system)
128 `(("autoconf" ,autoconf)
129 ("autoconf-archive" ,autoconf-archive)
130 ("automake" ,automake)
131 ("gettext" ,gettext-minimal)
133 ("pkg-config" ,pkg-config)
134 ;; For scripts/pixma_gen_options.py.
135 ("python" ,python-wrapper)))
140 (modify-phases %standard-phases
141 (add-before 'bootstrap 'zap-unnecessary-git-dependency
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
150 (setenv "BACKENDS" " ")
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
157 ;; Disable unmaintained tests that that fail with errors resembling:
159 ;; < # by sane-desc 3.5 from sane-backends 1.0.24git on Jul 31 2013
161 ;; > # by sane-desc 3.5 from sane-backends 1.0.27 on 1970-01-01#
162 ;; FAIL: sane-desc -m usermap -s ./data
165 (substitute* "testsuite/tools/Makefile.in"
166 (((string-append " " pattern " ")) " ")))
167 (list "usermap" "db" "udev" "udev\\+acl" "udev\\+hwdb" "hwdb"))
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:
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'."
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"
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")
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
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")
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)))
222 (substitute-keyword-arguments (package-arguments sane-backends-minimal)
224 `(modify-phases ,phases
225 (delete 'disable-backends)
226 (add-after 'disable-failing-tests 'disable-failing-backend-tests
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\\)") ""))
233 (add-after 'unpack 'add-backends
235 (substitute* "backend/dll.conf.in"
236 (("hp5590" all) (format #f "~a~%~a" all "hpaio")))
238 (add-after 'install 'install-hpaio
239 (lambda* (#:key inputs outputs #:allow-other-keys)
240 (define hplip (string-append (assoc-ref inputs "hplip")
242 (define out (string-append (assoc-ref outputs "out")
246 (symlink file (string-append out "/" (basename file))))
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.")))
256 (define-public utsushi
257 (let ((commit "839d06a5a80b353cb604eb9f7d352a1648ab1fdf"))
260 (version (git-version "0.65.0" "1" commit))
264 (url "https://gitlab.com/utsushi/utsushi")
266 (file-name (git-file-name name version))
269 "0i6ipqy61abbsmqqqy5sii0vlib146snvp975sgjmv4nzy9mwf24"))))
270 (build-system gnu-build-system)
274 #~(list (string-append "--with-boost-libdir="
275 #$(this-package-input "boost") "/lib")
276 "CXXFLAGS=-Wno-error")
278 #~(modify-phases %standard-phases
279 (add-before 'bootstrap 'zap-unnecessary-git-dependency
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")))))))
291 sane-backends-minimal
297 (native-inputs (list util-linux
305 (home-page "https://gitlab.com/utsushi/utsushi")
306 (synopsis "Image scanning software for EPSON devices")
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}
312 (license license:gpl3+))))
314 (define-public scanbd
321 (uri (string-append "mirror://sourceforge/scanbd/releases/"
322 "scanbd-" version ".tgz"))
324 (base32 "0pvy4qirfjdfm8aj6x5rkbgl7hk3jfa2s21qkk8ic5dqfjjab75n"))))
325 (build-system gnu-build-system)
327 (list #:configure-flags
328 #~(list "--disable-debug"
330 "CFLAGS=-Wno-error") ; warnings should never be fatal
332 #~(modify-phases %standard-phases
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
340 (string-append "scanbdconfdir=" conf)
341 (string-append "scannerconfdir=" conf "/scanner.d")
343 (add-after 'install 'install-extra-documentation
344 ;; The README provides more detailed set-up instructions than
347 (let ((doc (string-append #$output "/share/doc/"
348 #$name "-" #$version)))
349 (install-file "doc/README.txt" doc)))))))
354 ("libconfuse" ,libconfuse)
355 ("sane-backends" ,sane-backends)
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.
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.
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+)))
382 (url "https://gitlab.com/sane-project/frontend/xsane.git")
384 (file-name (git-file-name name version))
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)))
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 ") ""))
405 (build-system gnu-build-system)
408 (list (string-append "xsanedocdir=" (assoc-ref %outputs "out")
409 "/share/doc/" ,name "-" ,version))
410 #:tests? #f ; no test suite
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))
421 (substitute* "src/xsane-save.c"
422 (("png_ptr->jmpbuf") "png_jmpbuf(png_ptr)"))
424 (add-after 'unpack 'use-sane-help-browser
426 (substitute* "src/xsane.h"
427 (("netscape") (which "xdg-open")))
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"))
439 ("libjpeg" ,libjpeg-turbo)
441 ("sane-backends" ,sane-backends)
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")
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.
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+)))