gnu: libdvdcss: Update to 1.4.3.
[jackhill/guix/guix.git] / gnu / packages / scanner.scm
CommitLineData
45c151d9 1;;; GNU Guix --- Functional package management for GNU
3b71b36c
AW
2;;; Copyright © 2014 John Darrington <jmd@gnu.org>
3;;; Copyright © 2015 Andy Wingo <wingo@igalia.com>
4c928743 4;;; Copyright © 2016 Andy Patterson <ajpatter@uwaterloo.ca>
ad149383 5;;; Copyright © 2017, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
8e189596 6;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
45c151d9
JD
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)
a608666d 24 #:use-module (gnu packages)
902d76c8 25 #:use-module (gnu packages autotools)
a608666d 26 #:use-module (gnu packages freedesktop)
902d76c8 27 #:use-module (gnu packages gettext)
a608666d
TGR
28 #:use-module (gnu packages ghostscript)
29 #:use-module (gnu packages gtk)
6845ab52 30 #:use-module (gnu packages image)
3b71b36c 31 #:use-module (gnu packages libusb)
21b9c6fa 32 #:use-module (gnu packages pkg-config)
902d76c8 33 #:use-module (gnu packages python)
509906c2 34 #:use-module (gnu packages xml)
21b9c6fa
TGR
35 #:use-module (guix build-system gnu)
36 #:use-module (guix download)
a608666d 37 #:use-module (guix git-download)
45c151d9 38 #:use-module ((guix licenses)
011ec41c 39 #:prefix license:)
21b9c6fa
TGR
40 #:use-module (guix packages)
41 #:use-module (guix utils))
45c151d9 42
32aa37a2 43(define-public sane-backends-minimal
45c151d9 44 (package
32aa37a2 45 (name "sane-backends-minimal")
78ce446b 46 (version "1.0.32")
45c151d9 47 (source (origin
902d76c8
TGR
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))
45c151d9 53 (sha256
78ce446b 54 (base32 "13jlqdp7n7z2n78v6idl3ri5idk7ddk9j8wrmh73lba8l9y8xnsi"))
a32d0c83
LC
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.
6cbee49d
MW
59 '(begin
60 (substitute* "tools/sane-desc.c"
61 (("asctime \\(localtime \\(&current_time\\)\\)")
cf9047b2 62 "\"1970-01-01\""))))))
45c151d9 63 (build-system gnu-build-system)
3b71b36c 64 (native-inputs
902d76c8
TGR
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)))
3b71b36c 73 (inputs
abe6e670 74 `(("libusb" ,libusb)))
45c151d9 75 (arguments
4ed390a0 76 `(#:phases
3b71b36c 77 (modify-phases %standard-phases
902d76c8
TGR
78 (add-before 'bootstrap 'zap-unnecessary-git-dependency
79 (lambda _
78ce446b
TGR
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)))))
33a14e29
AP
85 (add-before 'configure 'disable-backends
86 (lambda _
87 (setenv "BACKENDS" " ")
7018f926
TGR
88
89 ;; Disable tests that may require back ends to be built.
90 (substitute* "testsuite/Makefile.in"
cf9047b2 91 ((" backend ") " "))))
902d76c8 92 (add-before 'configure 'disable-failing-tests
4ed390a0 93 (lambda _
abe6e670
TGR
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
4ed390a0
TGR
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"))
abe6e670
TGR
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"
cf9047b2 112 (("sanei_usb_test\\$\\(EXEEXT\\) ") ""))))
902d76c8
TGR
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")))
4ed390a0
TGR
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/"
cf9047b2 125 "60-libsane.rules")))))
902d76c8
TGR
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")))))))))
45c151d9 137 (home-page "http://www.sane-project.org")
32aa37a2
AP
138 (synopsis
139 "Raster image scanner library and drivers, without scanner support")
45c151d9
JD
140 (description "SANE stands for \"Scanner Access Now Easy\" and is an API
141proving access to any raster image scanner hardware (flatbed scanner,
142hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The
32aa37a2 143package contains the library, but no drivers.")
011ec41c 144 (license license:gpl2+))) ; plus linking exception
4c928743 145
902d76c8
TGR
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.
4c928743 149(define-public sane-backends
1a265842 150 (package/inherit sane-backends-minimal
4c928743
AP
151 (name "sane-backends")
152 (inputs
8e189596 153 `(("hplip" ,(@ (gnu packages cups) hplip-minimal))
509906c2 154 ("libjpeg" ,libjpeg-turbo) ; for pixma/epsonds/other back ends
10bd2889 155 ("libpng" ,libpng) ; support ‘scanimage --format=png’
509906c2 156 ("libxml2" ,libxml2) ; for pixma back end
4c928743
AP
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)
5f6ce90a
LP
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))
4c928743
AP
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
189proving access to any raster image scanner hardware (flatbed scanner,
190hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The
191package contains the library and drivers.")))
a608666d
TGR
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"
99b10602 210 "xsane-fix-snprintf-buffer-length.patch"
a608666d
TGR
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))
011ec41c 229 #:tests? #f ; no test suite
a608666d
TGR
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)
4bd428a7 258 ("libjpeg" ,libjpeg-turbo)
a608666d
TGR
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
268images from it. You can photocopy multi-page documents and save, fax, print,
269or e-mail your scanned images. It is highly configurable and exposes all
270device settings, letting you fine-tune the final result. It can also be used
271as a GIMP plugin to acquire images directly from a scanner.
272
273XSane talks to scanners through the @acronym{SANE, Scanner Access Now Easy}
274back-end library, which supports almost all existing scanners.")
011ec41c 275 (license license:gpl2+)))