Apologies, the attached patch was out of date. The patch attached to this mail is the correct one.
-Andreas
On Fri, Jul 16, 2021 at 07:23:17PM +0200, Andreas Grapentin wrote:
>
> 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
> ------------------------------------------------------------------------------
> From 82baa4506b3a5497276dde4983eeaf7579dcac53 Mon Sep 17 00:00:00 2001
> From: Andreas Grapentin <[email protected]>
> 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 <[email protected]>
> ---
> 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
>
> _______________________________________________
> Dev mailing list
> [email protected]
> https://lists.parabola.nu/mailman/listinfo/dev
--
------------------------------------------------------------------------------
my GPG Public Key: https://files.grapentin.org/.gpg/public.key
------------------------------------------------------------------------------
From a94838e1792a85f74a540daafb6715a5b3ae2908 Mon Sep 17 00:00:00 2001 From: Andreas Grapentin <[email protected]> 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 <[email protected]> --- src/lib/librelib | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/lib/librelib b/src/lib/librelib index 004c8b1..b3fb9c2 100755 --- a/src/lib/librelib +++ b/src/lib/librelib @@ -46,7 +46,7 @@ usage() { Hardcoding that path is the way of the dark side." echo prose 'By default, it looks for the files in `%s`, but this can be - changed with the environmental variable LIBRETOOLS_LIBDIR.' "$default_libdir" + changed with the environmental variable LIBRETOOLS_LIBRARY_PATH.' "$default_libdir" echo print "Example usage:" printf ' . $(%s conf)\n' "$cmd" @@ -65,19 +65,25 @@ main() { return 0 # $EXIT_SUCCESS fi - if [[ -z $LIBRETOOLS_LIBDIR ]]; then - export LIBRETOOLS_LIBDIR=$default_libdir + if [[ -z $LIBRETOOLS_LIBRARY_PATH ]]; then + export LIBRETOOLS_LIBRARY_PATH=$default_libdir fi lib=$1 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 -r -a libdir_array <<<"$LIBRETOOLS_LIBRARY_PATH" + + local libdir + for libdir in "${libdir_array[@]}"; do + for file in ${lib} libre${lib} ${lib}.sh libre${lib}.sh; do + if [[ -f "$libdir/$file" ]]; then + printf '%s\n' "$libdir/$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
signature.asc
Description: PGP signature
_______________________________________________ Dev mailing list [email protected] https://lists.parabola.nu/mailman/listinfo/dev
