xbps-query(8): added support to find revdeps for virtual pkgs in repository mode.

This commit is contained in:
Juan RP 2013-06-11 16:18:40 +02:00
parent 99be698979
commit 734a2c3c2b
2 changed files with 44 additions and 5 deletions

7
NEWS
View File

@ -1,5 +1,12 @@
xbps-0.25 (???): 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 `<arch>-repodata`. * Use a single zlib compressed file to store repository data `<arch>-repodata`.
This will allow us to extend repositories with more metadata if needed, and 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. simplifies the API. This is just the starting point to add PGP signatures.

View File

@ -164,8 +164,11 @@ repo_revdeps_cb(struct xbps_repo *repo, void *arg, bool *done)
int int
repo_show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg) repo_show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
{ {
prop_dictionary_t pkgd; prop_array_t vdeps;
const char *pkgver; prop_dictionary_t pkgd = NULL;
const char *pkgver, *vpkg;
unsigned int i;
int rv = 0;
if (xbps_pkg_version(pkg)) if (xbps_pkg_version(pkg))
pkgver = 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) && if (((pkgd = xbps_rpool_get_pkg(xhp, pkg)) == NULL) &&
((pkgd = xbps_rpool_get_virtualpkg(xhp, pkg)) == NULL)) ((pkgd = xbps_rpool_get_virtualpkg(xhp, pkg)) == NULL))
return ENOENT; 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;
} }