diff options
author | Dan McGee <dan@archlinux.org> | 2011-01-29 12:10:05 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-01-31 09:38:14 -0600 |
commit | 09f9f2433173477c0b0d269203e0f40df0907aa9 (patch) | |
tree | eae68479fe1d80f20b84eb3c01a8def30aeee441 /src/pacman/pacman.c | |
parent | 986edb8bd4308b73ef225a554f13a07c232ead91 (diff) |
Allow both cleanmethod values to be specified at the same time
No reason to disallow this- it allows keeping even more packages around in
the cache. Test cases included for this case and to ensure the default
behavior is preserved.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman/pacman.c')
-rw-r--r-- | src/pacman/pacman.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 45500cfb..21d02107 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -792,6 +792,18 @@ static void option_add_syncfirst(const char *name) { config->syncfirst = alpm_list_add(config->syncfirst, strdup(name)); } +/* helper for being used with setrepeatingoption */ +static void option_add_cleanmethod(const char *value) { + if (strcmp(value, "KeepInstalled") == 0) { + config->cleanmethod |= PM_CLEAN_KEEPINST; + } else if (strcmp(value, "KeepCurrent") == 0) { + config->cleanmethod |= PM_CLEAN_KEEPCUR; + } else { + pm_printf(PM_LOG_ERROR, _("invalid value for 'CleanMethod' : '%s'\n"), + value); + } +} + /** Add repeating options such as NoExtract, NoUpgrade, etc to libalpm * settings. Refactored out of the parseconfig code since all of them did * the exact same thing and duplicated code. @@ -1008,15 +1020,7 @@ static int _parse_options(char *key, char *value) alpm_option_set_fetchcb(download_with_xfercommand); pm_printf(PM_LOG_DEBUG, "config: xfercommand: %s\n", value); } else if (strcmp(key, "CleanMethod") == 0) { - if (strcmp(value, "KeepInstalled") == 0) { - config->cleanmethod = PM_CLEAN_KEEPINST; - } else if (strcmp(value, "KeepCurrent") == 0) { - config->cleanmethod = PM_CLEAN_KEEPCUR; - } else { - pm_printf(PM_LOG_ERROR, _("invalid value for 'CleanMethod' : '%s'\n"), value); - return(1); - } - pm_printf(PM_LOG_DEBUG, "config: cleanmethod: %s\n", value); + setrepeatingoption(value, "CleanMethod", option_add_cleanmethod); } else { pm_printf(PM_LOG_ERROR, _("directive '%s' with a value not recognized\n"), key); return(1); |