From a5a7021658212748e9f787ce23181d3e099aba73 Mon Sep 17 00:00:00 2001 From: Timo Teräs Date: Fri, 9 Sep 2011 16:31:11 +0300 Subject: applets: start using solver code still todo: - 'fix' is missing - 'del -R' does not work - 'upgrade' does not do self-upgrade first ... and a lot of testing. --- src/cache.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'src/cache.c') diff --git a/src/cache.c b/src/cache.c index ac1fba7..cf468fd 100644 --- a/src/cache.c +++ b/src/cache.c @@ -17,36 +17,30 @@ #include "apk_defines.h" #include "apk_applet.h" #include "apk_database.h" -#include "apk_state.h" #include "apk_package.h" #include "apk_print.h" +#include "apk_solver.h" #define CACHE_CLEAN BIT(0) #define CACHE_DOWNLOAD BIT(1) static int cache_download(struct apk_database *db) { - struct apk_state *state; + struct apk_changeset changeset; struct apk_change *change; struct apk_package *pkg; struct apk_repository *repo; char item[PATH_MAX], cacheitem[PATH_MAX]; int i, r = 0; - state = apk_state_new(db); - if (state == NULL) - goto err; - - for (i = 0; i < db->world->num; i++) { - r = apk_state_lock_dependency(state, &db->world->item[i]); - if (r != 0) { - apk_error("Unable to select version for '%s': %d", - db->world->item[i].name->name, r); - goto err; - } + r = apk_solver_solve(db, 0, db->world, NULL, &changeset); + if (r != 0) { + apk_error("Unable to select packages. Run apk fix."); + return r; } - list_for_each_entry(change, &state->change_list_head, change_list) { + for (i = 0; i < changeset.changes->num; i++) { + change = &changeset.changes->item[i]; pkg = change->newpkg; apk_pkg_format_cache(pkg, APK_BLOB_BUF(cacheitem)); @@ -63,9 +57,6 @@ static int cache_download(struct apk_database *db) APK_SIGN_VERIFY_IDENTITY); } -err: - if (state != NULL) - apk_state_unref(state); return r; } -- cgit v1.2.3-70-g09d2