pkg: add support for foo-uninstalled.pc file

feature/tap-sh
William Pitcock 2012-05-05 23:00:20 -05:00
parent 1bf5da3ba4
commit 65d4b88dbc
2 changed files with 21 additions and 0 deletions

19
pkg.c
View File

@ -62,6 +62,7 @@ pkg_t *
pkg_find(const char *name, unsigned int flags) pkg_find(const char *name, unsigned int flags)
{ {
char locbuf[PKG_CONFIG_PATH_SZ]; char locbuf[PKG_CONFIG_PATH_SZ];
char uninst_locbuf[PKG_CONFIG_PATH_SZ];
char **path; char **path;
size_t count, iter = 0; size_t count, iter = 0;
const char *env_path; const char *env_path;
@ -76,8 +77,17 @@ pkg_find(const char *name, unsigned int flags)
while (iter < count) while (iter < count)
{ {
snprintf(locbuf, sizeof locbuf, "%s/%s" PKG_CONFIG_EXT, path[iter], name); snprintf(locbuf, sizeof locbuf, "%s/%s" PKG_CONFIG_EXT, path[iter], name);
snprintf(uninst_locbuf, sizeof uninst_locbuf, "%s/%s-uninstalled" PKG_CONFIG_EXT, path[iter], name);
free(path[iter]); free(path[iter]);
if ((f = fopen(uninst_locbuf, "r")) != NULL)
{
pkg_t *pkg = parse_file(locbuf, f);
pkg->uninstalled = true;
return pkg;
}
if ((f = fopen(locbuf, "r")) != NULL) if ((f = fopen(locbuf, "r")) != NULL)
return parse_file(locbuf, f); return parse_file(locbuf, f);
@ -94,8 +104,17 @@ pkg_find(const char *name, unsigned int flags)
while (iter < count) while (iter < count)
{ {
snprintf(locbuf, sizeof locbuf, "%s/%s" PKG_CONFIG_EXT, path[iter], name); snprintf(locbuf, sizeof locbuf, "%s/%s" PKG_CONFIG_EXT, path[iter], name);
snprintf(uninst_locbuf, sizeof uninst_locbuf, "%s/%s-uninstalled" PKG_CONFIG_EXT, path[iter], name);
free(path[iter]); free(path[iter]);
if ((f = fopen(uninst_locbuf, "r")) != NULL)
{
pkg_t *pkg = parse_file(locbuf, f);
pkg->uninstalled = true;
return pkg;
}
if ((f = fopen(locbuf, "r")) != NULL) if ((f = fopen(locbuf, "r")) != NULL)
return parse_file(locbuf, f); return parse_file(locbuf, f);

2
pkg.h
View File

@ -110,6 +110,8 @@ struct pkg_ {
pkg_dependency_t *requires_private; pkg_dependency_t *requires_private;
pkg_dependency_t *conflicts; pkg_dependency_t *conflicts;
pkg_tuple_t *vars; pkg_tuple_t *vars;
bool uninstalled;
}; };
#define PKG_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((c))) #define PKG_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((c)))