cli: fix --modversion not showing version in various cases

There are numerous edge cases where version is wrong or missing when
matching the dependency queue to resolved packages. This adds the
dependency name as it appears in the dependency queue to each package as
it is resolved, allowing for a simple and correct comparison when
printing.

Signed-off-by: Colin Gillespie <colin@cgillespie.xyz>
Colin Gillespie 2023-08-19 07:57:48 +10:00 committed by Ariadne Conill
parent 9cddd22bbc
commit 66994f1533
3 changed files with 23 additions and 12 deletions

View File

@ -306,7 +306,7 @@ apply_modversion(pkgconf_client_t *client, pkgconf_pkg_t *world, void *data, int
pkgconf_dependency_t *dep = world_iter->data;
pkgconf_pkg_t *pkg = dep->match;
if (strncmp(pkg->id, queue_node->package, strlen(pkg->id)))
if (strcmp(pkg->why, queue_node->package))
continue;
if (pkg->version != NULL) {
@ -315,6 +315,8 @@ apply_modversion(pkgconf_client_t *client, pkgconf_pkg_t *world, void *data, int
printf("%s\n", pkg->version);
}
break;
}
}

View File

@ -149,6 +149,7 @@ struct pkgconf_pkg_ {
char *license;
char *maintainer;
char *copyright;
char *why;
pkgconf_list_t libs;
pkgconf_list_t libs_private;

View File

@ -546,6 +546,9 @@ pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
if (pkg->copyright != NULL)
free(pkg->copyright);
if (pkg->why != NULL)
free(pkg->why);
free(pkg);
}
@ -1398,19 +1401,24 @@ pkgconf_pkg_verify_dependency(pkgconf_client_t *client, pkgconf_dependency_t *pk
return NULL;
}
return pkgconf_pkg_scan_providers(client, pkgdep, eflags);
}
if (pkg->id == NULL)
pkg->id = strdup(pkgdep->package);
if (pkgconf_pkg_comparator_impls[pkgdep->compare](pkg->version, pkgdep->version) != true)
{
if (eflags != NULL)
*eflags |= PKGCONF_PKG_ERRF_PACKAGE_VER_MISMATCH;
pkg = pkgconf_pkg_scan_providers(client, pkgdep, eflags);
}
else
pkgdep->match = pkgconf_pkg_ref(client, pkg);
{
if (pkg->id == NULL)
pkg->id = strdup(pkgdep->package);
if (pkgconf_pkg_comparator_impls[pkgdep->compare](pkg->version, pkgdep->version) != true)
{
if (eflags != NULL)
*eflags |= PKGCONF_PKG_ERRF_PACKAGE_VER_MISMATCH;
}
else
pkgdep->match = pkgconf_pkg_ref(client, pkg);
}
if (pkg != NULL)
pkg->why = strdup(pkgdep->package);
return pkg;
}