Improve dependency matching via repos and use the "pkgver" object
in pkg dictionary to improve performance in some cases. Bumped XBPS_RELVER to 20091121. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091122041547-oywx4db75j8uttl3
This commit is contained in:
@@ -195,7 +195,7 @@ find_repo_deps(prop_dictionary_t master, prop_dictionary_t repo,
|
||||
prop_array_t curpkg_rdeps;
|
||||
prop_object_t obj;
|
||||
prop_object_iterator_t iter;
|
||||
const char *reqpkg, *reqvers;
|
||||
const char *reqpkg, *reqvers, *pkg_queued;
|
||||
char *pkgname;
|
||||
int rv = 0;
|
||||
|
||||
@@ -217,12 +217,12 @@ find_repo_deps(prop_dictionary_t master, prop_dictionary_t repo,
|
||||
/* There was an error checking it... */
|
||||
break;
|
||||
} else if (rv == 1) {
|
||||
/* pkgdep is satisfied */
|
||||
/* Required pkg dependency is satisfied */
|
||||
DPRINTF(("Dependency %s satisfied.\n", reqpkg));
|
||||
rv = 0;
|
||||
continue;
|
||||
}
|
||||
DPRINTF(("Dependency %s not mached.\n", reqpkg));
|
||||
DPRINTF(("Dependency %s not installed.\n", reqpkg));
|
||||
pkgname = xbps_get_pkgdep_name(reqpkg);
|
||||
if (pkgname == NULL) {
|
||||
rv = EINVAL;
|
||||
@@ -236,12 +236,24 @@ find_repo_deps(prop_dictionary_t master, prop_dictionary_t repo,
|
||||
}
|
||||
/*
|
||||
* Check if package is already added in the
|
||||
* array of unsorted deps.
|
||||
* array of unsorted deps, and check if current required
|
||||
* dependency pattern is matched.
|
||||
*/
|
||||
if (xbps_find_pkg_in_dict(master, "unsorted_deps", pkgname)) {
|
||||
DPRINTF(("Dependency %s already queued.\n", pkgname));
|
||||
free(pkgname);
|
||||
continue;
|
||||
curpkgd = xbps_find_pkg_in_dict(master, "unsorted_deps", pkgname);
|
||||
if (curpkgd) {
|
||||
prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||
"pkgver", &pkg_queued);
|
||||
if (pkg_queued == NULL) {
|
||||
free(pkgname);
|
||||
return errno;
|
||||
}
|
||||
if (xbps_pkgdep_match(pkg_queued, __UNCONST(reqpkg))) {
|
||||
DPRINTF(("Dependency %s already queued.\n",
|
||||
pkgname));
|
||||
free(pkgname);
|
||||
continue;
|
||||
}
|
||||
curpkgd = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -35,7 +35,7 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic)
|
||||
{
|
||||
prop_dictionary_t dict, pkgd;
|
||||
prop_array_t array;
|
||||
const char *pkgname, *version, *desc;
|
||||
const char *pkgname, *version, *desc, *pkgver;
|
||||
char *plist;
|
||||
int rv = 0;
|
||||
|
||||
@@ -47,6 +47,7 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic)
|
||||
prop_dictionary_get_cstring_nocopy(pkgrd, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(pkgrd, "version", &version);
|
||||
prop_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc);
|
||||
prop_dictionary_get_cstring_nocopy(pkgrd, "pkgver", &pkgver);
|
||||
|
||||
dict = prop_dictionary_internalize_from_file(plist);
|
||||
if (dict != NULL) {
|
||||
@@ -56,6 +57,7 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic)
|
||||
goto out;
|
||||
}
|
||||
prop_dictionary_set_cstring_nocopy(pkgd, "version", version);
|
||||
prop_dictionary_set_cstring_nocopy(pkgd, "pkgver", pkgver);
|
||||
prop_dictionary_set_cstring_nocopy(pkgd, "short_desc", desc);
|
||||
prop_dictionary_set_bool(pkgd, "automatic-install", automatic);
|
||||
|
||||
|
||||
@@ -153,27 +153,19 @@ xbps_requiredby_pkg_add(prop_array_t regar, prop_dictionary_t pkg)
|
||||
prop_array_t rdeps;
|
||||
prop_object_t obj, obj2;
|
||||
prop_object_iterator_t iter, iter2;
|
||||
const char *reqname, *pkgname, *version, *str;
|
||||
char *rdepname, *fpkgn;
|
||||
const char *reqname, *pkgver, *str;
|
||||
char *rdepname;
|
||||
int rv = 0;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(pkg, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(pkg, "version", &version);
|
||||
fpkgn = xbps_xasprintf("%s-%s", pkgname, version);
|
||||
if (fpkgn == NULL)
|
||||
return ENOMEM;
|
||||
prop_dictionary_get_cstring_nocopy(pkg, "pkgver", &pkgver);
|
||||
|
||||
rdeps = prop_dictionary_get(pkg, "run_depends");
|
||||
if (rdeps == NULL || prop_array_count(rdeps) == 0) {
|
||||
free(fpkgn);
|
||||
if (rdeps == NULL || prop_array_count(rdeps) == 0)
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
iter = prop_array_iterator(rdeps);
|
||||
if (iter == NULL) {
|
||||
free(fpkgn);
|
||||
if (iter == NULL)
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
str = prop_string_cstring_nocopy(obj);
|
||||
@@ -193,7 +185,7 @@ xbps_requiredby_pkg_add(prop_array_t regar, prop_dictionary_t pkg)
|
||||
prop_dictionary_get_cstring_nocopy(obj2, "pkgname",
|
||||
&reqname);
|
||||
if (strcmp(rdepname, reqname) == 0) {
|
||||
rv = add_pkg_into_reqby(obj2, fpkgn);
|
||||
rv = add_pkg_into_reqby(obj2, pkgver);
|
||||
if (rv == EEXIST)
|
||||
continue;
|
||||
else if (rv != 0) {
|
||||
@@ -209,7 +201,6 @@ xbps_requiredby_pkg_add(prop_array_t regar, prop_dictionary_t pkg)
|
||||
}
|
||||
|
||||
out:
|
||||
free(fpkgn);
|
||||
prop_object_iterator_release(iter);
|
||||
|
||||
return rv;
|
||||
|
||||
26
lib/util.c
26
lib/util.c
@@ -115,8 +115,8 @@ int SYMEXPORT
|
||||
xbps_check_is_installed_pkg(const char *pkg)
|
||||
{
|
||||
prop_dictionary_t dict;
|
||||
const char *instver;
|
||||
char *pkgname, *instpkg;
|
||||
const char *instpkgver;
|
||||
char *pkgname;
|
||||
int rv = 0;
|
||||
pkg_state_t state = 0;
|
||||
|
||||
@@ -146,18 +146,15 @@ xbps_check_is_installed_pkg(const char *pkg)
|
||||
free(pkgname);
|
||||
return 0; /* not fully installed */
|
||||
}
|
||||
|
||||
/* Get version from installed package */
|
||||
prop_dictionary_get_cstring_nocopy(dict, "version", &instver);
|
||||
instpkg = xbps_xasprintf("%s-%s", pkgname, instver);
|
||||
free(pkgname);
|
||||
if (instpkg == NULL) {
|
||||
|
||||
instpkgver = xbps_get_pkgver_from_dict(dict);
|
||||
if (instpkgver == NULL) {
|
||||
prop_object_release(dict);
|
||||
return -1;
|
||||
}
|
||||
/* Check if installed pkg is matched against pkgdep pattern */
|
||||
rv = xbps_pkgdep_match(instpkg, __UNCONST(pkg));
|
||||
free(instpkg);
|
||||
rv = xbps_pkgdep_match(instpkgver, __UNCONST(pkg));
|
||||
prop_object_release(dict);
|
||||
|
||||
return rv;
|
||||
@@ -269,6 +266,17 @@ xbps_get_pkgdep_version(const char *pkg)
|
||||
return res;
|
||||
}
|
||||
|
||||
const char SYMEXPORT *
|
||||
xbps_get_pkgver_from_dict(prop_dictionary_t d)
|
||||
{
|
||||
const char *pkgver;
|
||||
|
||||
assert(d != NULL);
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver);
|
||||
return pkgver;
|
||||
}
|
||||
|
||||
static char *
|
||||
get_pkg_index_remote_plist(const char *uri, const char *machine)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user