Mailing List Archive

[PATCH Libgpg-error] m4: Fix detection of gpgrt's libdir.
* src/gpg-error.m4 (GPGRT_CONFIG): Handle the case where none of the
system lib directories contain a pkgconfig subdirectory.
--

When we look for gpgrt_libdir, there's a corner case if we had been able
to obtain system libdirs (using `cc -print-search-dirs`) *but* none of
those system libdirs happen to contain a valid pkgconfig subdirectory
(which may be unlikely but can and does happen when cross-compiling).

We do test for the case where we have not obtained any system libdir at
all, in which case we fallback to `${gpgrt_prefix}/lib`
(`possible_libdir1`), but we do not test if the list of libdir
candidates is reduced to nothing after we have eliminated all the
libdirs that do not contain a pkgconfig subdirectory.

This patch adds a test for this precise case.

Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org>
---
src/gpg-error.m4 | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/src/gpg-error.m4 b/src/gpg-error.m4
index 4b5cd40..a9b96af 100644
--- a/src/gpg-error.m4
+++ b/src/gpg-error.m4
@@ -120,6 +120,10 @@ AC_DEFUN([AM_PATH_GPG_ERROR],
fi
if test -n "$gpgrt_libdir"; then break; fi
done
+ if test -z "$libdir_candidates"; then
+ # No valid pkgconfig dir in any of the system directories, fallback
+ gpgrt_libdir=${possible_libdir1}
+ fi
else
# When we cannot determine system libdir-format, use this:
gpgrt_libdir=${possible_libdir1}
--
2.35.3


_______________________________________________
Gnupg-devel mailing list
Gnupg-devel@gnupg.org
https://lists.gnupg.org/mailman/listinfo/gnupg-devel
Re: [PATCH Libgpg-error] m4: Fix detection of gpgrt's libdir. [ In reply to ]
Damien Goutte-Gattat wrote:
> * src/gpg-error.m4 (GPGRT_CONFIG): Handle the case where none of the
> system lib directories contain a pkgconfig subdirectory.

Thank you. Applied (adding version update), and pushed.
--

_______________________________________________
Gnupg-devel mailing list
Gnupg-devel@gnupg.org
https://lists.gnupg.org/mailman/listinfo/gnupg-devel
Re: [PATCH Libgpg-error] m4: Fix detection of gpgrt's libdir. [ In reply to ]
On Tue, Sep 20, 2022 at 5:29 PM Damien Goutte-Gattat via Gnupg-devel
<gnupg-devel@gnupg.org> wrote:
>
> * src/gpg-error.m4 (GPGRT_CONFIG): Handle the case where none of the
> system lib directories contain a pkgconfig subdirectory.
> --
>
> When we look for gpgrt_libdir, there's a corner case if we had been able
> to obtain system libdirs (using `cc -print-search-dirs`) *but* none of
> those system libdirs happen to contain a valid pkgconfig subdirectory
> (which may be unlikely but can and does happen when cross-compiling).
>
> We do test for the case where we have not obtained any system libdir at
> all, in which case we fallback to `${gpgrt_prefix}/lib`
> (`possible_libdir1`), but we do not test if the list of libdir
> candidates is reduced to nothing after we have eliminated all the
> libdirs that do not contain a pkgconfig subdirectory.
>
> This patch adds a test for this precise case.
>
> Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org>
> ---
> src/gpg-error.m4 | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/src/gpg-error.m4 b/src/gpg-error.m4
> index 4b5cd40..a9b96af 100644
> --- a/src/gpg-error.m4
> +++ b/src/gpg-error.m4
> @@ -120,6 +120,10 @@ AC_DEFUN([AM_PATH_GPG_ERROR],
> fi
> if test -n "$gpgrt_libdir"; then break; fi
> done
> + if test -z "$libdir_candidates"; then
> + # No valid pkgconfig dir in any of the system directories, fallback
> + gpgrt_libdir=${possible_libdir1}
> + fi
> else
> # When we cannot determine system libdir-format, use this:
> gpgrt_libdir=${possible_libdir1}
> --
> 2.35.3

I think the portable test is:

if test x"$libdir_candidates" = "x"; then

I don't recall why it is preferred.

Jeff

_______________________________________________
Gnupg-devel mailing list
Gnupg-devel@gnupg.org
https://lists.gnupg.org/mailman/listinfo/gnupg-devel
Re: [PATCH Libgpg-error] m4: Fix detection of gpgrt's libdir. [ In reply to ]
Jeffrey Walton via Gnupg-devel wrote:
> On Tue, Sep 20, 2022 at 5:29 PM Damien Goutte-Gattat via Gnupg-devel
> <gnupg-devel@gnupg.org> wrote:
...
>> diff --git a/src/gpg-error.m4 b/src/gpg-error.m4
>> index 4b5cd40..a9b96af 100644
>> --- a/src/gpg-error.m4
>> +++ b/src/gpg-error.m4
>> @@ -120,6 +120,10 @@ AC_DEFUN([AM_PATH_GPG_ERROR],
>> fi
>> if test -n "$gpgrt_libdir"; then break; fi
>> done
>> + if test -z "$libdir_candidates"; then
>> + # No valid pkgconfig dir in any of the system directories, fallback
>> + gpgrt_libdir=${possible_libdir1}
>> + fi
>> else
>> # When we cannot determine system libdir-format, use this:
>> gpgrt_libdir=${possible_libdir1}
...
> I think the portable test is:
>
> if test x"$libdir_candidates" = "x"; then
>
> I don't recall why it is preferred.

This came up on the git list about a year ago. The git
project tries quite hard to write portable shell code and
they don't require the `test "x$foo" = "x"` idiom.

https://lore.kernel.org/git/3ab4f29e-987a-c7de-0cca-a64c3bf4be47@gmail.com/

That post links to an interesting article on the history of
this particular shell idiom:

https://www.vidarholen.net/contents/blog/?p=1035

Based on that, I think it would be better to not use that
method unless the reason for it can be adequately defined.

--
Todd
Re: [PATCH Libgpg-error] m4: Fix detection of gpgrt's libdir. [ In reply to ]
On Wed, Sep 21, 2022 at 01:24:23AM -0400, GnuPG Development wrote:
> On Tue, Sep 20, 2022 at 5:29 PM Damien Goutte-Gattat via Gnupg-devel
> <gnupg-devel@gnupg.org> wrote:
> >
> > * src/gpg-error.m4 (GPGRT_CONFIG): Handle the case where none of the
> > system lib directories contain a pkgconfig subdirectory.
> > --
> >
> > When we look for gpgrt_libdir, there's a corner case if we had been able
> > to obtain system libdirs (using `cc -print-search-dirs`) *but* none of
> > those system libdirs happen to contain a valid pkgconfig subdirectory
> > (which may be unlikely but can and does happen when cross-compiling).
> >
> > We do test for the case where we have not obtained any system libdir at
> > all, in which case we fallback to `${gpgrt_prefix}/lib`
> > (`possible_libdir1`), but we do not test if the list of libdir
> > candidates is reduced to nothing after we have eliminated all the
> > libdirs that do not contain a pkgconfig subdirectory.
> >
> > This patch adds a test for this precise case.
> >
> > Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org>
> > ---
> > src/gpg-error.m4 | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/src/gpg-error.m4 b/src/gpg-error.m4
> > index 4b5cd40..a9b96af 100644
> > --- a/src/gpg-error.m4
> > +++ b/src/gpg-error.m4
> > @@ -120,6 +120,10 @@ AC_DEFUN([AM_PATH_GPG_ERROR],
> > fi
> > if test -n "$gpgrt_libdir"; then break; fi
> > done
> > + if test -z "$libdir_candidates"; then
> > + # No valid pkgconfig dir in any of the system directories, fallback
> > + gpgrt_libdir=${possible_libdir1}
> > + fi
> > else
> > # When we cannot determine system libdir-format, use this:
> > gpgrt_libdir=${possible_libdir1}
> > --
> > 2.35.3
>
> I think the portable test is:
>
> if test x"$libdir_candidates" = "x"; then
>
> I don't recall why it is preferred.

IIRC both are fine on any semi-modern shell.
--
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab