~ruther/guix-local

a78f921850ad53820ba35a042d6395668e56a51d — Sergey Trofimov 9 months ago 652d885
gnu: sane-backends-minimal: Respect backend search paths.

SANE's dynamic loading mechanism looks for configs in SANE_CONFIG_DIR,
and the libraries are expected to be either in LD_LIBRARY_PATH or in the
LIBDIR, which is set during the build to $PREFIX/lib/sane. A small patch
is necessary to make SANE respect backend search paths set by Guix.

* gnu/local.mk: Register sane-look-for-plugins-in-SANE_BACKEND_LIB_PATH.patch
* gnu/packages/scanner.scm (sane-backends-minimal): Patch dynamic
loading mechanism to look for libraries in SANE_BACKEND_LIB_PATH.

Change-Id: I132a709d171331d249acfe2fd1242dae43867ae8
M gnu/local.mk => gnu/local.mk +1 -0
@@ 2270,6 2270,7 @@ dist_patch_DATA =						\
  %D%/packages/patches/sage-safeguard-sage-getargspec-cython.patch \
  %D%/packages/patches/sajson-for-gemmi-numbers-as-strings.patch	\
  %D%/packages/patches/sajson-build-with-gcc10.patch		\
  %D%/packages/patches/sane-look-for-plugins-in-SANE_BACKEND_LIB_PATH.patch	\
  %D%/packages/patches/sbc-fix-build-non-x86.patch		\
  %D%/packages/patches/sbcl-fix-arm64-shared-lib.patch		\
  %D%/packages/patches/sbcl-aserve-add-HTML-5-elements.patch	\

A gnu/packages/patches/sane-look-for-plugins-in-SANE_BACKEND_LIB_PATH.patch => gnu/packages/patches/sane-look-for-plugins-in-SANE_BACKEND_LIB_PATH.patch +25 -0
@@ 0,0 1,25 @@
From 324ad2e5b5d4b08fb682fa05d5baaaf087d13f5c Mon Sep 17 00:00:00 2001
From: Sergey Trofimov <sarg@sarg.org.ru>
Date: Sat, 20 Sep 2025 18:26:44 +0200
Subject: [PATCH] Look for plugins in SANE_BACKEND_LIB_PATH.

---
 backend/dll.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/backend/dll.c b/backend/dll.c
index bf34c4f6d..d52e81206 100644
--- a/backend/dll.c
+++ b/backend/dll.c
@@ -461,6 +461,8 @@ load (struct backend *be)
     be->op[i] = op_unsupported;
 
   path = getenv ("LD_LIBRARY_PATH");
+  if (!path)
+    path = getenv ("SANE_BACKEND_LIB_PATH");	/* for guix */
   if (!path)
     path = getenv ("SHLIB_PATH");	/* for HP-UX */
   if (!path)
-- 
2.51.0


M gnu/packages/scanner.scm => gnu/packages/scanner.scm +16 -0
@@ 48,6 48,7 @@
  #:use-module ((guix licenses)
                #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix search-paths)
  #:use-module (guix utils))

(define-public sane-airscan


@@ 115,6 116,8 @@ both WSD and eSCL.")
             (file-name (git-file-name name version))
             (sha256
              (base32 "1fb6shx9bz0svcyasmyqs93rbbwq7kzg6l0h1zh3kjvcwhchyv72"))
             (patches (search-patches
                       "sane-look-for-plugins-in-SANE_BACKEND_LIB_PATH.patch"))
             (modules '((guix build utils)))
             (snippet
              ;; Generated HTML files and udev rules normally embed a


@@ 186,6 189,11 @@ both WSD and eSCL.")
                          (string-append out
                                         "/lib/udev/rules.d/"
                                         "60-libsane.rules")))))
         (add-after 'install 'remove-dll.conf
           (lambda _
             ;; dll.conf lists enabled backends, so it should be removed as
             ;; there are none in this package
             (delete-file (string-append %output "/etc/sane.d/dll.conf"))))
         (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.


@@ 197,6 205,14 @@ both WSD and eSCL.")
                             (invoke "sed" "-i" "/^PO-Revision-Date:/d" file))
                           (list "en@boldquot/LC_MESSAGES/sane-backends.mo"
                                 "en@quot/LC_MESSAGES/sane-backends.mo")))))))))
    (native-search-paths
     (list
      (search-path-specification
        (variable "SANE_CONFIG_DIR")
        (files '("etc/sane.d")))
      (search-path-specification
        (variable "SANE_BACKEND_LIB_PATH")
        (files '("lib/sane")))))
    (home-page "http://www.sane-project.org")
    (synopsis
     "Raster image scanner library and drivers, without scanner support")