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
This commit is contained in:
Sergey Trofimov 2025-06-12 12:30:35 +02:00 committed by Maxim Cournoyer
parent c7cb794db8
commit ebc8f12d65
No known key found for this signature in database
GPG key ID: 1260E46482E63562
3 changed files with 42 additions and 0 deletions

View file

@ -2266,6 +2266,7 @@ dist_patch_DATA = \
%D%/packages/patches/sage-safeguard-sage-getargspec-cython.patch \ %D%/packages/patches/sage-safeguard-sage-getargspec-cython.patch \
%D%/packages/patches/sajson-for-gemmi-numbers-as-strings.patch \ %D%/packages/patches/sajson-for-gemmi-numbers-as-strings.patch \
%D%/packages/patches/sajson-build-with-gcc10.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/sbc-fix-build-non-x86.patch \
%D%/packages/patches/sbcl-fix-arm64-shared-lib.patch \ %D%/packages/patches/sbcl-fix-arm64-shared-lib.patch \
%D%/packages/patches/sbcl-aserve-add-HTML-5-elements.patch \ %D%/packages/patches/sbcl-aserve-add-HTML-5-elements.patch \

View file

@ -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

View file

@ -48,6 +48,7 @@
#:use-module ((guix licenses) #:use-module ((guix licenses)
#:prefix license:) #:prefix license:)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix search-paths)
#:use-module (guix utils)) #:use-module (guix utils))
(define-public sane-airscan (define-public sane-airscan
@ -115,6 +116,8 @@ both WSD and eSCL.")
(file-name (git-file-name name version)) (file-name (git-file-name name version))
(sha256 (sha256
(base32 "1fb6shx9bz0svcyasmyqs93rbbwq7kzg6l0h1zh3kjvcwhchyv72")) (base32 "1fb6shx9bz0svcyasmyqs93rbbwq7kzg6l0h1zh3kjvcwhchyv72"))
(patches (search-patches
"sane-look-for-plugins-in-SANE_BACKEND_LIB_PATH.patch"))
(modules '((guix build utils))) (modules '((guix build utils)))
(snippet (snippet
;; Generated HTML files and udev rules normally embed a ;; Generated HTML files and udev rules normally embed a
@ -186,6 +189,11 @@ both WSD and eSCL.")
(string-append out (string-append out
"/lib/udev/rules.d/" "/lib/udev/rules.d/"
"60-libsane.rules"))))) "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 (add-after 'install 'make-reproducible
;; XXX Work around an old bug <https://issues.guix.gnu.org/26247>. ;; XXX Work around an old bug <https://issues.guix.gnu.org/26247>.
;; Then work around "Throw to key `decoding-error' ..." by using sed. ;; 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)) (invoke "sed" "-i" "/^PO-Revision-Date:/d" file))
(list "en@boldquot/LC_MESSAGES/sane-backends.mo" (list "en@boldquot/LC_MESSAGES/sane-backends.mo"
"en@quot/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") (home-page "http://www.sane-project.org")
(synopsis (synopsis
"Raster image scanner library and drivers, without scanner support") "Raster image scanner library and drivers, without scanner support")