libxbps: take into account virtual-pkg settings in conf file when updating.

This commit is contained in:
Juan RP 2011-07-08 15:28:57 +02:00
parent ce9bc051e1
commit 5585b98ac6
2 changed files with 50 additions and 10 deletions

View File

@ -129,6 +129,9 @@ repository_find_pkg(const char *pattern, const char *reason)
if (state == XBPS_PKG_STATE_UNPACKED)
reason = "configure";
else if (state == XBPS_PKG_STATE_NOT_INSTALLED)
reason = "install";
/*
* Set transaction obj in pkg dictionary to "install", "configure"
* or "update".

View File

@ -315,8 +315,9 @@ repo_find_best_pkg_cb(struct repository_pool_index *rpi,
bool *done)
{
struct repo_pool_fpkg *rpf = arg;
prop_dictionary_t instpkgd;
prop_dictionary_t instpkgd, vpkgd;
const char *instver, *repover;
char *vpattern = NULL;
rpf->pkgd = xbps_find_pkg_in_dict_by_name(rpi->rpi_repod,
"packages", rpf->pattern);
@ -340,24 +341,60 @@ repo_find_best_pkg_cb(struct repository_pool_index *rpi,
"version", &repover);
prop_object_release(instpkgd);
if (xbps_cmpver(repover, instver) > 0) {
xbps_dbg_printf("Found '%s-%s' (installed: %s) "
"in repository '%s'.\n", rpf->pattern, repover,
instver, rpi->rpi_uri);
if (xbps_cmpver(repover, instver) <= 0) {
xbps_dbg_printf("Skipping '%s-%s' (installed: %s) "
"from repository '%s'\n", rpf->pattern, repover, instver,
rpi->rpi_uri);
errno = EEXIST;
return 0;
}
/*
* New package version found, exit from the loop.
* New package version is greater than current installed, but first
* check if this is a virtual package and it's set specifically
* in the configuration file.
*/
prop_dictionary_set_cstring(rpf->pkgd, "repository",
vpattern = xbps_xasprintf("%s>=0", rpf->pattern);
if (vpattern == NULL)
return EINVAL;
vpkgd = xbps_find_virtualpkg_user_in_dict_by_pattern(
rpi->rpi_repod, "packages", vpattern);
if (vpkgd) {
/*
* Virtual package enabled in conf file and new
* version found.
*/
free(vpattern);
prop_dictionary_set_cstring(vpkgd, "repository",
rpi->rpi_uri);
*done = true;
errno = 0;
rpf->pkgfound = true;
return 0;
} else {
/*
* Virtual package not enabled in conf file but it's
* currently proviving the same virtual package that
* we are updating... ignore it.
*/
if (xbps_find_virtual_pkg_in_dict(rpf->pkgd,
vpattern, true)) {
free(vpattern);
return 0;
}
xbps_dbg_printf("Skipping '%s-%s' (installed: %s) "
"from repository '%s'\n", rpf->pattern, repover, instver,
free(vpattern);
}
/*
* New package version found, exit from the loop.
*/
xbps_dbg_printf("Found '%s-%s' (installed: %s) "
"in repository '%s'.\n", rpf->pattern, repover,
instver, rpi->rpi_uri);
prop_dictionary_set_cstring(rpf->pkgd, "repository",
rpi->rpi_uri);
errno = EEXIST;
*done = true;
errno = 0;
rpf->pkgfound = true;
}
return 0;
}