diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-08-06 14:25:03 +0300 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-08-06 14:25:03 +0300 |
commit | ecdacd15032578148489f868fd928fb502032c60 (patch) | |
tree | e8ad3d487b60017f3f4975d09bbeac4a77b8d0b7 /src/upgrade.c | |
parent | fac43e2d60b550425481052e521d141730a303de (diff) | |
download | apk-tools-ecdacd15032578148489f868fd928fb502032c60.tar.gz apk-tools-ecdacd15032578148489f868fd928fb502032c60.tar.bz2 apk-tools-ecdacd15032578148489f868fd928fb502032c60.tar.xz apk-tools-ecdacd15032578148489f868fd928fb502032c60.zip |
all: implement database open options
so user can override trusted keys directory and repositories file.
Diffstat (limited to 'src/upgrade.c')
-rw-r--r-- | src/upgrade.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/upgrade.c b/src/upgrade.c index 333035f..f91e8cc 100644 --- a/src/upgrade.c +++ b/src/upgrade.c @@ -16,7 +16,8 @@ #include "apk_database.h" #include "apk_state.h" -static int upgrade_parse(void *ctx, int optch, int optindex, const char *optarg) +static int upgrade_parse(void *ctx, struct apk_db_options *dbopts, + int optch, int optindex, const char *optarg) { switch (optch) { case 'a': @@ -28,35 +29,29 @@ static int upgrade_parse(void *ctx, int optch, int optindex, const char *optarg) return 0; } -static int upgrade_main(void *ctx, int argc, char **argv) +static int upgrade_main(void *ctx, struct apk_database *db, int argc, char **argv) { - struct apk_database db; struct apk_state *state = NULL; - int i, r; + int i, r = 0; apk_flags |= APK_UPGRADE; - r = apk_db_open(&db, apk_root, APK_OPENF_WRITE); - if (r != 0) - return r; - - state = apk_state_new(&db); + 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]); + 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 upgrade '%s'", - db.world->item[i].name->name); + db->world->item[i].name->name); goto err; } } - r = apk_state_commit(state, &db); + r = apk_state_commit(state, db); err: if (state != NULL) apk_state_unref(state); - apk_db_close(&db); return r; } @@ -70,6 +65,7 @@ static struct apk_applet apk_upgrade = { .name = "upgrade", .help = "Upgrade (or downgrade with -a) the currently installed " "packages to versions available in repositories.", + .open_flags = APK_OPENF_WRITE, .num_options = ARRAY_SIZE(upgrade_options), .options = upgrade_options, .parse = upgrade_parse, |