define-prefix: skip one level if it ends up in /lib

In Debian and Ubuntu the multiarch filesystem layout looks as follows:

/usr/lib/x86_64-linux-gnu/pkgconfig/
/usr/lib/i386-linux-gnu/pkgconfig/

Which means when --define-prefix skips to the grand-parent
directory of pkgconfig, it ends up in /usr/lib rather than
/usr as it's supposed to.

This causes for example the include path to be printed as:
/usr/lib/include
which is wrong and breaks applications.

Check if the new directory is 'lib' and if it is go one step
above. A new series of unit tests is added with this layout.
This commit is contained in:
Luca Boccassi 2019-07-03 20:54:53 +01:00
parent 2ad16fa7ac
commit 50a46d5fbb
3 changed files with 28 additions and 0 deletions

View file

@ -51,3 +51,22 @@ done
RESULT="-I/some/path/include -L/some/path/lib -lfoo"
run_test --define-prefix --cflags --libs empty-prefix
run_test --dont-define-prefix --cflags --libs empty-prefix
# Test prefix redefinition for .pc files when the pkgconfig directory is in
# ..../lib/arch/ as Debian and Ubuntu and their derivatives do.
PKG_CONFIG_LIBDIR="${abs_srcdir}/lib/arch/pkgconfig"
for pkg in prefixdef prefixdef-expanded; do
# Typical redefinition
RESULT="-I${abs_top_srcdir}/check/include -L${abs_top_srcdir}/check/lib -lfoo"
run_test --define-prefix --cflags --libs $pkg
RESULT="-I/reloc/include -L/reloc/lib -lfoo"
run_test --dont-define-prefix --cflags --libs $pkg
# Non-standard redefinition
RESULT="-I/reloc/include -L${abs_top_srcdir}/check -lfoo"
run_test --define-prefix --prefix-variable=libdir --cflags --libs $pkg
RESULT="-I/reloc/include -L/reloc/lib -lfoo"
run_test --dont-define-prefix --cflags --libs $pkg
done

1
check/lib/arch/pkgconfig Symbolic link
View file

@ -0,0 +1 @@
../../pkgconfig

View file

@ -1021,6 +1021,14 @@ parse_line (Package *pkg, const char *untrimmed, const char *path,
q = g_path_get_dirname (pkg->pcfiledir);
prefix = g_path_get_dirname (q);
g_free (q);
/* Debian/Ubuntu use ..../lib/x86_64-linux-gnu/pkg-config */
if (g_str_has_suffix (prefix, "/lib"))
{
q = prefix;
prefix = g_path_get_dirname (q);
g_free (q);
}
/* Turn backslashes into slashes or
* g_shell_parse_argv() will eat them when ${prefix}