libxbps: extend the API, new func: xbps_repository_pool_find_pkg.

prop_dictionary_t xbps_repository_pool_find_pkg(const char *pkg, bool bypattern, bool best)

This function iterates over the repository pool and returns a pkg
dictionary matching its pkgname if "bypattern" is false, otherwise
if "pkg" matches the pkgdep pattern. If "best" is true, it will look
in all repos and will return the newer version, otherwise the first one
that matches the arguments specified.

With this addition supporting many small registered repos is cheap, because
it checks by-package rather than by-package-list. This also helped to removed
some duplicated code and fix some rare bugs.

Bump XBPS_RELVER to 20110118.
This commit is contained in:
Juan RP
2011-01-18 14:44:39 +01:00
parent 1125963da8
commit 503afdd48d
5 changed files with 260 additions and 326 deletions

View File

@ -67,7 +67,6 @@ xbps_sort_pkg_deps(prop_dictionary_t transd)
"continue sorting\n");
return ENOENT;
}
sorted = prop_array_create();
if (sorted == NULL)
return ENOMEM;
@ -79,7 +78,6 @@ xbps_sort_pkg_deps(prop_dictionary_t transd)
rv = EINVAL;
goto out;
}
/*
* All required deps are satisfied (already installed).
*/
@ -205,6 +203,8 @@ again:
* objects than the total number of required dependencies.
*/
if (ndeps != prop_array_count(sorted)) {
xbps_dbg_printf("wrong sorted deps cnt %zu vs %zu\n",
ndeps, prop_array_count(sorted));
rv = EINVAL;
goto out;
}
@ -215,9 +215,10 @@ again:
prop_dictionary_remove(transd, "unsorted_deps");
out:
if (rv != 0) {
if (rv != 0)
prop_dictionary_remove(transd, "packages");
prop_object_release(sorted);
}
prop_object_release(sorted);
return rv;
}