Faster generation of dynamic reverse dependencies and do this exactly once.
This commit is contained in:
parent
e2176ec4b6
commit
22adf99e40
@ -64,7 +64,7 @@
|
|||||||
*/
|
*/
|
||||||
#define XBPS_PKGINDEX_VERSION "1.6"
|
#define XBPS_PKGINDEX_VERSION "1.6"
|
||||||
|
|
||||||
#define XBPS_API_VERSION "20121207"
|
#define XBPS_API_VERSION "20121215"
|
||||||
|
|
||||||
#ifndef XBPS_VERSION
|
#ifndef XBPS_VERSION
|
||||||
#define XBPS_VERSION "UNSET"
|
#define XBPS_VERSION "UNSET"
|
||||||
@ -498,6 +498,13 @@ struct xbps_handle {
|
|||||||
* Proplib dictionary with pkg metafiles.
|
* Proplib dictionary with pkg metafiles.
|
||||||
*/
|
*/
|
||||||
prop_dictionary_t pkg_metad;
|
prop_dictionary_t pkg_metad;
|
||||||
|
/**
|
||||||
|
* @private pkgdb_revdeps.
|
||||||
|
*
|
||||||
|
* Proplib dictionary with full reverse dependencies from pkgdb.
|
||||||
|
*/
|
||||||
|
prop_dictionary_t pkgdb_revdeps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var transd;
|
* @var transd;
|
||||||
*
|
*
|
||||||
|
@ -289,6 +289,8 @@ xbps_end(struct xbps_handle *xhp)
|
|||||||
xbps_pkgdb_release(xhp);
|
xbps_pkgdb_release(xhp);
|
||||||
xbps_rpool_release(xhp);
|
xbps_rpool_release(xhp);
|
||||||
xbps_fetch_unset_cache_connection();
|
xbps_fetch_unset_cache_connection();
|
||||||
|
if (xhp->pkgdb_revdeps != NULL)
|
||||||
|
prop_object_release(xhp->pkgdb_revdeps);
|
||||||
|
|
||||||
cfg_free(xhp->cfg);
|
cfg_free(xhp->cfg);
|
||||||
free(xhp->cachedir_priv);
|
free(xhp->cachedir_priv);
|
||||||
|
71
lib/pkgdb.c
71
lib/pkgdb.c
@ -217,53 +217,80 @@ get_pkg_metadata(struct xbps_handle *xhp, prop_dictionary_t pkgd)
|
|||||||
return pkg_metad;
|
return pkg_metad;
|
||||||
}
|
}
|
||||||
|
|
||||||
prop_array_t
|
static void
|
||||||
xbps_pkgdb_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
|
generate_full_revdeps_tree(struct xbps_handle *xhp)
|
||||||
{
|
{
|
||||||
prop_array_t rundeps, provides, result = NULL;
|
prop_array_t rundeps, pkg;
|
||||||
prop_dictionary_t pkgd, pkgdep_metad;
|
prop_dictionary_t pkgmetad;
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
prop_object_iterator_t iter;
|
prop_object_iterator_t iter;
|
||||||
const char *pkgver, *curpkgver;
|
const char *pkgver, *pkgdep, *vpkgname;
|
||||||
|
char *curpkgname;
|
||||||
|
unsigned int i;
|
||||||
|
bool alloc;
|
||||||
|
|
||||||
if ((pkgd = xbps_pkgdb_get_pkg(xhp, pkg)) == NULL)
|
if (xhp->pkgdb_revdeps)
|
||||||
return NULL;
|
return;
|
||||||
|
|
||||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
xhp->pkgdb_revdeps = prop_dictionary_create();
|
||||||
provides = prop_dictionary_get(pkgd, "provides");
|
|
||||||
|
|
||||||
iter = prop_array_iterator(xhp->pkgdb);
|
iter = prop_array_iterator(xhp->pkgdb);
|
||||||
assert(iter);
|
assert(iter);
|
||||||
|
|
||||||
while ((obj = prop_object_iterator_next(iter))) {
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &curpkgver);
|
|
||||||
/*
|
/*
|
||||||
* If run_depends is in pkgdb use it, otherwise fallback to
|
* If run_depends is in pkgdb use it, otherwise fallback to
|
||||||
* the slower pkg metadata method.
|
* the slower pkg metadata method.
|
||||||
*/
|
*/
|
||||||
rundeps = prop_dictionary_get(obj, "run_depends");
|
rundeps = prop_dictionary_get(obj, "run_depends");
|
||||||
if (rundeps == NULL) {
|
if (rundeps == NULL) {
|
||||||
pkgdep_metad = get_pkg_metadata(xhp, obj);
|
pkgmetad = get_pkg_metadata(xhp, obj);
|
||||||
assert(pkgdep_metad);
|
assert(pkgmetad);
|
||||||
rundeps = prop_dictionary_get(pkgdep_metad,
|
rundeps = prop_dictionary_get(pkgmetad, "run_depends");
|
||||||
"run_depends");
|
|
||||||
}
|
}
|
||||||
if (rundeps == NULL || !prop_array_count(rundeps))
|
if (rundeps == NULL || !prop_array_count(rundeps))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (xbps_match_pkgdep_in_array(rundeps, pkgver) ||
|
for (i = 0; i < prop_array_count(rundeps); i++) {
|
||||||
(provides &&
|
alloc = false;
|
||||||
xbps_match_any_virtualpkg_in_rundeps(rundeps, provides))) {
|
prop_array_get_cstring_nocopy(rundeps, i, &pkgdep);
|
||||||
if (result == NULL)
|
curpkgname = xbps_pkgpattern_name(pkgdep);
|
||||||
result = prop_array_create();
|
if (curpkgname == NULL)
|
||||||
|
curpkgname = xbps_pkg_name(pkgdep);
|
||||||
|
assert(curpkgname);
|
||||||
|
vpkgname = vpkg_user_conf(xhp, curpkgname, false);
|
||||||
|
if (vpkgname == NULL)
|
||||||
|
vpkgname = curpkgname;
|
||||||
|
|
||||||
if (!xbps_match_string_in_array(result, curpkgver))
|
pkg = prop_dictionary_get(xhp->pkgdb_revdeps, vpkgname);
|
||||||
prop_array_add_cstring_nocopy(result, curpkgver);
|
if (pkg == NULL) {
|
||||||
|
alloc = true;
|
||||||
|
pkg = prop_array_create();
|
||||||
|
}
|
||||||
|
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||||
|
prop_array_add_cstring_nocopy(pkg, pkgver);
|
||||||
|
prop_dictionary_set(xhp->pkgdb_revdeps, vpkgname, pkg);
|
||||||
|
free(curpkgname);
|
||||||
|
if (alloc)
|
||||||
|
prop_object_release(pkg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prop_object_iterator_release(iter);
|
prop_object_iterator_release(iter);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
prop_array_t
|
||||||
|
xbps_pkgdb_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
|
||||||
|
{
|
||||||
|
prop_dictionary_t pkgd;
|
||||||
|
const char *pkgname;
|
||||||
|
|
||||||
|
if ((pkgd = xbps_pkgdb_get_pkg(xhp, pkg)) == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
generate_full_revdeps_tree(xhp);
|
||||||
|
prop_dictionary_get_cstring_nocopy(pkgd, "pkgname", &pkgname);
|
||||||
|
|
||||||
|
return prop_dictionary_get(xhp->pkgdb_revdeps, pkgname);
|
||||||
}
|
}
|
||||||
|
|
||||||
prop_dictionary_t
|
prop_dictionary_t
|
||||||
|
Loading…
Reference in New Issue
Block a user