From 4bf13c3d9a58d4f1685401c3569abb40c5649ca3 Mon Sep 17 00:00:00 2001 From: Timo Teräs Date: Fri, 9 Sep 2011 19:41:19 +0300 Subject: del: fix recursive deletion and messages (after solver merge) Deduce the world dependencies to remove locally, and same for the additional messages about packages not deleted. --- src/solver.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/solver.c') diff --git a/src/solver.c b/src/solver.c index 72eb3e1..75575c2 100644 --- a/src/solver.c +++ b/src/solver.c @@ -974,14 +974,17 @@ static int cmp_upgrade(struct apk_change *change) return 0; } -static int commit_changeset(struct apk_database *db, - struct apk_changeset *changeset, - struct apk_dependency_array *world) +int apk_solver_commit_changeset(struct apk_database *db, + struct apk_changeset *changeset, + struct apk_dependency_array *world) { struct progress prog; struct apk_change *change; int i, r = 0, size_diff = 0; + if (changeset->changes == NULL) + goto all_done; + /* Count what needs to be done */ memset(&prog, 0, sizeof(prog)); for (i = 0; i < changeset->changes->num; i++) { @@ -1044,6 +1047,7 @@ static int commit_changeset(struct apk_database *db, apk_db_run_triggers(db); +all_done: apk_dependency_array_copy(&db->world, world); apk_db_write_config(db); @@ -1085,10 +1089,10 @@ static void print_dep_errors(char *label, struct apk_dependency_array *deps) printf("\n"); } -static void print_errors(struct apk_database *db, - struct apk_package_array *solution, - struct apk_dependency_array *world, - int unsatisfiable) +void apk_solver_print_errors(struct apk_database *db, + struct apk_package_array *solution, + struct apk_dependency_array *world, + int unsatisfiable) { int i; @@ -1120,16 +1124,13 @@ int apk_solver_commit(struct apk_database *db, if (r < 0) return r; - if (changeset.changes == NULL) - apk_change_array_init(&changeset.changes); - if (r == 0 || (apk_flags & APK_FORCE)) { /* Success -- or forced installation of bad graph */ - commit_changeset(db, &changeset, world); + apk_solver_commit_changeset(db, &changeset, world); r = 0; } else { /* Failure -- print errors */ - print_errors(db, solution, world, r); + apk_solver_print_errors(db, solution, world, r); } apk_package_array_free(&solution); -- cgit v1.2.3-60-g2f50