From 004adad0482bc9693587cd8c00791451a5fff9bd Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 30 Jul 2012 02:46:03 -0500 Subject: [PATCH] pkg: improve conflicts handling --- pkg.c | 34 ++++++++++++++++++++-------------- tests/run.sh.in | 2 +- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/pkg.c b/pkg.c index 5cf1284..820a9ca 100644 --- a/pkg.c +++ b/pkg.c @@ -756,30 +756,36 @@ 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_dependency_t *node, *depnode; 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) + PKG_FOREACH_LIST_ENTRY(root->requires, depnode) { - 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_t *pkgdep; + + if (*depnode->package == '\0' || strcmp(depnode->package, node->package)) + continue; + + 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); - - return PKG_ERRF_PACKAGE_CONFLICT; } - - pkg_free(pkgdep); } return PKG_ERRF_OK; diff --git a/tests/run.sh.in b/tests/run.sh.in index 4e4f00c..2ad9bce 100644 --- a/tests/run.sh.in +++ b/tests/run.sh.in @@ -129,7 +129,7 @@ run_test "PKG_CONFIG_PATH=${selfdir}/lib1 PKG_CONFIG_SYSROOT_DIR=/test ${1} --cf # 8) tests for 'Conflicts' 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 \$?" \ '-lconflicts' '0'