diff --git a/pkg.c b/pkg.c index 2b48f30..c03256e 100644 --- a/pkg.c +++ b/pkg.c @@ -610,6 +610,37 @@ pkg_walk_list(pkg_dependency_t *deplist, return eflags; } +static inline unsigned int +pkg_walk_conflicts_list(pkg_t *root, pkg_dependency_t *deplist, unsigned int flags) +{ + unsigned int eflags; + pkg_dependency_t *node; + + PKG_FOREACH_LIST_ENTRY(deplist, node) + { + pkg_t *pkgdep; + + if (*node->package == '\0') + continue; + + pkgdep = pkg_verify_dependency(node, flags, &eflags); + if (eflags == PKG_ERRF_OK) + { + fprintf(stderr, "Version '%s' of '%s' conflicts with '%s' due to satisfying conflict rule '%s %s%s%s'.\n", + pkgdep->version, pkgdep->realname, root->realname, node->package, pkg_get_comparator(node), + node->version != NULL ? " " : "", node->version != NULL ? node->version : ""); + fprintf(stderr, "It may be possible to ignore this conflict and continue, try the\n"); + fprintf(stderr, "PKG_CONFIG_IGNORE_CONFLICTS environment variable.\n"); + } + + pkg_free(pkgdep); + + return PKG_ERRF_PACKAGE_CONFLICT; + } + + return PKG_ERRF_OK; +} + /* * pkg_traverse(root, func, data, maxdepth, flags) * @@ -628,6 +659,13 @@ pkg_traverse(pkg_t *root, if (maxdepth == 0) return eflags; + if (!(flags & PKGF_SKIP_CONFLICTS)) + { + eflags = pkg_walk_conflicts_list(root, root->conflicts, rflags); + if (eflags != PKG_ERRF_OK) + return eflags; + } + eflags = pkg_walk_list(root->requires, func, data, maxdepth, rflags); if (eflags != PKG_ERRF_OK) return eflags; diff --git a/pkg.h b/pkg.h index cb9168f..ecea1d7 100644 --- a/pkg.h +++ b/pkg.h @@ -122,6 +122,7 @@ struct pkg_ { #define PKG_ERRF_OK 0x0 #define PKG_ERRF_PACKAGE_NOT_FOUND 0x1 #define PKG_ERRF_PACKAGE_VER_MISMATCH 0x2 +#define PKG_ERRF_PACKAGE_CONFLICT 0x4 typedef void (*pkg_traverse_func_t)(pkg_t *pkg, void *data, unsigned int flags);