xbps-query: fix --fulldeptree with multiple pkgs using vpkgs and non vpkgs.

This commit is contained in:
Juan RP 2014-10-29 09:46:54 +01:00
parent 5dba1108d1
commit 15943d990c

View File

@ -43,6 +43,8 @@ struct pkgdep {
static SLIST_HEAD(pkgdep_head, pkgdep) pkgdep_list =
SLIST_HEAD_INITIALIZER(pkgdep_list);
static xbps_dictionary_t pkgdep_pvmap;
static void
print_rdeps(struct xbps_handle *xhp, xbps_array_t rdeps, bool full, bool repo)
{
@ -53,7 +55,6 @@ print_rdeps(struct xbps_handle *xhp, xbps_array_t rdeps, bool full, bool repo)
for (unsigned int i = 0; i < xbps_array_count(rdeps); i++) {
struct pkgdep *pd;
const char *pkgver;
char *vpkg = NULL;
bool virtual = false, found = false;
xbps_array_get_cstring_nocopy(rdeps, i, &curdep);
@ -83,16 +84,15 @@ print_rdeps(struct xbps_handle *xhp, xbps_array_t rdeps, bool full, bool repo)
p = xbps_pkg_name(curdep);
assert(p);
vpkg = xbps_xasprintf("%s-%s", p, xbps_pkg_version(pkgver));
assert(vpkg);
if (pkgdep_pvmap == NULL)
pkgdep_pvmap = xbps_dictionary_create();
xbps_dictionary_set_cstring_nocopy(pkgdep_pvmap, p, pkgver);
free(p);
}
/* uniquify dependencies, sorting will be done later */
SLIST_FOREACH(pd, &pkgdep_list, pkgdep_entries) {
if (virtual && strcmp(pd->pkg, vpkg) == 0) {
found = true;
break;
} else if (strcmp(pd->pkg, pkgver) == 0) {
if (strcmp(pd->pkg, pkgver) == 0) {
found = true;
break;
}
@ -100,11 +100,7 @@ print_rdeps(struct xbps_handle *xhp, xbps_array_t rdeps, bool full, bool repo)
if (!found) {
pd = malloc(sizeof(*pd));
assert(pd);
if (virtual)
pd->pkg = vpkg;
else
pd->pkg = pkgver;
pd->pkg = pkgver;
pd->rdeps = xbps_array_copy(currdeps);
SLIST_INSERT_HEAD(&pkgdep_list, pd, pkgdep_entries);
//printf("Added %s into the slist\n", pd->pkg);
@ -143,13 +139,21 @@ sort_rdeps(void)
char *pkgname;
xbps_array_get_cstring_nocopy(pd->rdeps, i, &pkgdep);
pkgname = xbps_pkgpattern_name(pkgdep);
if (pkgname == NULL)
if ((pkgname = xbps_pkgpattern_name(pkgdep)) == NULL)
pkgname = xbps_pkg_name(pkgdep);
if (xbps_match_pkgname_in_array(result, pkgname))
assert(pkgname);
if (xbps_match_pkgname_in_array(result, pkgname)) {
mdeps++;
free(pkgname);
continue;
}
if (xbps_dictionary_get(pkgdep_pvmap, pkgname)) {
mdeps++;
free(pkgname);
continue;
}
//printf("%s: missing dep %s\n", pd->pkg, pkgdep);
free(pkgname);
}
if (mdeps == rdeps) {