summaryrefslogtreecommitdiff
path: root/src/del.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2011-09-09 16:31:11 +0300
committerTimo Teräs <timo.teras@iki.fi>2011-09-09 16:32:31 +0300
commita5a7021658212748e9f787ce23181d3e099aba73 (patch)
tree459384995fc52f096007c3ed4d8d88ca865f998c /src/del.c
parent0e24207c2e4fedb9c0656ed98bc37cd37df44d91 (diff)
downloadapk-tools-a5a7021658212748e9f787ce23181d3e099aba73.tar.gz
apk-tools-a5a7021658212748e9f787ce23181d3e099aba73.tar.bz2
apk-tools-a5a7021658212748e9f787ce23181d3e099aba73.tar.xz
apk-tools-a5a7021658212748e9f787ce23181d3e099aba73.zip
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.
Diffstat (limited to 'src/del.c')
-rw-r--r--src/del.c38
1 files changed, 7 insertions, 31 deletions
diff --git a/src/del.c b/src/del.c
index 4c00ade..cbf0686 100644
--- a/src/del.c
+++ b/src/del.c
@@ -11,17 +11,16 @@
#include <stdio.h>
#include "apk_applet.h"
-#include "apk_state.h"
#include "apk_database.h"
#include "apk_print.h"
+#include "apk_solver.h"
static int del_parse(void *ctx, struct apk_db_options *db,
int optch, int optindex, const char *optarg)
{
switch (optch) {
case 'r':
- apk_flags |= APK_RECURSIVE_DELETE;
- break;
+ /* FIXME: Reimplement recursive delete. */
default:
return -1;
}
@@ -30,40 +29,17 @@ static int del_parse(void *ctx, struct apk_db_options *db,
static int del_main(void *ctx, struct apk_database *db, int argc, char **argv)
{
- struct apk_state *state;
struct apk_name *name;
+ struct apk_dependency_array *world = NULL;
int i, r = 0;
+ apk_dependency_array_copy(&world, db->world);
for (i = 0; i < argc; i++) {
name = apk_db_get_name(db, APK_BLOB_STR(argv[i]));
- name->flags &= ~APK_NAME_TOPLEVEL;
- name->flags |= APK_NAME_TOPLEVEL_OVERRIDE;
- apk_deps_del(&db->world, name);
+ apk_deps_del(&world, name);
}
-
- state = apk_state_new(db);
- if (state == NULL)
- goto err;
-
- for (i = 0; i < argc; i++) {
- struct apk_dependency dep;
-
- name = apk_db_get_name(db, APK_BLOB_STR(argv[i]));
- dep = (struct apk_dependency) {
- .name = name,
- .version = apk_blob_atomize(APK_BLOB_NULL),
- .result_mask = APK_DEPMASK_CONFLICT,
- };
-
- r |= apk_state_lock_dependency(state, &dep);
- }
- if (r == 0)
- r = apk_state_commit(state);
- else
- apk_state_print_errors(state);
-err:
- if (state != NULL)
- apk_state_unref(state);
+ r = apk_solver_commit(db, 0, world);
+ apk_dependency_array_free(&world);
return r;
}