From 3a488564753cee51832b6824128249a99eb4613b Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Thu, 25 Jun 2009 11:09:40 +0300 Subject: upgrade: add --available option That will make the upgrade prefer packages available in repositories. This is good if one want's to downgrade packages by removing an experimental repository. Or to force re-install of locally built vs. repository version when the package version are same, but checksum is different. Fixes #51. --- src/upgrade.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/upgrade.c') diff --git a/src/upgrade.c b/src/upgrade.c index 81a6d45..59a113d 100644 --- a/src/upgrade.c +++ b/src/upgrade.c @@ -16,6 +16,18 @@ #include "apk_database.h" #include "apk_state.h" +static int upgrade_parse(void *ctx, int optch, int optindex, const char *optarg) +{ + switch (optch) { + case 'a': + apk_flags |= APK_PREFER_AVAILABLE; + break; + default: + return -1; + } + return 0; +} + static int upgrade_main(void *ctx, int argc, char **argv) { struct apk_database db; @@ -45,9 +57,16 @@ err: return r; } +static struct option upgrade_options[] = { + { "available", no_argument, NULL, 'a' }, +}; + static struct apk_applet apk_upgrade = { .name = "upgrade", - .usage = "", + .usage = "[-a|--available]", + .num_options = ARRAY_SIZE(upgrade_options), + .options = upgrade_options, + .parse = upgrade_parse, .main = upgrade_main, }; -- cgit v1.2.3