Fix and improve when there are missing deps in the transaction dictionary.

This commit is contained in:
Juan RP
2010-11-23 23:17:04 +01:00
parent 99f3d846de
commit d2be842ce5
5 changed files with 23 additions and 11 deletions

View File

@@ -612,10 +612,11 @@ xbps_exec_transaction(bool yes)
trans->dict = xbps_repository_get_transaction_dict(); trans->dict = xbps_repository_get_transaction_dict();
if (trans->dict == NULL) { if (trans->dict == NULL) {
rv = errno; xbps_dbg_printf("Empty transaction dictionary: %s\n",
strerror(errno));
goto out; goto out;
} }
if (rv == ENOENT) { if (errno == ENOENT) {
/* /*
* Bail out if there are unresolved deps. * Bail out if there are unresolved deps.
*/ */

View File

@@ -75,8 +75,9 @@ xbps_regpkgdb_dictionary_get(void)
regpkgdb_dict = prop_dictionary_internalize_from_zfile(plist); regpkgdb_dict = prop_dictionary_internalize_from_zfile(plist);
if (regpkgdb_dict == NULL) { if (regpkgdb_dict == NULL) {
free(plist); free(plist);
xbps_dbg_printf("[regpkgdb] cannot internalize " if (errno != ENOENT)
"regpkgdb_dict %s\n", strerror(errno)); xbps_dbg_printf("[regpkgdb] cannot internalize "
"regpkgdb_dict %s\n", strerror(errno));
return NULL; return NULL;
} }
free(plist); free(plist);

View File

@@ -113,6 +113,7 @@ add_missing_reqdep(prop_dictionary_t trans_dict, const char *reqpkg)
prop_object_t obj; prop_object_t obj;
size_t idx = 0; size_t idx = 0;
bool add_pkgdep, pkgfound, update_pkgdep; bool add_pkgdep, pkgfound, update_pkgdep;
int rv = 0;
assert(trans_dict != NULL); assert(trans_dict != NULL);
assert(reqpkg != NULL); assert(reqpkg != NULL);
@@ -148,6 +149,12 @@ add_missing_reqdep(prop_dictionary_t trans_dict, const char *reqpkg)
} }
if (strcmp(pkgnamedep, curpkgnamedep) == 0) { if (strcmp(pkgnamedep, curpkgnamedep) == 0) {
pkgfound = true; pkgfound = true;
if (strcmp(curver, pkgver) == 0) {
free(curpkgnamedep);
free(pkgnamedep);
rv = EEXIST;
goto out;
}
/* /*
* if new dependency version is greater than current * if new dependency version is greater than current
* one, store it. * one, store it.
@@ -158,6 +165,7 @@ add_missing_reqdep(prop_dictionary_t trans_dict, const char *reqpkg)
add_pkgdep = false; add_pkgdep = false;
free(curpkgnamedep); free(curpkgnamedep);
free(pkgnamedep); free(pkgnamedep);
rv = EEXIST;
goto out; goto out;
} }
update_pkgdep = true; update_pkgdep = true;
@@ -180,7 +188,7 @@ out:
return errno; return errno;
} }
return 0; return rv;
} }
static int static int

View File

@@ -213,18 +213,17 @@ xbps_repository_get_transaction_dict(void)
* return the dictionary, the client should always * return the dictionary, the client should always
* check if that's the case. * check if that's the case.
*/ */
if (rv == ENOENT) return trans_dict;
return trans_dict;
return NULL;
} }
/* /*
* Add total transaction installed/download sizes * Add total transaction installed/download sizes
* to the transaction dictionary. * to the transaction dictionary.
*/ */
if (compute_transaction_sizes() != 0) if ((rv = compute_transaction_sizes()) != 0) {
errno = rv;
return NULL; return NULL;
}
/* /*
* Remove the "missing_deps" array now that it's not needed. * Remove the "missing_deps" array now that it's not needed.

View File

@@ -74,8 +74,11 @@ xbps_sort_pkg_deps(prop_dictionary_t chaindeps)
* If there are missing dependencies, bail out. * If there are missing dependencies, bail out.
*/ */
missingdeps = prop_dictionary_get(chaindeps, "missing_deps"); missingdeps = prop_dictionary_get(chaindeps, "missing_deps");
if (prop_array_count(missingdeps) > 0) if (prop_array_count(missingdeps) > 0) {
xbps_dbg_printf("missing dependencies! won't "
"continue sorting\n");
return ENOENT; return ENOENT;
}
sorted = prop_array_create(); sorted = prop_array_create();
if (sorted == NULL) if (sorted == NULL)