[pacman-dev] [PATCH 14/14] Make HandleOptdeps Ask and Install work together better

Benedikt Morbach benedikt.morbach at googlemail.com
Wed Nov 23 10:51:28 EST 2011


Signed-off-by: Benedikt Morbach <benedikt.morbach at googlemail.com>
---
 doc/pacman.conf.5.txt |    3 +++
 src/pacman/sync.c     |    4 ++--
 src/pacman/util.c     |   11 ++++++++---
 src/pacman/util.h     |    2 +-
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/doc/pacman.conf.5.txt b/doc/pacman.conf.5.txt
index 7e9017a..42bf1c2 100644
--- a/doc/pacman.conf.5.txt
+++ b/doc/pacman.conf.5.txt
@@ -170,6 +170,9 @@ Options
 	Also, the optional dependencies of the targets won't be shown during installation.
 	If `ShowAll` and `Ask` are set, the prompt also shows optional dependencies
 	which are already installed.
+	The prompt selects none of the optional dependencies by default.
+	If `Install` and `Ask` are both 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 8fbdf78..ec90616 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -665,7 +665,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;
 				}
@@ -739,7 +739,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 8e5e480..4055127 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1400,11 +1400,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;
@@ -1422,10 +1423,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 0fbc6b9..229167c 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -75,7 +75,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, ...);
 
-- 
1.7.7.3



More information about the pacman-dev mailing list