diff --git a/main.c b/main.c index a6853e2..4ae7e95 100644 --- a/main.c +++ b/main.c @@ -244,7 +244,7 @@ pkg_queue_walk(pkg_queue_t *head) { pkg_t *pkg; - pkg = pkg_verify_dependency(iter, global_traverse_flags); + pkg = pkg_verify_dependency(iter, global_traverse_flags, NULL); print_requires(pkg, NULL); } } @@ -261,7 +261,7 @@ pkg_queue_walk(pkg_queue_t *head) { pkg_t *pkg; - pkg = pkg_verify_dependency(iter, global_traverse_flags | PKGF_SEARCH_PRIVATE); + pkg = pkg_verify_dependency(iter, global_traverse_flags | PKGF_SEARCH_PRIVATE, NULL); print_requires_private(pkg, NULL); } } diff --git a/pkg.c b/pkg.c index dbe2f96..69f231d 100644 --- a/pkg.c +++ b/pkg.c @@ -244,13 +244,21 @@ pkg_get_comparator(pkg_dependency_t *pkgdep) * return the appropriate pkg_t object, else NULL. */ pkg_t * -pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags) +pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags) { pkg_t *pkg; + if (eflags != NULL) + *eflags = PKG_ERRF_OK; + pkg = pkg_find(pkgdep->package, flags); if (pkg == NULL) + { + if (eflags != NULL) + *eflags |= PKG_ERRF_PACKAGE_NOT_FOUND; + return NULL; + } pkg->id = strdup(pkgdep->package); @@ -285,6 +293,9 @@ pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags) return pkg; } + if (eflags != NULL) + *eflags |= PKG_ERRF_PACKAGE_VER_MISMATCH; + return NULL; } @@ -307,6 +318,7 @@ pkg_walk_list(pkg_dependency_t *deplist, int maxdepth, unsigned int flags) { + unsigned int eflags; pkg_dependency_t *node; foreach_list_entry(deplist, node) @@ -316,13 +328,16 @@ pkg_walk_list(pkg_dependency_t *deplist, if (*node->package == '\0') continue; - pkgdep = pkg_verify_dependency(node, flags); + pkgdep = pkg_verify_dependency(node, flags, &eflags); if (pkgdep == NULL) { - fprintf(stderr, "Package %s was not found in the pkg-config search path.\n", node->package); - fprintf(stderr, "Perhaps you should add the directory containing `%s.pc'\n", node->package); - fprintf(stderr, "to the PKG_CONFIG_PATH environment variable\n"); - fprintf(stderr, "No package '%s' found\n", node->package); + if (eflags & PKG_ERRF_PACKAGE_NOT_FOUND) + { + fprintf(stderr, "Package %s was not found in the pkg-config search path.\n", node->package); + fprintf(stderr, "Perhaps you should add the directory containing `%s.pc'\n", node->package); + fprintf(stderr, "to the PKG_CONFIG_PATH environment variable\n"); + fprintf(stderr, "No package '%s' found\n", node->package); + } exit(EXIT_FAILURE); } diff --git a/pkg.h b/pkg.h index cfb2988..1564df4 100644 --- a/pkg.h +++ b/pkg.h @@ -104,11 +104,15 @@ struct pkg_ { #define PKGF_SEARCH_PRIVATE 0x1 #define PKGF_ENV_ONLY 0x2 +#define PKG_ERRF_OK 0x0 +#define PKG_ERRF_PACKAGE_NOT_FOUND 0x1 +#define PKG_ERRF_PACKAGE_VER_MISMATCH 0x2 + pkg_t *pkg_find(const char *name, unsigned int flags); void pkg_traverse(pkg_t *root, void (*pkg_traverse_func)(pkg_t *package, void *data), void *data, int maxdepth, unsigned int flags); void pkg_verify_graph(pkg_t *root, int depth, unsigned int flags); int pkg_compare_version(const char *a, const char *b); -pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags); +pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags); const char *pkg_get_comparator(pkg_dependency_t *pkgdep); /* parse.c */