From 734a2c3c2b46c52482dc487265033f83e314fd93 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 11 Jun 2013 16:18:40 +0200 Subject: [PATCH] xbps-query(8): added support to find revdeps for virtual pkgs in repository mode. --- NEWS | 7 +++++++ bin/xbps-query/show-deps.c | 42 +++++++++++++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 48afd96a..e0a32182 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,12 @@ xbps-0.25 (???): + * xbps-query(8): added support to find reverse dependencies in repository mode + for virtual packages, i.e: + + $ xbps-query -RX xserver-abi-input + xf86-input-evdev-2.8.0_1 + ... + * Use a single zlib compressed file to store repository data `-repodata`. This will allow us to extend repositories with more metadata if needed, and simplifies the API. This is just the starting point to add PGP signatures. diff --git a/bin/xbps-query/show-deps.c b/bin/xbps-query/show-deps.c index f0fdb887..0cd41d5f 100644 --- a/bin/xbps-query/show-deps.c +++ b/bin/xbps-query/show-deps.c @@ -164,8 +164,11 @@ repo_revdeps_cb(struct xbps_repo *repo, void *arg, bool *done) int repo_show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg) { - prop_dictionary_t pkgd; - const char *pkgver; + prop_array_t vdeps; + prop_dictionary_t pkgd = NULL; + const char *pkgver, *vpkg; + unsigned int i; + int rv = 0; if (xbps_pkg_version(pkg)) pkgver = pkg; @@ -173,9 +176,38 @@ repo_show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg) if (((pkgd = xbps_rpool_get_pkg(xhp, pkg)) == NULL) && ((pkgd = xbps_rpool_get_virtualpkg(xhp, pkg)) == NULL)) return ENOENT; - - prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); } + /* + * If pkg is a virtual pkg let's match it instead of the real pkgver. + */ + if (pkgd) { + if ((vdeps = prop_dictionary_get(pkgd, "provides"))) { + for (i = 0; i < prop_array_count(vdeps); i++) { + char *buf, *vpkgn; - return xbps_rpool_foreach(xhp, repo_revdeps_cb, __UNCONST(pkgver)); + prop_array_get_cstring_nocopy(vdeps, i, &vpkg); + if (strchr(vpkg, '_') == NULL) + buf = xbps_xasprintf("%s_1", vpkg); + else + buf = strdup(vpkg); + + vpkgn = xbps_pkg_name(buf); + assert(vpkgn); + free(buf); + if (strcmp(vpkgn, pkg)) { + free(vpkgn); + continue; + } + free(vpkgn); + rv = xbps_rpool_foreach(xhp, repo_revdeps_cb, + __UNCONST(vpkg)); + } + } else { + prop_dictionary_get_cstring_nocopy(pkgd, + "pkgver", &pkgver); + rv = xbps_rpool_foreach(xhp, repo_revdeps_cb, + __UNCONST(pkgver)); + } + } + return rv; }