gnu: cvs-fast-export: Update to 1.56.
[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 Tobias Geerinckx-Rice <me@tobias.gr>
6 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
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 scanner)
24 #:use-module (gnu packages)
25 #:use-module (gnu packages autotools)
26 #:use-module (gnu packages freedesktop)
27 #:use-module (gnu packages gettext)
28 #:use-module (gnu packages ghostscript)
29 #:use-module (gnu packages gtk)
30 #:use-module (gnu packages image)
31 #:use-module (gnu packages libusb)
32 #:use-module (gnu packages pkg-config)
33 #:use-module (gnu packages python)
34 #:use-module (gnu packages xml)
35 #:use-module (guix build-system gnu)
36 #:use-module (guix download)
37 #:use-module (guix git-download)
38 #:use-module ((guix licenses)
39 #:prefix license:)
40 #:use-module (guix packages)
41 #:use-module (guix utils))
42
43 (define-public sane-backends-minimal
44 (package
45 (name "sane-backends-minimal")
46 (version "1.0.32")
47 (source (origin
48 (method git-fetch)
49 (uri (git-reference
50 (url "https://gitlab.com/sane-project/backends")
51 (commit version)))
52 (file-name (git-file-name name version))
53 (sha256
54 (base32 "13jlqdp7n7z2n78v6idl3ri5idk7ddk9j8wrmh73lba8l9y8xnsi"))
55 (modules '((guix build utils)))
56 (snippet
57 ;; Generated HTML files and udev rules normally embed a
58 ;; timestamp. Work around that to build things reproducibly.
59 '(begin
60 (substitute* "tools/sane-desc.c"
61 (("asctime \\(localtime \\(&current_time\\)\\)")
62 "\"1970-01-01\""))))))
63 (build-system gnu-build-system)
64 (native-inputs
65 `(("autoconf" ,autoconf)
66 ("autoconf-archive" ,autoconf-archive)
67 ("automake" ,automake)
68 ("gettext" ,gettext-minimal)
69 ("libtool" ,libtool)
70 ("pkg-config" ,pkg-config)
71 ;; For scripts/pixma_gen_options.py.
72 ("python" ,python-wrapper)))
73 (inputs
74 `(("libusb" ,libusb)))
75 (arguments
76 `(#:phases
77 (modify-phases %standard-phases
78 (add-before 'bootstrap 'zap-unnecessary-git-dependency
79 (lambda _
80 ;; This runs before default patch-shebangs phase.
81 (substitute* "tools/git-version-gen"
82 (("/bin/sh") (which "sh")))
83 (with-output-to-file ".tarball-version"
84 (lambda _ (format #t ,version)))))
85 (add-before 'configure 'disable-backends
86 (lambda _
87 (setenv "BACKENDS" " ")
88
89 ;; Disable tests that may require back ends to be built.
90 (substitute* "testsuite/Makefile.in"
91 ((" backend ") " "))))
92 (add-before 'configure 'disable-failing-tests
93 (lambda _
94 ;; Disable unmaintained tests that that fail with errors resembling:
95 ;;
96 ;; < # by sane-desc 3.5 from sane-backends 1.0.24git on Jul 31 2013
97 ;; ---
98 ;; > # by sane-desc 3.5 from sane-backends 1.0.27 on 1970-01-01#
99 ;; FAIL: sane-desc -m usermap -s ./data
100 (for-each
101 (lambda (pattern)
102 (substitute* "testsuite/tools/Makefile.in"
103 (((string-append " " pattern " ")) " ")))
104 (list "usermap" "db" "udev" "udev\\+acl" "udev\\+hwdb" "hwdb"))
105
106 ;; Disable tests that try to connect to actual USB hardware & fail
107 ;; with the following error when no USB access is allowed at all:
108 ;;
109 ;; sanei_usb_test: sanei_usb_test.c:849: main: Assertion
110 ;; `test_init (1)' failed.
111 (substitute* "testsuite/sanei/Makefile.in"
112 (("sanei_usb_test\\$\\(EXEEXT\\) ") ""))))
113 (add-before 'build 'build-pixma_sane_options.c
114 ;; "No rule to make target '../backend/pixma/pixma_sane_options.c',
115 ;; needed by 'sane-backends.pot-update'."
116 (lambda _
117 (invoke "make" "-C" "backend" "pixma/pixma_sane_options.c")))
118 (add-after 'install 'install-udev-rules
119 (lambda* (#:key outputs #:allow-other-keys)
120 (let ((out (assoc-ref outputs "out")))
121 (mkdir-p (string-append out "/lib/udev/rules.d"))
122 (copy-file "tools/udev/libsane.rules"
123 (string-append out
124 "/lib/udev/rules.d/"
125 "60-libsane.rules")))))
126 (add-after 'install 'make-reproducible
127 ;; XXX Work around an old bug <https://issues.guix.gnu.org/26247>.
128 ;; Then work around "Throw to key `decoding-error' ..." by using sed.
129 (lambda* (#:key outputs #:allow-other-keys)
130 (let* ((out (assoc-ref outputs "out"))
131 (locale (string-append out "/share/locale")))
132 (with-directory-excursion locale
133 (for-each (lambda (file)
134 (invoke "sed" "-i" "/^PO-Revision-Date:/d" file))
135 (list "en@boldquot/LC_MESSAGES/sane-backends.mo"
136 "en@quot/LC_MESSAGES/sane-backends.mo")))))))))
137 (home-page "http://www.sane-project.org")
138 (synopsis
139 "Raster image scanner library and drivers, without scanner support")
140 (description "SANE stands for \"Scanner Access Now Easy\" and is an API
141 proving access to any raster image scanner hardware (flatbed scanner,
142 hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The
143 package contains the library, but no drivers.")
144 (license license:gpl2+))) ; plus linking exception
145
146 ;; This variant links in the hpaio backend provided by hplip, which adds
147 ;; support for HP scanners whose backends are not maintained by the SANE
148 ;; project, and builds all of those backends.
149 (define-public sane-backends
150 (package/inherit sane-backends-minimal
151 (name "sane-backends")
152 (inputs
153 `(("hplip" ,(@ (gnu packages cups) hplip-minimal))
154 ("libjpeg" ,libjpeg-turbo) ; for pixma/epsonds/other back ends
155 ("libpng" ,libpng) ; support ‘scanimage --format=png’
156 ("libxml2" ,libxml2) ; for pixma back end
157 ,@(package-inputs sane-backends-minimal)))
158 (arguments
159 (substitute-keyword-arguments (package-arguments sane-backends-minimal)
160 ((#:phases phases)
161 `(modify-phases ,phases
162 (delete 'disable-backends)
163 (add-after 'disable-failing-tests 'disable-failing-backend-tests
164 (lambda _
165 ;; Disable test that fails on i686:
166 ;; <https://bugs.gnu.org/39449>
167 (substitute* "testsuite/backend/genesys/Makefile.in"
168 ((" genesys_unit_tests\\$\\(EXEEXT\\)") ""))
169 #t))
170 (add-after 'unpack 'add-backends
171 (lambda _
172 (substitute* "backend/dll.conf.in"
173 (("hp5590" all) (format #f "~a~%~a" all "hpaio")))
174 #t))
175 (add-after 'install 'install-hpaio
176 (lambda* (#:key inputs outputs #:allow-other-keys)
177 (define hplip (string-append (assoc-ref inputs "hplip")
178 "/lib/sane"))
179 (define out (string-append (assoc-ref outputs "out")
180 "/lib/sane"))
181 (for-each
182 (lambda (file)
183 (symlink file (string-append out "/" (basename file))))
184 (find-files hplip))
185 #t))))))
186 (synopsis
187 "Raster image scanner library and drivers, with scanner support")
188 (description "SANE stands for \"Scanner Access Now Easy\" and is an API
189 proving access to any raster image scanner hardware (flatbed scanner,
190 hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The
191 package contains the library and drivers.")))
192
193 (define-public xsane
194 (package
195 (name "xsane")
196 (version "0.999")
197 (source
198 (origin
199 (method git-fetch)
200 (uri (git-reference
201 (url "https://gitlab.com/sane-project/frontend/xsane.git")
202 (commit version)))
203 (file-name (git-file-name name version))
204 (sha256
205 (base32 "08zvxj7i1s88ckrsqldmsrikc3g62a6p3s3i5b5x4krcfpi3vs50"))
206 ;; Apply some important-looking fixes. There are many more unreleased
207 ;; commits upstream. A 1.0 release is planned.
208 (patches (search-patches "xsane-fix-memory-leak.patch"
209 "xsane-fix-pdf-floats.patch"
210 "xsane-fix-snprintf-buffer-length.patch"
211 "xsane-support-ipv6.patch"
212 "xsane-tighten-default-umask.patch"))
213 (modules '((guix build utils)))
214 (snippet
215 '(begin
216 ;; Remove ancient bundled lprng code under a non-free licence. See
217 ;; <https://trisquel.info/en/issues/10713>, which solves the problem
218 ;; by replacing it with a newer (free) copy. We let the build fall
219 ;; back to the system version instead, which appears to work fine.
220 (delete-file "lib/snprintf.c")
221 (substitute* "lib/Makefile.in"
222 (("snprintf\\.o ") ""))
223 #t))))
224 (build-system gnu-build-system)
225 (arguments
226 `(#:make-flags
227 (list (string-append "xsanedocdir=" (assoc-ref %outputs "out")
228 "/share/doc/" ,name "-" ,version))
229 #:tests? #f ; no test suite
230 #:phases
231 (modify-phases %standard-phases
232 (add-after 'unpack 'patch-invalid-dereference
233 ;; Fix the following compilation error with libpng:
234 ;; xsane-save.c: In function ‘xsane_save_png’:
235 ;; xsane-save.c:4913:21: error: dereferencing pointer to
236 ;; incomplete type ‘png_struct {aka struct png_struct_def}’
237 ;; if (setjmp(png_ptr->jmpbuf))
238 ;; ^
239 (lambda _
240 (substitute* "src/xsane-save.c"
241 (("png_ptr->jmpbuf") "png_jmpbuf(png_ptr)"))
242 #t))
243 (add-after 'unpack 'use-sane-help-browser
244 (lambda _
245 (substitute* "src/xsane.h"
246 (("netscape") (which "xdg-open")))
247 #t))
248 (add-after 'install 'delete-empty-/sbin
249 (lambda* (#:key outputs #:allow-other-keys)
250 (let ((out (assoc-ref outputs "out")))
251 (rmdir (string-append out "/sbin"))
252 #t))))))
253 (native-inputs
254 `(("pkg-config" ,pkg-config)))
255 (inputs
256 `(("gtk+" ,gtk+-2)
257 ("lcms" ,lcms)
258 ("libjpeg" ,libjpeg-turbo)
259 ("libtiff" ,libtiff)
260 ("sane-backends" ,sane-backends)
261
262 ;; To open the manual from the Help menu.
263 ("xdg-utils" ,xdg-utils)))
264 (home-page "https://gitlab.com/sane-project/frontend/xsane")
265 (synopsis "Featureful graphical interface for document and image scanners")
266 (description
267 "XSane is a graphical interface for controlling a scanner and acquiring
268 images from it. You can photocopy multi-page documents and save, fax, print,
269 or e-mail your scanned images. It is highly configurable and exposes all
270 device settings, letting you fine-tune the final result. It can also be used
271 as a GIMP plugin to acquire images directly from a scanner.
272
273 XSane talks to scanners through the @acronym{SANE, Scanner Access Now Easy}
274 back-end library, which supports almost all existing scanners.")
275 (license license:gpl2+)))