gnu: nnn: Don't use NAME in source URI.
[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 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 (guix packages)
25 #:use-module (guix download)
26 #:use-module (guix utils)
27 #:use-module (guix build-system gnu)
28 #:use-module (gnu packages pkg-config)
29 #:use-module (gnu packages libusb)
30 #:use-module ((guix licenses)
31 #:prefix licence:))
32
33 (define-public sane-backends-minimal
34 (package
35 (name "sane-backends-minimal")
36 (version "1.0.27")
37 (source (origin
38 (method url-fetch)
39 (uri (string-append
40 "https://alioth.debian.org/frs/download.php/latestfile/176/"
41 "sane-backends-" version ".tar.gz"))
42 (sha256
43 (base32
44 "1j9nbqspaj0rlgalafb5z6r606k0i22kz0rcpd744p176yzlfdr9"))
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.
49 '(begin
50 (substitute* "tools/sane-desc.c"
51 (("asctime \\(localtime \\(&current_time\\)\\)")
52 "\"1970-01-01\""))
53 #t))))
54 (build-system gnu-build-system)
55 (native-inputs
56 `(("pkg-config" ,pkg-config)))
57 (inputs
58 `(("libusb-compat" ,libusb-compat)))
59 (arguments
60 `(#:phases
61 (modify-phases %standard-phases
62 (add-before 'configure 'disable-backends
63 (lambda _
64 (setenv "BACKENDS" " ")
65 #t))
66 ;; Disable unmaintained tests that that fail with errors resembling:
67 ;;
68 ;; < # by sane-desc 3.5 from sane-backends 1.0.24git on Jul 31 2013
69 ;; ---
70 ;; > # by sane-desc 3.5 from sane-backends 1.0.27 on 1970-01-01#
71 ;; FAIL: sane-desc -m usermap -s ./data
72 (add-before 'configure 'disable-failing-tests
73 (lambda _
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"))
79 #t))
80 (add-after 'install 'install-udev-rules
81 (lambda* (#:key outputs #:allow-other-keys)
82 (let ((out (assoc-ref outputs "out")))
83 (mkdir-p (string-append out "/lib/udev/rules.d"))
84 (copy-file "tools/udev/libsane.rules"
85 (string-append out
86 "/lib/udev/rules.d/"
87 "60-libsane.rules"))
88 #t))))))
89 (home-page "http://www.sane-project.org")
90 (synopsis
91 "Raster image scanner library and drivers, without scanner support")
92 (description "SANE stands for \"Scanner Access Now Easy\" and is an API
93 proving access to any raster image scanner hardware (flatbed scanner,
94 hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The
95 package contains the library, but no drivers.")
96 (license licence:gpl2+))) ; plus linking exception
97
98 ;; This variant links in the hpaio backend, provided by hplip, which adds
99 ;; support for HP scanners whose backends are not maintained by
100 ;; 'sane-backends'. It also builds all of those backends.
101 (define-public sane-backends
102 (package
103 (inherit sane-backends-minimal)
104 (name "sane-backends")
105 (inputs
106 `(("hplip" ,(@ (gnu packages cups) hplip-minimal))
107 ,@(package-inputs sane-backends-minimal)))
108 (arguments
109 (substitute-keyword-arguments (package-arguments sane-backends-minimal)
110 ((#:phases phases)
111 `(modify-phases ,phases
112 (delete 'disable-backends)
113 (add-after 'unpack 'add-backends
114 (lambda _
115 (substitute* "backend/dll.conf.in"
116 (("hp5590" all) (format #f "~a~%~a" all "hpaio")))
117 #t))
118 (add-after 'install 'install-hpaio
119 (lambda* (#:key inputs outputs #:allow-other-keys)
120 (define hplip (string-append (assoc-ref inputs "hplip")
121 "/lib/sane"))
122 (define out (string-append (assoc-ref outputs "out")
123 "/lib/sane"))
124 (for-each
125 (lambda (file)
126 (symlink file (string-append out "/" (basename file))))
127 (find-files hplip))
128 #t))))))
129 (synopsis
130 "Raster image scanner library and drivers, with scanner support")
131 (description "SANE stands for \"Scanner Access Now Easy\" and is an API
132 proving access to any raster image scanner hardware (flatbed scanner,
133 hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The
134 package contains the library and drivers.")))