pkg: add conflicts graph node verification (issue #13)

feature/tap-sh
William Pitcock 2012-05-11 20:51:13 -05:00
parent 948e219075
commit 6c1ace0aa7
2 changed files with 39 additions and 0 deletions

38
pkg.c
View File

@ -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;

1
pkg.h
View File

@ -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);