Use best pkg available when resolving required dependencies.

This commit is contained in:
Juan RP 2012-03-28 12:01:59 +02:00
parent af593500c3
commit a5f4848d0b
3 changed files with 23 additions and 3 deletions

3
NEWS
View File

@ -1,5 +1,8 @@
xbps-0.15 (???):
* When resolving required dependencies also find the best pkg
available in repository pool. Thanks to dave for testing!
* Started a test suite for libxbps. Tests are written for Kyua
(http://code.google.com/p/kyua) and can be built and installed
with the --with-tests configure option, by default will be installed

View File

@ -56,7 +56,7 @@
*/
#define XBPS_PKGINDEX_VERSION "1.4"
#define XBPS_API_VERSION "20120324"
#define XBPS_API_VERSION "20120328"
#define XBPS_VERSION "0.15"
/**

View File

@ -38,7 +38,8 @@ store_dependency(prop_dictionary_t transd,
{
const struct xbps_handle *xhp = xbps_handle_get();
prop_array_t array;
const char *pkgname, *pkgver, *repoloc;
prop_dictionary_t curpkgd;
const char *pkgname, *pkgver, *repoloc, *curpkgver;
size_t x;
int rv = 0;
@ -50,6 +51,21 @@ store_dependency(prop_dictionary_t transd,
prop_dictionary_get_cstring_nocopy(repo_pkgd, "pkgname", &pkgname);
prop_dictionary_get_cstring_nocopy(repo_pkgd, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(repo_pkgd, "repository", &repoloc);
/*
* Check if same pkg is already in transaction, and if current pkg version
* is greater add it, otherwise drop it.
*/
curpkgd = xbps_find_pkg_in_dict_by_name(transd, "unsorted_deps", pkgname);
if (curpkgd != NULL) {
prop_dictionary_get_cstring_nocopy(curpkgd, "pkgver", &curpkgver);
rv = xbps_cmpver(pkgver, curpkgver);
if (rv == 1) {
xbps_remove_pkg_from_dict_by_name(transd,
"unsorted_deps", pkgname);
xbps_dbg_printf("%s: found pkg `%s' in transaction, replaced by `%s'.\n",
__func__, curpkgver, pkgver);
}
}
/*
* Overwrite package state in dictionary with same state than the
* package currently uses, otherwise not-installed.
@ -61,6 +77,7 @@ store_dependency(prop_dictionary_t transd,
*/
if (!prop_dictionary_set_bool(repo_pkgd, "automatic-install", true))
return errno;
/*
* Add the dictionary into the array.
*/
@ -372,7 +389,7 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
curpkgd = xbps_repository_pool_find_virtualpkg(reqpkg, true);
if (curpkgd == NULL) {
curpkgd = xbps_repository_pool_find_pkg(reqpkg, true,
false);
true);
if (curpkgd == NULL) {
/* pkg not found, there was some error */
if (errno && errno != ENOENT) {