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>
8 ;;; This file is part of GNU Guix.
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.
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.
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/>.
23 (define-module (gnu packages scanner)
24 #:use-module (gnu packages)
25 #:use-module (gnu packages freedesktop)
26 #:use-module (gnu packages ghostscript)
27 #:use-module (gnu packages gtk)
28 #:use-module (gnu packages image)
29 #:use-module (gnu packages libusb)
30 #:use-module (gnu packages pkg-config)
31 #:use-module (gnu packages xml)
32 #:use-module (guix build-system gnu)
33 #:use-module (guix download)
34 #:use-module (guix git-download)
35 #:use-module ((guix licenses)
37 #:use-module (guix packages)
38 #:use-module (guix utils))
40 (define-public sane-backends-minimal
42 (name "sane-backends-minimal")
47 "https://gitlab.com/sane-project/backends/uploads/"
48 "8bf1cae2e1803aefab9e5331550e5d5d/"
49 "sane-backends-" version ".tar.gz"))
51 (base32 "1am5w92zyybs26wx4brgmky6dzpd8n34jyfrfx3qbvcqngy10fsa"))
52 (modules '((guix build utils)))
54 ;; Generated HTML files and udev rules normally embed a
55 ;; timestamp. Work around that to build things reproducibly.
57 (substitute* "tools/sane-desc.c"
58 (("asctime \\(localtime \\(¤t_time\\)\\)")
61 (build-system gnu-build-system)
63 `(("pkg-config" ,pkg-config)))
65 `(("libusb" ,libusb)))
68 (modify-phases %standard-phases
69 (add-before 'configure 'disable-backends
71 (setenv "BACKENDS" " ")
73 ;; Disable tests that may require back ends to be built.
74 (substitute* "testsuite/Makefile.in"
77 (add-after 'unpack 'disable-failing-tests
79 ;; Disable unmaintained tests that that fail with errors resembling:
81 ;; < # by sane-desc 3.5 from sane-backends 1.0.24git on Jul 31 2013
83 ;; > # by sane-desc 3.5 from sane-backends 1.0.27 on 1970-01-01#
84 ;; FAIL: sane-desc -m usermap -s ./data
87 (substitute* "testsuite/tools/Makefile.in"
88 (((string-append " " pattern " ")) " ")))
89 (list "usermap" "db" "udev" "udev\\+acl" "udev\\+hwdb" "hwdb"))
91 ;; Disable tests that try to connect to actual USB hardware & fail
92 ;; with the following error when no USB access is allowed at all:
94 ;; sanei_usb_test: sanei_usb_test.c:849: main: Assertion
95 ;; `test_init (1)' failed.
96 (substitute* "testsuite/sanei/Makefile.in"
97 (("sanei_usb_test\\$\\(EXEEXT\\) ") ""))
99 (add-after 'install 'install-udev-rules
100 (lambda* (#:key outputs #:allow-other-keys)
101 (let ((out (assoc-ref outputs "out")))
102 (mkdir-p (string-append out "/lib/udev/rules.d"))
103 (copy-file "tools/udev/libsane.rules"
108 (home-page "http://www.sane-project.org")
110 "Raster image scanner library and drivers, without scanner support")
111 (description "SANE stands for \"Scanner Access Now Easy\" and is an API
112 proving access to any raster image scanner hardware (flatbed scanner,
113 hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The
114 package contains the library, but no drivers.")
115 (license licence:gpl2+))) ; plus linking exception
117 ;; This variant links in the hpaio backend, provided by hplip, which adds
118 ;; support for HP scanners whose backends are not maintained by
119 ;; 'sane-backends'. It also builds all of those backends.
120 (define-public sane-backends
122 (inherit sane-backends-minimal)
123 (name "sane-backends")
125 `(("hplip" ,(@ (gnu packages cups) hplip-minimal))
126 ("libjpeg" ,libjpeg-turbo) ; for pixma/epsonds/other back ends
127 ("libpng" ,libpng) ; support ‘scanimage --format=png’
128 ("libxml2" ,libxml2) ; for pixma back end
129 ,@(package-inputs sane-backends-minimal)))
131 (substitute-keyword-arguments (package-arguments sane-backends-minimal)
133 `(modify-phases ,phases
134 (delete 'disable-backends)
135 (add-after 'disable-failing-tests 'disable-failing-backend-tests
137 ;; Disable test that fails on i686:
138 ;; <https://bugs.gnu.org/39449>
139 (substitute* "testsuite/backend/genesys/Makefile.in"
140 ((" genesys_unit_tests\\$\\(EXEEXT\\)") ""))
142 (add-after 'unpack 'add-backends
144 (substitute* "backend/dll.conf.in"
145 (("hp5590" all) (format #f "~a~%~a" all "hpaio")))
147 (add-after 'install 'install-hpaio
148 (lambda* (#:key inputs outputs #:allow-other-keys)
149 (define hplip (string-append (assoc-ref inputs "hplip")
151 (define out (string-append (assoc-ref outputs "out")
155 (symlink file (string-append out "/" (basename file))))
159 "Raster image scanner library and drivers, with scanner support")
160 (description "SANE stands for \"Scanner Access Now Easy\" and is an API
161 proving access to any raster image scanner hardware (flatbed scanner,
162 hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The
163 package contains the library and drivers.")))
173 (url "https://gitlab.com/sane-project/frontend/xsane.git")
175 (file-name (git-file-name name version))
177 (base32 "08zvxj7i1s88ckrsqldmsrikc3g62a6p3s3i5b5x4krcfpi3vs50"))
178 ;; Apply some important-looking fixes. There are many more unreleased
179 ;; commits upstream. A 1.0 release is planned.
180 (patches (search-patches "xsane-fix-memory-leak.patch"
181 "xsane-fix-pdf-floats.patch"
182 "xsane-fix-snprintf-buffer-length.patch"
183 "xsane-support-ipv6.patch"
184 "xsane-tighten-default-umask.patch"))
185 (modules '((guix build utils)))
188 ;; Remove ancient bundled lprng code under a non-free licence. See
189 ;; <https://trisquel.info/en/issues/10713>, which solves the problem
190 ;; by replacing it with a newer (free) copy. We let the build fall
191 ;; back to the system version instead, which appears to work fine.
192 (delete-file "lib/snprintf.c")
193 (substitute* "lib/Makefile.in"
194 (("snprintf\\.o ") ""))
196 (build-system gnu-build-system)
199 (list (string-append "xsanedocdir=" (assoc-ref %outputs "out")
200 "/share/doc/" ,name "-" ,version))
201 #:tests? #f ; no test suite
203 (modify-phases %standard-phases
204 (add-after 'unpack 'patch-invalid-dereference
205 ;; Fix the following compilation error with libpng:
206 ;; xsane-save.c: In function ‘xsane_save_png’:
207 ;; xsane-save.c:4913:21: error: dereferencing pointer to
208 ;; incomplete type ‘png_struct {aka struct png_struct_def}’
209 ;; if (setjmp(png_ptr->jmpbuf))
212 (substitute* "src/xsane-save.c"
213 (("png_ptr->jmpbuf") "png_jmpbuf(png_ptr)"))
215 (add-after 'unpack 'use-sane-help-browser
217 (substitute* "src/xsane.h"
218 (("netscape") (which "xdg-open")))
220 (add-after 'install 'delete-empty-/sbin
221 (lambda* (#:key outputs #:allow-other-keys)
222 (let ((out (assoc-ref outputs "out")))
223 (rmdir (string-append out "/sbin"))
226 `(("pkg-config" ,pkg-config)))
230 ("libjpeg" ,libjpeg-turbo)
232 ("sane-backends" ,sane-backends)
234 ;; To open the manual from the Help menu.
235 ("xdg-utils" ,xdg-utils)))
236 (home-page "https://gitlab.com/sane-project/frontend/xsane")
237 (synopsis "Featureful graphical interface for document and image scanners")
239 "XSane is a graphical interface for controlling a scanner and acquiring
240 images from it. You can photocopy multi-page documents and save, fax, print,
241 or e-mail your scanned images. It is highly configurable and exposes all
242 device settings, letting you fine-tune the final result. It can also be used
243 as a GIMP plugin to acquire images directly from a scanner.
245 XSane talks to scanners through the @acronym{SANE, Scanner Access Now Easy}
246 back-end library, which supports almost all existing scanners.")
247 (license licence:gpl2+)))