From 2b5d3bb8f4676afe9dee4eef13858c3c5088716c Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 7 Feb 2013 18:50:55 +0100 Subject: [PATCH] libxbps: when resolving deps, ignore all of them that depend on the origin pkg. --- NEWS | 3 +++ include/xbps_api.h.in | 2 +- lib/rindex_pkgdeps.c | 18 +++++++++++++++++- lib/transaction_sortdeps.c | 7 ++++++- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 43659d40..adcb3eda 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ xbps-0.21 (???): + * libxbps: when resolving deps in transaction, ignore incorrect ones; + for example a package might be depending on itself thru virtual packages. + * configure: don't link to libs in PREFIX/lib blindly; figure out sysroot dir with gcc compiler and use this for headers/libs. diff --git a/include/xbps_api.h.in b/include/xbps_api.h.in index c59fd226..0353878d 100644 --- a/include/xbps_api.h.in +++ b/include/xbps_api.h.in @@ -64,7 +64,7 @@ */ #define XBPS_PKGINDEX_VERSION "1.6" -#define XBPS_API_VERSION "20130207" +#define XBPS_API_VERSION "20130207-1" #ifndef XBPS_VERSION #define XBPS_VERSION "UNSET" diff --git a/lib/rindex_pkgdeps.c b/lib/rindex_pkgdeps.c index f69749ca..efa19c48 100644 --- a/lib/rindex_pkgdeps.c +++ b/lib/rindex_pkgdeps.c @@ -158,7 +158,7 @@ find_repo_deps(struct xbps_handle *xhp, prop_array_t curpkgrdeps; pkg_state_t state; size_t x; - const char *reqpkg, *pkgver_q, *reason = NULL; + const char *reqpkg, *reqpkgname, *pkgver_q, *reason = NULL; char *pkgname; int rv = 0; @@ -317,6 +317,22 @@ find_repo_deps(struct xbps_handle *xhp, } prop_dictionary_get_cstring_nocopy(curpkgd, "pkgver", &pkgver_q); + prop_dictionary_get_cstring_nocopy(curpkgd, + "pkgname", &reqpkgname); + /* + * Check dependency validity. + */ + pkgname = xbps_pkg_name(curpkg); + assert(pkgname); + if (strcmp(pkgname, reqpkgname) == 0) { + xbps_dbg_printf_append(xhp, "[ignoring wrong dependency " + "%s (depends on itself)]\n", + reqpkg); + free(pkgname); + continue; + } + free(pkgname); + /* * Check if package has matched conflicts. */ diff --git a/lib/transaction_sortdeps.c b/lib/transaction_sortdeps.c index dd346fba..c3aa4bba 100644 --- a/lib/transaction_sortdeps.c +++ b/lib/transaction_sortdeps.c @@ -205,9 +205,14 @@ again: rv = EINVAL; break; } + if ((xbps_match_virtual_pkg_in_dict(curpkgd, str, true)) || + (xbps_match_virtual_pkg_in_dict(curpkgd, str, false))) { + xbps_dbg_printf_append(xhp, "ignore wrong " + "dependency %s (depends on itself)\n", str); + continue; + } prop_dictionary_get_cstring_nocopy(curpkgd, "transaction", &tract); - lpd = pkgdep_alloc(curpkgd, str); if (pdn == NULL) {