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
feature/tap-sh
William Pitcock 2017-02-03 13:17:21 -06:00
parent 02ad6d1ab9
commit 647c0255aa
3 changed files with 11 additions and 1 deletions

View File

@ -100,7 +100,7 @@ pkgconf_fragment_munge(const pkgconf_client_t *client, char *buf, size_t buflen,
pkgconf_strlcat(buf, source, buflen); pkgconf_strlcat(buf, source, buflen);
if (*buf == '/') if (*buf == '/' && !(client->flags & PKGCONF_PKG_PKGF_DONT_RELOCATE_PATHS))
pkgconf_path_relocate(buf, buflen); pkgconf_path_relocate(buf, buflen);
} }

View File

@ -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_ITER_PKG_IS_PRIVATE 0x100
#define PKGCONF_PKG_PKGF_SKIP_PROVIDES 0x200 #define PKGCONF_PKG_PKGF_SKIP_PROVIDES 0x200
#define PKGCONF_PKG_PKGF_REDEFINE_PREFIX 0x400 #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_OK 0x0
#define PKGCONF_PKG_ERRF_PACKAGE_NOT_FOUND 0x1 #define PKGCONF_PKG_ERRF_PACKAGE_NOT_FOUND 0x1

9
main.c
View File

@ -54,6 +54,7 @@
#define PKG_PATH (((uint64_t) 1) << 34) #define PKG_PATH (((uint64_t) 1) << 34)
#define PKG_DEFINE_PREFIX (((uint64_t) 1) << 35) #define PKG_DEFINE_PREFIX (((uint64_t) 1) << 35)
#define PKG_DONT_DEFINE_PREFIX (((uint64_t) 1) << 36) #define PKG_DONT_DEFINE_PREFIX (((uint64_t) 1) << 36)
#define PKG_DONT_RELOCATE_PATHS (((uint64_t) 1) << 37)
static pkgconf_client_t pkg_client; 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(" --prefix-variable=varname sets the name of the variable that pkgconf considers\n");
printf(" to be the package prefix\n"); printf(" to be the package prefix\n");
printf(" --relocate=path relocates a path and exits (mostly for testsuite)\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"); 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 }, { "define-prefix", no_argument, &want_flags, PKG_DEFINE_PREFIX },
{ "relocate", required_argument, NULL, 45 }, { "relocate", required_argument, NULL, 45 },
{ "dont-define-prefix", no_argument, &want_flags, PKG_DONT_DEFINE_PREFIX }, { "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 } { NULL, 0, NULL, 0 }
}; };
@ -757,6 +760,9 @@ main(int argc, char *argv[])
else else
want_flags &= ~(PKG_SILENCE_ERRORS); 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) if ((want_flags & PKG_ABOUT) == PKG_ABOUT)
{ {
about(); about();
@ -785,6 +791,9 @@ main(int argc, char *argv[])
return EXIT_SUCCESS; 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; error_msgout = stderr;
if ((want_flags & PKG_ERRORS_ON_STDOUT) == PKG_ERRORS_ON_STDOUT) if ((want_flags & PKG_ERRORS_ON_STDOUT) == PKG_ERRORS_ON_STDOUT)
error_msgout = stdout; error_msgout = stdout;