From 647c0255aa14355a04115e3b91169390bdfa7a2d Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Fri, 3 Feb 2017 13:17:21 -0600 Subject: [PATCH] libpkgconf: add PKGCONF_PKG_PKGF_DONT_RELOCATE_PATHS (#110) main: add PKG_CONFIG_DONT_RELOCATE_PATHS environment variable and --dont-relocate-paths option to disable path relocation --- libpkgconf/fragment.c | 2 +- libpkgconf/libpkgconf.h | 1 + main.c | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libpkgconf/fragment.c b/libpkgconf/fragment.c index 898a38f..82b9f69 100644 --- a/libpkgconf/fragment.c +++ b/libpkgconf/fragment.c @@ -100,7 +100,7 @@ pkgconf_fragment_munge(const pkgconf_client_t *client, char *buf, size_t buflen, pkgconf_strlcat(buf, source, buflen); - if (*buf == '/') + if (*buf == '/' && !(client->flags & PKGCONF_PKG_PKGF_DONT_RELOCATE_PATHS)) pkgconf_path_relocate(buf, buflen); } diff --git a/libpkgconf/libpkgconf.h b/libpkgconf/libpkgconf.h index b58390e..951450c 100644 --- a/libpkgconf/libpkgconf.h +++ b/libpkgconf/libpkgconf.h @@ -186,6 +186,7 @@ void pkgconf_client_set_prefix_varname(pkgconf_client_t *client, const char *pre #define PKGCONF_PKG_PKGF_ITER_PKG_IS_PRIVATE 0x100 #define PKGCONF_PKG_PKGF_SKIP_PROVIDES 0x200 #define PKGCONF_PKG_PKGF_REDEFINE_PREFIX 0x400 +#define PKGCONF_PKG_PKGF_DONT_RELOCATE_PATHS 0x800 #define PKGCONF_PKG_ERRF_OK 0x0 #define PKGCONF_PKG_ERRF_PACKAGE_NOT_FOUND 0x1 diff --git a/main.c b/main.c index 05603e0..4acc3d9 100644 --- a/main.c +++ b/main.c @@ -54,6 +54,7 @@ #define PKG_PATH (((uint64_t) 1) << 34) #define PKG_DEFINE_PREFIX (((uint64_t) 1) << 35) #define PKG_DONT_DEFINE_PREFIX (((uint64_t) 1) << 36) +#define PKG_DONT_RELOCATE_PATHS (((uint64_t) 1) << 37) static pkgconf_client_t pkg_client; @@ -577,6 +578,7 @@ usage(void) printf(" --prefix-variable=varname sets the name of the variable that pkgconf considers\n"); printf(" to be the package prefix\n"); printf(" --relocate=path relocates a path and exits (mostly for testsuite)\n"); + printf(" --dont-relocate-paths disables path relocation support\n"); printf("\nchecking specific pkg-config database entries:\n\n"); @@ -698,6 +700,7 @@ main(int argc, char *argv[]) { "define-prefix", no_argument, &want_flags, PKG_DEFINE_PREFIX }, { "relocate", required_argument, NULL, 45 }, { "dont-define-prefix", no_argument, &want_flags, PKG_DONT_DEFINE_PREFIX }, + { "dont-relocate-paths", no_argument, &want_flags, PKG_DONT_RELOCATE_PATHS }, { NULL, 0, NULL, 0 } }; @@ -757,6 +760,9 @@ main(int argc, char *argv[]) else want_flags &= ~(PKG_SILENCE_ERRORS); + if (getenv("PKG_CONFIG_DONT_RELOCATE_PATHS")) + want_flags |= (PKG_DONT_RELOCATE_PATHS); + if ((want_flags & PKG_ABOUT) == PKG_ABOUT) { about(); @@ -785,6 +791,9 @@ main(int argc, char *argv[]) return EXIT_SUCCESS; } + if ((want_flags & PKG_DONT_RELOCATE_PATHS) == PKG_DONT_RELOCATE_PATHS) + want_client_flags |= PKGCONF_PKG_PKGF_DONT_RELOCATE_PATHS; + error_msgout = stderr; if ((want_flags & PKG_ERRORS_ON_STDOUT) == PKG_ERRORS_ON_STDOUT) error_msgout = stdout;