gnu: Add btanks.
[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>
abe6e670 5;;; Copyright © 2017, 2019 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)
24 #:use-module (guix packages)
25 #:use-module (guix download)
4c928743 26 #:use-module (guix utils)
45c151d9 27 #:use-module (guix build-system gnu)
3b71b36c
AW
28 #:use-module (gnu packages pkg-config)
29 #:use-module (gnu packages libusb)
45c151d9
JD
30 #:use-module ((guix licenses)
31 #:prefix licence:))
32
32aa37a2 33(define-public sane-backends-minimal
45c151d9 34 (package
32aa37a2 35 (name "sane-backends-minimal")
4febd4b0 36 (version "1.0.27")
45c151d9
JD
37 (source (origin
38 (method url-fetch)
d976eccd 39 (uri (string-append
4febd4b0 40 "https://alioth.debian.org/frs/download.php/latestfile/176/"
32aa37a2 41 "sane-backends-" version ".tar.gz"))
45c151d9
JD
42 (sha256
43 (base32
4febd4b0 44 "1j9nbqspaj0rlgalafb5z6r606k0i22kz0rcpd744p176yzlfdr9"))
a32d0c83
LC
45 (modules '((guix build utils)))
46 (snippet
47 ;; Generated HTML files and udev rules normally embed a
48 ;; timestamp. Work around that to build things reproducibly.
6cbee49d
MW
49 '(begin
50 (substitute* "tools/sane-desc.c"
51 (("asctime \\(localtime \\(&current_time\\)\\)")
52 "\"1970-01-01\""))
53 #t))))
45c151d9 54 (build-system gnu-build-system)
3b71b36c
AW
55 (native-inputs
56 `(("pkg-config" ,pkg-config)))
57 (inputs
abe6e670 58 `(("libusb" ,libusb)))
45c151d9 59 (arguments
4ed390a0 60 `(#:phases
3b71b36c 61 (modify-phases %standard-phases
33a14e29
AP
62 (add-before 'configure 'disable-backends
63 (lambda _
64 (setenv "BACKENDS" " ")
65 #t))
abe6e670 66 (add-after 'unpack 'disable-failing-tests
4ed390a0 67 (lambda _
abe6e670
TGR
68 ;; Disable unmaintained tests that that fail with errors resembling:
69 ;;
70 ;; < # by sane-desc 3.5 from sane-backends 1.0.24git on Jul 31 2013
71 ;; ---
72 ;; > # by sane-desc 3.5 from sane-backends 1.0.27 on 1970-01-01#
73 ;; FAIL: sane-desc -m usermap -s ./data
4ed390a0
TGR
74 (for-each
75 (lambda (pattern)
76 (substitute* "testsuite/tools/Makefile.in"
77 (((string-append " " pattern " ")) " ")))
78 (list "usermap" "db" "udev" "udev\\+acl" "udev\\+hwdb" "hwdb"))
abe6e670
TGR
79
80 ;; Disable tests that try to connect to actual USB hardware & fail
81 ;; with the following error when no USB access is allowed at all:
82 ;;
83 ;; sanei_usb_test: sanei_usb_test.c:849: main: Assertion
84 ;; `test_init (1)' failed.
85 (substitute* "testsuite/sanei/Makefile.in"
86 (("sanei_usb_test\\$\\(EXEEXT\\) ") ""))
4ed390a0
TGR
87 #t))
88 (add-after 'install 'install-udev-rules
89 (lambda* (#:key outputs #:allow-other-keys)
90 (let ((out (assoc-ref outputs "out")))
91 (mkdir-p (string-append out "/lib/udev/rules.d"))
92 (copy-file "tools/udev/libsane.rules"
93 (string-append out
94 "/lib/udev/rules.d/"
37294772
MW
95 "60-libsane.rules"))
96 #t))))))
45c151d9 97 (home-page "http://www.sane-project.org")
32aa37a2
AP
98 (synopsis
99 "Raster image scanner library and drivers, without scanner support")
45c151d9
JD
100 (description "SANE stands for \"Scanner Access Now Easy\" and is an API
101proving access to any raster image scanner hardware (flatbed scanner,
102hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The
32aa37a2 103package contains the library, but no drivers.")
45c151d9 104 (license licence:gpl2+))) ; plus linking exception
4c928743
AP
105
106;; This variant links in the hpaio backend, provided by hplip, which adds
107;; support for HP scanners whose backends are not maintained by
108;; 'sane-backends'. It also builds all of those backends.
109(define-public sane-backends
110 (package
111 (inherit sane-backends-minimal)
112 (name "sane-backends")
113 (inputs
8e189596 114 `(("hplip" ,(@ (gnu packages cups) hplip-minimal))
4c928743
AP
115 ,@(package-inputs sane-backends-minimal)))
116 (arguments
117 (substitute-keyword-arguments (package-arguments sane-backends-minimal)
118 ((#:phases phases)
119 `(modify-phases ,phases
120 (delete 'disable-backends)
121 (add-after 'unpack 'add-backends
122 (lambda _
123 (substitute* "backend/dll.conf.in"
124 (("hp5590" all) (format #f "~a~%~a" all "hpaio")))
125 #t))
126 (add-after 'install 'install-hpaio
127 (lambda* (#:key inputs outputs #:allow-other-keys)
128 (define hplip (string-append (assoc-ref inputs "hplip")
129 "/lib/sane"))
130 (define out (string-append (assoc-ref outputs "out")
131 "/lib/sane"))
132 (for-each
133 (lambda (file)
134 (symlink file (string-append out "/" (basename file))))
135 (find-files hplip))
136 #t))))))
137 (synopsis
138 "Raster image scanner library and drivers, with scanner support")
139 (description "SANE stands for \"Scanner Access Now Easy\" and is an API
140proving access to any raster image scanner hardware (flatbed scanner,
141hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The
142package contains the library and drivers.")))