From ebc8f12d65309c822ad1da24675a24a5b82fccf7 Mon Sep 17 00:00:00 2001 From: Sergey Trofimov Date: Thu, 12 Jun 2025 12:30:35 +0200 Subject: [PATCH] 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 --- gnu/local.mk | 1 + ...for-plugins-in-SANE_BACKEND_LIB_PATH.patch | 25 +++++++++++++++++++ gnu/packages/scanner.scm | 16 ++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 gnu/packages/patches/sane-look-for-plugins-in-SANE_BACKEND_LIB_PATH.patch diff --git a/gnu/local.mk b/gnu/local.mk index 0e9a737f03d..272b3452642 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -2266,6 +2266,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 \ diff --git a/gnu/packages/patches/sane-look-for-plugins-in-SANE_BACKEND_LIB_PATH.patch b/gnu/packages/patches/sane-look-for-plugins-in-SANE_BACKEND_LIB_PATH.patch new file mode 100644 index 00000000000..aef4d152743 --- /dev/null +++ b/gnu/packages/patches/sane-look-for-plugins-in-SANE_BACKEND_LIB_PATH.patch @@ -0,0 +1,25 @@ +From 324ad2e5b5d4b08fb682fa05d5baaaf087d13f5c Mon Sep 17 00:00:00 2001 +From: Sergey Trofimov +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 + diff --git a/gnu/packages/scanner.scm b/gnu/packages/scanner.scm index 259e378b658..b99e60a6c59 100644 --- a/gnu/packages/scanner.scm +++ b/gnu/packages/scanner.scm @@ -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 . ;; 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")