scanner.scm 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  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, 2022 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. (define-module (gnu packages scanner)
  23. #:use-module (gnu packages)
  24. #:use-module (gnu packages autotools)
  25. #:use-module (gnu packages avahi)
  26. #:use-module (gnu packages compression)
  27. #:use-module (gnu packages freedesktop)
  28. #:use-module (gnu packages gettext)
  29. #:use-module (gnu packages ghostscript)
  30. #:use-module (gnu packages glib)
  31. #:use-module (gnu packages gtk)
  32. #:use-module (gnu packages image)
  33. #:use-module (gnu packages libusb)
  34. #:use-module (gnu packages linux)
  35. #:use-module (gnu packages pkg-config)
  36. #:use-module (gnu packages python)
  37. #:use-module (gnu packages textutils)
  38. #:use-module (gnu packages tls)
  39. #:use-module (gnu packages xml)
  40. #:use-module (guix build-system gnu)
  41. #:use-module (guix download)
  42. #:use-module (guix git-download)
  43. #:use-module (guix gexp)
  44. #:use-module ((guix licenses)
  45. #:prefix license:)
  46. #:use-module (guix packages)
  47. #:use-module (guix utils))
  48. (define-public sane-airscan
  49. (package
  50. (name "sane-airscan")
  51. (version "0.99.27")
  52. (source
  53. (origin
  54. (method git-fetch)
  55. (uri (git-reference
  56. (url "https://github.com/alexpevzner/sane-airscan")
  57. (commit version)))
  58. (file-name (git-file-name name version))
  59. (sha256
  60. (base32 "1syxsih1kdnz9slsg5a92bqnllagm4cybqk4n2y6mbkqn6h0zlnv"))))
  61. (build-system gnu-build-system)
  62. (arguments
  63. (list #:make-flags
  64. #~(list (string-append "prefix=" #$output)
  65. (string-append "libdir=$(prefix)/lib"))
  66. #:phases
  67. #~(modify-phases %standard-phases
  68. (delete 'configure )))) ; no configure script
  69. (native-inputs
  70. (list pkg-config))
  71. (inputs
  72. (list avahi
  73. gnutls
  74. libjpeg-turbo
  75. libpng
  76. libxml2
  77. sane-backends))
  78. (home-page "https://github.com/alexpevzner/sane-airscan")
  79. (synopsis "SANE backend for eSCL (AirScan) and WSD document scanners")
  80. (description ; no @acronym{eSCL} because the meaning isn't officially known
  81. "This SANE backend lets you scan documents and images from scanners and
  82. multi-function printers that speak eSCL (marketed as ``AirScan'') or
  83. @acronym{WSD, Web Services for Devices} (or ``WS-Scan'').
  84. Both are vendor-neutral protocols that allow ``driverless'' scanning over IPv4
  85. and IPv6 networks without the vendor-specific drivers that make up most of the
  86. sane-backends collection. This is similar to how most contemporary printers
  87. speak the universal @acronym{IPP, Internet Printing Protocol}.
  88. Only scanners that support eSCL will also work over USB. This requires a
  89. suitable IPP-over-USB daemon like ipp-usb to be installed and configured.
  90. Any eSCL or WSD-capable scanner should just work. sane-airscan automatically
  91. discovers and configures devices, including which protocol to use. It was
  92. successfully tested with many devices from Brother, Canon, Dell, Kyocera,
  93. Lexmark, Epson, HP, OKI, Panasonic, Pantum, Ricoh, Samsung, and Xerox, with both
  94. WSD and eSCL.")
  95. (license (list license:gpl2+ ; the combined work
  96. license:expat)))) ; http_parser.[ch]
  97. (define-public sane-backends-minimal
  98. (package
  99. (name "sane-backends-minimal")
  100. (version "1.0.32")
  101. (source (origin
  102. (method git-fetch)
  103. (uri (git-reference
  104. (url "https://gitlab.com/sane-project/backends")
  105. (commit version)))
  106. (file-name (git-file-name name version))
  107. (sha256
  108. (base32 "13jlqdp7n7z2n78v6idl3ri5idk7ddk9j8wrmh73lba8l9y8xnsi"))
  109. (modules '((guix build utils)))
  110. (snippet
  111. ;; Generated HTML files and udev rules normally embed a
  112. ;; timestamp. Work around that to build things reproducibly.
  113. '(begin
  114. (substitute* "tools/sane-desc.c"
  115. (("asctime \\(localtime \\(&current_time\\)\\)")
  116. "\"1970-01-01\""))))))
  117. (build-system gnu-build-system)
  118. (native-inputs
  119. `(("autoconf" ,autoconf)
  120. ("autoconf-archive" ,autoconf-archive)
  121. ("automake" ,automake)
  122. ("gettext" ,gettext-minimal)
  123. ("libtool" ,libtool)
  124. ("pkg-config" ,pkg-config)
  125. ;; For scripts/pixma_gen_options.py.
  126. ("python" ,python-wrapper)))
  127. (inputs
  128. (list libusb))
  129. (arguments
  130. `(#:phases
  131. (modify-phases %standard-phases
  132. (add-before 'bootstrap 'zap-unnecessary-git-dependency
  133. (lambda _
  134. ;; This runs before default patch-shebangs phase.
  135. (substitute* "tools/git-version-gen"
  136. (("/bin/sh") (which "sh")))
  137. (with-output-to-file ".tarball-version"
  138. (lambda _ (format #t ,version)))))
  139. (add-before 'configure 'disable-backends
  140. (lambda _
  141. (setenv "BACKENDS" " ")
  142. ;; Disable tests that may require back ends to be built.
  143. (substitute* "testsuite/Makefile.in"
  144. ((" backend ") " "))))
  145. (add-before 'configure 'disable-failing-tests
  146. (lambda _
  147. ;; Disable unmaintained tests that that fail with errors resembling:
  148. ;;
  149. ;; < # by sane-desc 3.5 from sane-backends 1.0.24git on Jul 31 2013
  150. ;; ---
  151. ;; > # by sane-desc 3.5 from sane-backends 1.0.27 on 1970-01-01#
  152. ;; FAIL: sane-desc -m usermap -s ./data
  153. (for-each
  154. (lambda (pattern)
  155. (substitute* "testsuite/tools/Makefile.in"
  156. (((string-append " " pattern " ")) " ")))
  157. (list "usermap" "db" "udev" "udev\\+acl" "udev\\+hwdb" "hwdb"))
  158. ;; Disable tests that try to connect to actual USB hardware & fail
  159. ;; with the following error when no USB access is allowed at all:
  160. ;;
  161. ;; sanei_usb_test: sanei_usb_test.c:849: main: Assertion
  162. ;; `test_init (1)' failed.
  163. (substitute* "testsuite/sanei/Makefile.in"
  164. (("sanei_usb_test\\$\\(EXEEXT\\) ") ""))))
  165. (add-before 'build 'build-pixma_sane_options.c
  166. ;; "No rule to make target '../backend/pixma/pixma_sane_options.c',
  167. ;; needed by 'sane-backends.pot-update'."
  168. (lambda _
  169. (invoke "make" "-C" "backend" "pixma/pixma_sane_options.c")))
  170. (add-after 'install 'install-udev-rules
  171. (lambda* (#:key outputs #:allow-other-keys)
  172. (let ((out (assoc-ref outputs "out")))
  173. (mkdir-p (string-append out "/lib/udev/rules.d"))
  174. (copy-file "tools/udev/libsane.rules"
  175. (string-append out
  176. "/lib/udev/rules.d/"
  177. "60-libsane.rules")))))
  178. (add-after 'install 'make-reproducible
  179. ;; XXX Work around an old bug <https://issues.guix.gnu.org/26247>.
  180. ;; Then work around "Throw to key `decoding-error' ..." by using sed.
  181. (lambda* (#:key outputs #:allow-other-keys)
  182. (let* ((out (assoc-ref outputs "out"))
  183. (locale (string-append out "/share/locale")))
  184. (with-directory-excursion locale
  185. (for-each (lambda (file)
  186. (invoke "sed" "-i" "/^PO-Revision-Date:/d" file))
  187. (list "en@boldquot/LC_MESSAGES/sane-backends.mo"
  188. "en@quot/LC_MESSAGES/sane-backends.mo")))))))))
  189. (home-page "http://www.sane-project.org")
  190. (synopsis
  191. "Raster image scanner library and drivers, without scanner support")
  192. (description "SANE stands for \"Scanner Access Now Easy\" and is an API
  193. proving access to any raster image scanner hardware (flatbed scanner,
  194. hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The
  195. package contains the library, but no drivers.")
  196. (license license:gpl2+))) ; plus linking exception
  197. ;; This variant links in the hpaio backend provided by hplip, which adds
  198. ;; support for HP scanners whose backends are not maintained by the SANE
  199. ;; project, and builds all of those backends.
  200. (define-public sane-backends
  201. (package/inherit sane-backends-minimal
  202. (name "sane-backends")
  203. (inputs
  204. `(("hplip" ,(@ (gnu packages cups) hplip-minimal))
  205. ("libjpeg" ,libjpeg-turbo) ; for pixma/epsonds/other back ends
  206. ("libpng" ,libpng) ; support ‘scanimage --format=png’
  207. ("libxml2" ,libxml2) ; for pixma back end
  208. ,@(package-inputs sane-backends-minimal)))
  209. (arguments
  210. (substitute-keyword-arguments (package-arguments sane-backends-minimal)
  211. ((#:phases phases)
  212. `(modify-phases ,phases
  213. (delete 'disable-backends)
  214. (add-after 'disable-failing-tests 'disable-failing-backend-tests
  215. (lambda _
  216. ;; Disable test that fails on i686:
  217. ;; <https://bugs.gnu.org/39449>
  218. (substitute* "testsuite/backend/genesys/Makefile.in"
  219. ((" genesys_unit_tests\\$\\(EXEEXT\\)") ""))
  220. #t))
  221. (add-after 'unpack 'add-backends
  222. (lambda _
  223. (substitute* "backend/dll.conf.in"
  224. (("hp5590" all) (format #f "~a~%~a" all "hpaio")))
  225. #t))
  226. (add-after 'install 'install-hpaio
  227. (lambda* (#:key inputs outputs #:allow-other-keys)
  228. (define hplip (string-append (assoc-ref inputs "hplip")
  229. "/lib/sane"))
  230. (define out (string-append (assoc-ref outputs "out")
  231. "/lib/sane"))
  232. (for-each
  233. (lambda (file)
  234. (symlink file (string-append out "/" (basename file))))
  235. (find-files hplip))
  236. #t))))))
  237. (synopsis
  238. "Raster image scanner library and drivers, with scanner support")
  239. (description "SANE stands for \"Scanner Access Now Easy\" and is an API
  240. proving access to any raster image scanner hardware (flatbed scanner,
  241. hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The
  242. package contains the library and drivers.")))
  243. (define-public scanbd
  244. (package
  245. (name "scanbd")
  246. (version "1.5.1")
  247. (source
  248. (origin
  249. (method url-fetch)
  250. (uri (string-append "mirror://sourceforge/scanbd/releases/"
  251. "scanbd-" version ".tgz"))
  252. (sha256
  253. (base32 "0pvy4qirfjdfm8aj6x5rkbgl7hk3jfa2s21qkk8ic5dqfjjab75n"))))
  254. (build-system gnu-build-system)
  255. (arguments
  256. (list #:configure-flags
  257. #~(list "--disable-debug"
  258. "--sysconfdir=/etc"
  259. "CFLAGS=-Wno-error") ; warnings should never be fatal
  260. #:phases
  261. #~(modify-phases %standard-phases
  262. (replace 'install
  263. (lambda* (#:key make-flags #:allow-other-keys)
  264. (let ((conf (string-append #$output "/etc/scanbd")))
  265. (apply invoke "make" "install"
  266. ;; Install example configuration to the store, not
  267. ;; /etc. These don't inherit from each other, so
  268. ;; we need both.
  269. (string-append "scanbdconfdir=" conf)
  270. (string-append "scannerconfdir=" conf "/scanner.d")
  271. make-flags))))
  272. (add-after 'install 'install-extra-documentation
  273. ;; The README provides more detailed set-up instructions than
  274. ;; the man page.
  275. (lambda _
  276. (let ((doc (string-append #$output "/share/doc/"
  277. #$name "-" #$version)))
  278. (install-file "doc/README.txt" doc)))))))
  279. (native-inputs
  280. (list pkg-config))
  281. (inputs
  282. `(("dbus" ,dbus)
  283. ("libconfuse" ,libconfuse)
  284. ("sane-backends" ,sane-backends)
  285. ("udev" ,eudev)
  286. ("zlib" ,zlib)))
  287. (home-page "https://scanbd.sourceforge.io")
  288. (synopsis "Configurable scanner button monitor")
  289. (description "Scanbd stands for scanner button daemon. It regularly polls
  290. scanners for pressed buttons, function knob changes, or other events such
  291. as (un)plugging the scanner or inserting and removing paper. Then it performs
  292. the desired action(s) such as saving, copying, or e-mailing the image.
  293. Actions can be fully customized through scripts, based on any combination of
  294. switch or knob settings. Events are also signaled over D-Bus and scans can
  295. even be triggered over D-Bus from foreign applications.
  296. Scanbd talks to scanners through the @acronym{SANE, Scanner Access Now Easy}
  297. back-end library. This means that it supports almost all existing scanners,
  298. provided the driver also exposes the buttons.")
  299. (license license:gpl2+)))
  300. (define-public xsane
  301. (package
  302. (name "xsane")
  303. (version "0.999")
  304. (source
  305. (origin
  306. (method git-fetch)
  307. (uri (git-reference
  308. (url "https://gitlab.com/sane-project/frontend/xsane.git")
  309. (commit version)))
  310. (file-name (git-file-name name version))
  311. (sha256
  312. (base32 "08zvxj7i1s88ckrsqldmsrikc3g62a6p3s3i5b5x4krcfpi3vs50"))
  313. ;; Apply some important-looking fixes. There are many more unreleased
  314. ;; commits upstream. A 1.0 release is planned.
  315. (patches (search-patches "xsane-fix-memory-leak.patch"
  316. "xsane-fix-pdf-floats.patch"
  317. "xsane-fix-snprintf-buffer-length.patch"
  318. "xsane-support-ipv6.patch"
  319. "xsane-tighten-default-umask.patch"))
  320. (modules '((guix build utils)))
  321. (snippet
  322. '(begin
  323. ;; Remove ancient bundled lprng code under a non-free licence. See
  324. ;; <https://trisquel.info/en/issues/10713>, which solves the problem
  325. ;; by replacing it with a newer (free) copy. We let the build fall
  326. ;; back to the system version instead, which appears to work fine.
  327. (delete-file "lib/snprintf.c")
  328. (substitute* "lib/Makefile.in"
  329. (("snprintf\\.o ") ""))
  330. #t))))
  331. (build-system gnu-build-system)
  332. (arguments
  333. `(#:make-flags
  334. (list (string-append "xsanedocdir=" (assoc-ref %outputs "out")
  335. "/share/doc/" ,name "-" ,version))
  336. #:tests? #f ; no test suite
  337. #:phases
  338. (modify-phases %standard-phases
  339. (add-after 'unpack 'patch-invalid-dereference
  340. ;; Fix the following compilation error with libpng:
  341. ;; xsane-save.c: In function ‘xsane_save_png’:
  342. ;; xsane-save.c:4913:21: error: dereferencing pointer to
  343. ;; incomplete type ‘png_struct {aka struct png_struct_def}’
  344. ;; if (setjmp(png_ptr->jmpbuf))
  345. ;; ^
  346. (lambda _
  347. (substitute* "src/xsane-save.c"
  348. (("png_ptr->jmpbuf") "png_jmpbuf(png_ptr)"))
  349. #t))
  350. (add-after 'unpack 'use-sane-help-browser
  351. (lambda _
  352. (substitute* "src/xsane.h"
  353. (("netscape") (which "xdg-open")))
  354. #t))
  355. (add-after 'install 'delete-empty-/sbin
  356. (lambda* (#:key outputs #:allow-other-keys)
  357. (let ((out (assoc-ref outputs "out")))
  358. (rmdir (string-append out "/sbin"))
  359. #t))))))
  360. (native-inputs
  361. (list pkg-config))
  362. (inputs
  363. `(("gtk+" ,gtk+-2)
  364. ("lcms" ,lcms)
  365. ("libjpeg" ,libjpeg-turbo)
  366. ("libtiff" ,libtiff)
  367. ("sane-backends" ,sane-backends)
  368. ;; To open the manual from the Help menu.
  369. ("xdg-utils" ,xdg-utils)))
  370. (home-page "https://gitlab.com/sane-project/frontend/xsane")
  371. (synopsis "Featureful graphical interface for document and image scanners")
  372. (description
  373. "XSane is a graphical interface for controlling a scanner and acquiring
  374. images from it. You can photocopy multi-page documents and save, fax, print,
  375. or e-mail your scanned images. It is highly configurable and exposes all
  376. device settings, letting you fine-tune the final result. It can also be used
  377. as a GIMP plugin to acquire images directly from a scanner.
  378. XSane talks to scanners through the @acronym{SANE, Scanner Access Now Easy}
  379. back-end library, which supports almost all existing scanners.")
  380. (license license:gpl2+)))