resolvedeps: return the depmiss info to the frontend in case of failure

This commit is contained in:
Aurelien Foret 2006-01-21 18:28:38 +00:00
parent 2d08e902ef
commit fc8be93314
5 changed files with 26 additions and 9 deletions

View File

@ -354,7 +354,6 @@ extern enum __pmerrno_t {
/* Dependencies */
PM_ERR_UNSATISFIED_DEPS,
PM_ERR_CONFLICTING_DEPS,
PM_ERR_UNRESOLVABLE_DEPS,
PM_ERR_FILE_CONFLICTS,
/* Misc */
PM_ERR_USER_ABORT,

View File

@ -510,7 +510,8 @@ PMList* removedeps(pmdb_t *db, PMList *targs)
*
* make sure *list and *trail are already initialized
*/
int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list, PMList *trail, pmtrans_t *trans)
int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list,
PMList *trail, pmtrans_t *trans, PMList **data)
{
PMList *i, *j;
PMList *targ;
@ -571,7 +572,16 @@ int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list,
if(sync == NULL) {
_alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\" (\"%s\" is not in the package set)",
miss->target, miss->depend.name);
pm_errno = PM_ERR_UNRESOLVABLE_DEPS;
if(data) {
if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
FREELIST(*data);
pm_errno = PM_ERR_MEMORY;
goto error;
}
*miss = *(pmdepmissing_t *)i->data;
*data = pm_list_add(*data, miss);
}
pm_errno = PM_ERR_UNSATISFIED_DEPS;
goto error;
}
if(pkg_isin(sync->name, list)) {
@ -593,7 +603,7 @@ int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list,
}
if(usedep) {
trail = pm_list_add(trail, sync);
if(resolvedeps(local, dbs_sync, sync, list, trail, trans)) {
if(resolvedeps(local, dbs_sync, sync, list, trail, trans, data)) {
goto error;
}
_alpm_log(PM_LOG_DEBUG, "pulling dependency %s (needed by %s)",
@ -601,7 +611,16 @@ int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list,
list = pm_list_add(list, sync);
} else {
_alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\"", miss->target);
pm_errno = PM_ERR_UNRESOLVABLE_DEPS;
if(data) {
if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
FREELIST(*data);
pm_errno = PM_ERR_MEMORY;
goto error;
}
*miss = *(pmdepmissing_t *)i->data;
*data = pm_list_add(*data, miss);
}
pm_errno = PM_ERR_UNSATISFIED_DEPS;
goto error;
}
} else {

View File

@ -43,7 +43,8 @@ PMList *sortbydeps(PMList *targets, int mode);
PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages);
int splitdep(char *depstr, pmdepend_t *depend);
PMList *removedeps(pmdb_t *db, PMList *targs);
int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list, PMList *trail, pmtrans_t *trans);
int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list,
PMList *trail, pmtrans_t *trans, PMList **data);
#endif /* _ALPM_DEPS_H */

View File

@ -102,8 +102,6 @@ char *alpm_strerror(int err)
return "could not satisfy dependencies";
case PM_ERR_CONFLICTING_DEPS:
return "conflicting dependencies";
case PM_ERR_UNRESOLVABLE_DEPS:
return "could not resolve dependencies";
case PM_ERR_FILE_CONFLICTS:
return "conflicting files";
/* Miscellaenous */

View File

@ -376,7 +376,7 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
_alpm_log(PM_LOG_FLOW1, "resolving targets dependencies");
for(i = trans->packages; i; i = i->next) {
pmpkg_t *spkg = ((pmsyncpkg_t *)i->data)->pkg;
if(resolvedeps(db_local, dbs_sync, spkg, list, trail, trans) == -1) {
if(resolvedeps(db_local, dbs_sync, spkg, list, trail, trans, data) == -1) {
/* pm_errno is set by resolvedeps */
goto error;
}