Page MenuHome GnuPG

gpgrt-config doesn't work well with PKG_CONFIG_LIBDIR="" and setting PKG_CONFIG_PATH
Closed, ResolvedPublic

Description

gpgrt-config runs emulating pkg-config.

pkg-config supports PKG_CONFIG_PATH and PKG_CONFIG_LIBDIR environment variables.

Specifically, when PKG_CONFIG_LIBDIR is empty and PKG_CONFIG_PATH is defined, gpgrt-config should search *.pc files by PKG_CONFIG_PATH, ignoring --libdir option.

Event Timeline

gniibe triaged this task as High priority.Sep 9 2021, 12:33 PM
gniibe created this task.

Here is a possible fix:

diff --git a/src/gpgrt-config.in b/src/gpgrt-config.in
index 6352384..3aaa243 100644
--- a/src/gpgrt-config.in
+++ b/src/gpgrt-config.in
@@ -470,7 +470,7 @@ while test $# -gt 0; do
     esac
 done
 
-if [ x"${PKG_CONFIG_LIBDIR:+set}" = xset -a -z "$PKG_CONFIG_LIBDIR" ]; then
+if env | grep '^PKG_CONFIG_LIBDIR=$' >/dev/null 2>&1; then
   # The variable set as empty, we use PKG_CONFIG_PATH in this case,
   # ignoring --libdir option
   if [ -z "$PKG_CONFIG_PATH"  ]; then

If we could assume Bash, we can use test with -v, but it's not portable.
Also, we can't use printenv, it's not POSIX command.

gniibe changed the task status from Open to Testing.Sep 10 2021, 3:00 AM
gniibe added a project: Testing.

The fix works for me (using bash on openSUSE Tumbleweed).