Signed-off-by: Benedikt Morbach <benedikt.morbach@googlemail.com> --- doc/pacman.conf.5.txt | 2 ++ src/pacman/sync.c | 4 ++-- src/pacman/util.c | 11 ++++++++--- src/pacman/util.h | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/doc/pacman.conf.5.txt b/doc/pacman.conf.5.txt index 2bfe757..7735a1f 100644 --- a/doc/pacman.conf.5.txt +++ b/doc/pacman.conf.5.txt @@ -162,6 +162,8 @@ Options If set to `Ask`, display a prompt for each target, where the user can select which of the optional dependencies of that target will be installed. Also, the optional dependencies of the targets won't be shown during installation. + The prompt selects none of the optional dependencies by default. + If both values are specified, all optional dependencies are selected by default. *SigLevel =* ...:: Set the default signature verification level. For more information, see diff --git a/src/pacman/sync.c b/src/pacman/sync.c index f073b59..8f2f49f 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -660,7 +660,7 @@ static int process_optdeps(alpm_list_t *dblist, alpm_pkg_t *pkg) goto cleanup; } - if(multiselect_question(array, count)) { + if(multiselect_question(array, count, config->handleoptdeps & PM_OPTDEPS_INSTALL)) { retval = 1; goto cleanup; } @@ -734,7 +734,7 @@ static int process_group(alpm_list_t *dbs, const char *group) ret = 1; goto cleanup; } - if(multiselect_question(array, count)) { + if(multiselect_question(array, count, 1)) { ret = 1; free(array); goto cleanup; diff --git a/src/pacman/util.c b/src/pacman/util.c index 72a78d9..1a8a39d 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1255,11 +1255,12 @@ static int multiselect_parse(char *array, int count, char *response) return 0; } -int multiselect_question(char *array, int count) +int multiselect_question(char *array, int count, int default_state) { char *response, *lastchar; FILE *stream; size_t response_len = 64; + default_state = default_state ? 1 : 0; if(config->noconfirm) { stream = stdout; @@ -1277,10 +1278,14 @@ int multiselect_question(char *array, int count) *lastchar = 1; while(1) { - memset(array, 1, count); + memset(array, default_state, count); fprintf(stream, "\n"); - fprintf(stream, _("Enter a selection (default=all)")); + if(default_state) { + fprintf(stream, _("Enter a selection (default=all)")); + } else { + fprintf(stream, _("Enter a selection (default=none)")); + } fprintf(stream, ": "); fflush(stream); diff --git a/src/pacman/util.h b/src/pacman/util.h index 2e35e84..b505dba 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -69,7 +69,7 @@ void print_packages(const alpm_list_t *packages); void select_display(const alpm_list_t *pkglist); void select_optdep_display(alpm_list_t *optstrings); int select_question(int count); -int multiselect_question(char *array, int count); +int multiselect_question(char *array, int count, int default_state); int yesno(char *fmt, ...); int noyes(char *fmt, ...); int pm_printf(alpm_loglevel_t level, const char *format, ...) __attribute__((format(printf,2,3))); -- 1.7.6.1