pkg: improve conflicts handling

feature/tap-sh
William Pitcock 2012-07-30 02:46:03 -05:00
parent 391dbad713
commit 004adad048
2 changed files with 21 additions and 15 deletions

34
pkg.c
View File

@ -756,30 +756,36 @@ static inline unsigned int
pkg_walk_conflicts_list(pkg_t *root, pkg_dependency_t *deplist, unsigned int flags) pkg_walk_conflicts_list(pkg_t *root, pkg_dependency_t *deplist, unsigned int flags)
{ {
unsigned int eflags; unsigned int eflags;
pkg_dependency_t *node; pkg_dependency_t *node, *depnode;
PKG_FOREACH_LIST_ENTRY(deplist, node) PKG_FOREACH_LIST_ENTRY(deplist, node)
{ {
pkg_t *pkgdep;
if (*node->package == '\0') if (*node->package == '\0')
continue; continue;
pkgdep = pkg_verify_dependency(node, flags, &eflags); PKG_FOREACH_LIST_ENTRY(root->requires, depnode)
if (eflags == PKG_ERRF_OK)
{ {
fprintf(error_msgout, "Version '%s' of '%s' conflicts with '%s' due to satisfying conflict rule '%s %s%s%s'.\n", pkg_t *pkgdep;
pkgdep->version, pkgdep->realname, root->realname, node->package, pkg_get_comparator(node),
node->version != NULL ? " " : "", node->version != NULL ? node->version : ""); if (*depnode->package == '\0' || strcmp(depnode->package, node->package))
fprintf(error_msgout, "It may be possible to ignore this conflict and continue, try the\n"); continue;
fprintf(error_msgout, "PKG_CONFIG_IGNORE_CONFLICTS environment variable.\n");
pkgdep = pkg_verify_dependency(node, flags, &eflags);
if (eflags == PKG_ERRF_OK)
{
fprintf(error_msgout, "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(error_msgout, "It may be possible to ignore this conflict and continue, try the\n");
fprintf(error_msgout, "PKG_CONFIG_IGNORE_CONFLICTS environment variable.\n");
pkg_free(pkgdep);
return PKG_ERRF_PACKAGE_CONFLICT;
}
pkg_free(pkgdep); pkg_free(pkgdep);
return PKG_ERRF_PACKAGE_CONFLICT;
} }
pkg_free(pkgdep);
} }
return PKG_ERRF_OK; return PKG_ERRF_OK;

View File

@ -129,7 +129,7 @@ run_test "PKG_CONFIG_PATH=${selfdir}/lib1 PKG_CONFIG_SYSROOT_DIR=/test ${1} --cf
# 8) tests for 'Conflicts' # 8) tests for 'Conflicts'
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --libs conflicts; echo \$?" \ run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --libs conflicts; echo \$?" \
'1' '0'
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --ignore-conflicts --libs conflicts; echo \$?" \ run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --ignore-conflicts --libs conflicts; echo \$?" \
'-lconflicts' '0' '-lconflicts' '0'