From 65d4b88dbce94ec6b4f038e64560fcc457c316e7 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 5 May 2012 23:00:20 -0500 Subject: [PATCH] pkg: add support for foo-uninstalled.pc file --- pkg.c | 19 +++++++++++++++++++ pkg.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/pkg.c b/pkg.c index c77f017..bbcbb72 100644 --- a/pkg.c +++ b/pkg.c @@ -62,6 +62,7 @@ pkg_t * pkg_find(const char *name, unsigned int flags) { char locbuf[PKG_CONFIG_PATH_SZ]; + char uninst_locbuf[PKG_CONFIG_PATH_SZ]; char **path; size_t count, iter = 0; const char *env_path; @@ -76,8 +77,17 @@ pkg_find(const char *name, unsigned int flags) while (iter < count) { 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]); + 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) return parse_file(locbuf, f); @@ -94,8 +104,17 @@ pkg_find(const char *name, unsigned int flags) while (iter < count) { 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]); + 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) return parse_file(locbuf, f); diff --git a/pkg.h b/pkg.h index a517601..d3c8cda 100644 --- a/pkg.h +++ b/pkg.h @@ -110,6 +110,8 @@ struct pkg_ { pkg_dependency_t *requires_private; pkg_dependency_t *conflicts; pkg_tuple_t *vars; + + bool uninstalled; }; #define PKG_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((c)))