gnu: Use PACKAGE/INHERIT in more places.
[jackhill/guix/guix.git] / gnu / packages / scanner.scm
index 55a6422..9b405a5 100644 (file)
@@ -2,7 +2,7 @@
 ;;; Copyright © 2014 John Darrington <jmd@gnu.org>
 ;;; Copyright © 2015 Andy Wingo <wingo@igalia.com>
 ;;; Copyright © 2016 Andy Patterson <ajpatter@uwaterloo.ca>
-;;; Copyright © 2017, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2017, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
 ;;;
 ;;; This file is part of GNU Guix.
 
 (define-module (gnu packages scanner)
   #:use-module (gnu packages)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages freedesktop)
+  #:use-module (gnu packages gettext)
   #:use-module (gnu packages ghostscript)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages image)
   #:use-module (gnu packages libusb)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages python)
+  #:use-module (gnu packages xml)
   #:use-module (guix build-system gnu)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module ((guix licenses)
-                #:prefix licence:)
+                #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix utils))
 
 (define-public sane-backends-minimal
   (package
     (name "sane-backends-minimal")
-    (version "1.0.29")
+    (version "1.0.32")
     (source (origin
-             (method url-fetch)
-             (uri (string-append
-                   "https://gitlab.com/sane-project/backends/uploads/"
-                   "54f858b20a364fc35d820df935a86478/"
-                   "sane-backends-" version ".tar.gz"))
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://gitlab.com/sane-project/backends")
+                   (commit version)))
+             (file-name (git-file-name name version))
              (sha256
-              (base32
-               "1vd83vhl0hddwsdh2jb0k3yzycfghi2xa9lc3ga9r12rbx77n0ma"))
+              (base32 "13jlqdp7n7z2n78v6idl3ri5idk7ddk9j8wrmh73lba8l9y8xnsi"))
              (modules '((guix build utils)))
              (snippet
               ;; Generated HTML files and udev rules normally embed a
               '(begin
                  (substitute* "tools/sane-desc.c"
                    (("asctime \\(localtime \\(&current_time\\)\\)")
-                    "\"1970-01-01\""))
-                 #t))))
+                    "\"1970-01-01\""))))))
     (build-system gnu-build-system)
     (native-inputs
-     `(("pkg-config" ,pkg-config)))
+     `(("autoconf" ,autoconf)
+       ("autoconf-archive" ,autoconf-archive)
+       ("automake" ,automake)
+       ("gettext" ,gettext-minimal)
+       ("libtool" ,libtool)
+       ("pkg-config" ,pkg-config)
+       ;; For scripts/pixma_gen_options.py.
+       ("python" ,python-wrapper)))
     (inputs
      `(("libusb" ,libusb)))
     (arguments
      `(#:phases
        (modify-phases %standard-phases
+         (add-before 'bootstrap 'zap-unnecessary-git-dependency
+           (lambda _
+             ;; This runs before default patch-shebangs phase.
+             (substitute* "tools/git-version-gen"
+               (("/bin/sh") (which "sh")))
+             (with-output-to-file ".tarball-version"
+               (lambda _ (format #t ,version)))))
          (add-before 'configure 'disable-backends
            (lambda _
              (setenv "BACKENDS" " ")
 
              ;; Disable tests that may require back ends to be built.
              (substitute* "testsuite/Makefile.in"
-               ((" backend ") " "))
-             #t))
-         (add-after 'unpack 'disable-failing-tests
+               ((" backend ") " "))))
+         (add-before 'configure 'disable-failing-tests
            (lambda _
              ;; Disable unmaintained tests that that fail with errors resembling:
              ;;
              ;; sanei_usb_test: sanei_usb_test.c:849: main: Assertion
              ;; `test_init (1)' failed.
              (substitute* "testsuite/sanei/Makefile.in"
-               (("sanei_usb_test\\$\\(EXEEXT\\) ") ""))
-             #t))
+               (("sanei_usb_test\\$\\(EXEEXT\\) ") ""))))
+         (add-before 'build 'build-pixma_sane_options.c
+           ;; "No rule to make target '../backend/pixma/pixma_sane_options.c',
+           ;; needed by 'sane-backends.pot-update'."
+           (lambda _
+             (invoke "make" "-C" "backend" "pixma/pixma_sane_options.c")))
          (add-after 'install 'install-udev-rules
            (lambda* (#:key outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out")))
                (copy-file "tools/udev/libsane.rules"
                           (string-append out
                                          "/lib/udev/rules.d/"
-                                         "60-libsane.rules"))
-               #t))))))
+                                         "60-libsane.rules")))))
+         (add-after 'install 'make-reproducible
+           ;; XXX Work around an old bug <https://issues.guix.gnu.org/26247>.
+           ;; Then work around "Throw to key `decoding-error' ..." by using sed.
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (locale (string-append out "/share/locale")))
+               (with-directory-excursion locale
+                 (for-each (lambda (file)
+                             (invoke "sed" "-i" "/^PO-Revision-Date:/d" file))
+                           (list "en@boldquot/LC_MESSAGES/sane-backends.mo"
+                                 "en@quot/LC_MESSAGES/sane-backends.mo")))))))))
     (home-page "http://www.sane-project.org")
     (synopsis
      "Raster image scanner library and drivers, without scanner support")
 proving access to any raster image scanner hardware (flatbed scanner,
 hand-held scanner, video- and still-cameras, frame-grabbers, etc.).  The
 package contains the library, but no drivers.")
-    (license licence:gpl2+))) ; plus linking exception
+    (license license:gpl2+))) ; plus linking exception
 
-;; This variant links in the hpaio backend, provided by hplip, which adds
-;; support for HP scanners whose backends are not maintained by
-;; 'sane-backends'. It also builds all of those backends.
+;; This variant links in the hpaio backend provided by hplip, which adds
+;; support for HP scanners whose backends are not maintained by the SANE
+;; project, and builds all of those backends.
 (define-public sane-backends
-  (package
-    (inherit sane-backends-minimal)
+  (package/inherit sane-backends-minimal
     (name "sane-backends")
     (inputs
      `(("hplip" ,(@ (gnu packages cups) hplip-minimal))
-       ("libjpeg" ,libjpeg-turbo)       ; wanted by pixma, epsonds, others
+       ("libjpeg" ,libjpeg-turbo)       ; for pixma/epsonds/other back ends
        ("libpng" ,libpng)               ; support ‘scanimage --format=png’
+       ("libxml2" ,libxml2)             ; for pixma back end
        ,@(package-inputs sane-backends-minimal)))
     (arguments
      (substitute-keyword-arguments (package-arguments sane-backends-minimal)
@@ -197,7 +226,7 @@ package contains the library and drivers.")))
      `(#:make-flags
        (list (string-append "xsanedocdir=" (assoc-ref %outputs "out")
                             "/share/doc/" ,name "-" ,version))
-       #:tests? #f                      ; no test suite
+       #:tests? #f                                ; no test suite
        #:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'patch-invalid-dereference
@@ -243,4 +272,4 @@ as a GIMP plugin to acquire images directly from a scanner.
 
 XSane talks to scanners through the @acronym{SANE, Scanner Access Now Easy}
 back-end library, which supports almost all existing scanners.")
-    (license licence:gpl2+)))
+    (license license:gpl2+)))