[Dev] [PATCH] librelib: allow LIBRETOOLS_LIBDIR to be contain multiple directories
Andreas Grapentin
andreas at grapentin.org
Fri Jul 16 17:23:17 GMT 2021
I've noticed while testing local changes of parabola-vmbuilder that it
can be helpful to allow librelib to search for requested files in
different directories.
We already have LIBRETOOLS_LIBDIR for this, but setting this variable
removes the default seach location from the directories considered by
librelib, which is not always the desired behaviour.
With this patch, I propose a behaviour more like the PATH environment
variable, in that LIBRETOOLS_LIBDIR can hold several directories
separated by the colon character (':'), and requested files are searched
for in each of these directory in order of their apperance. As usual, if
this is not set, librelib will still default to /usr/lib/libretools
To further reflect the behaviour change, the patch also renames the
variable to LIBRETOOLS_LIBRARY_PATH.
OK to commit?
-Andreas
--
------------------------------------------------------------------------------
my GPG Public Key: https://files.grapentin.org/.gpg/public.key
------------------------------------------------------------------------------
-------------- next part --------------
From 82baa4506b3a5497276dde4983eeaf7579dcac53 Mon Sep 17 00:00:00 2001
From: Andreas Grapentin <andreas at grapentin.org>
Date: Sun, 12 Apr 2020 19:13:19 +0200
Subject: [PATCH] src/lib/librelib: separate LIBRETOOLS_LIBDIR by ':' and
consider each part as a candidate for searching the requested script, and
rename LIBRETOOLS_LIBDIR to LIBRETOOLS_LIBRARY_PATH to reflect that change
Signed-off-by: Andreas Grapentin <andreas at grapentin.org>
---
src/lib/librelib | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/lib/librelib b/src/lib/librelib
index 004c8b1..2b03774 100755
--- a/src/lib/librelib
+++ b/src/lib/librelib
@@ -73,11 +73,17 @@ main() {
lib=${lib#libre}
lib=${lib%.sh}
- for file in ${lib} libre${lib} ${lib}.sh libre${lib}.sh; do
- if [[ -f "$LIBRETOOLS_LIBDIR/$file" ]]; then
- printf '%s\n' "$LIBRETOOLS_LIBDIR/$file"
- return 0 # $EXIT_SUCCESS
- fi
+ local libdir_array
+ IFS=: read -ra libdir_array <<< "$LIBRETOOLS_LIBDIR"
+
+ local librelib_dir
+ for librelib_dir in "${libdir_array[@]}"; do
+ for file in ${lib} libre${lib} ${lib}.sh libre${lib}.sh; do
+ if [[ -f "$librelib_dir/$file" ]]; then
+ printf '%s\n' "$librelib_dir/$file"
+ return 0 # $EXIT_SUCCESS
+ fi
+ done
done
_l print '%s: could not find library: %s' "$cmd" "$lib" >&2
return 1 # $EXIT_FAILURE
--
2.32.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <https://lists.parabola.nu/pipermail/dev/attachments/20210716/68f6b98f/attachment.sig>
More information about the Dev
mailing list