[pacman-dev] 回复: [PATCH] Give the frontend control over responses for print

Ssfdust ssfdust at gmail.com
Tue Apr 16 03:32:37 EDT 2013




已从三星手机发送

-------- 原始消息 --------
主题:[pacman-dev] [PATCH] Give the frontend control over responses for
	print
发件人:Connor Behan <connor.behan at gmail.com>
收件人:pacman-dev at archlinux.org
抄送:

There are currently 8 questions that libalpm may ask the user. Each of
them has a "pacman default" and a "libalpm default". The pacman default
is the response that gets used if the user presses enter without typing
anything. Equivalently it is the response when --noconfirm is passed.
The libalpm default is what happens when --print is passed and the
question callback never even executes. This commit forces pacman to
specify responses for --print and therefore never rely on the libalpm
default. The following states how each question is handled:

ALPM_QUESTION_INSTALL_IGNOREPKG: The pacman default is 1 and the libalpm
default is 0. The latter was agreed to be a bug so we return 1 on print.

ALPM_QUESTION_REPLACE_PKG: The pacman default is 1 and the libalpm
default is 0. We return 0 on print.

ALPM_QUESTION_CONFLICT_PKG: The pacman default is 0 and the libalpm
default is 0. We return 0 on print even though print should not
encounter this.

ALPM_QUESTION_REMOVE_PKGS: The pacman default is 0 and the libalpm
default is 0. We return 0 on print.

ALPM_QUESTION_SELECT_PROVIDER: The pacman default is 0 and the libalpm
default is 0. We return 0 on print.

ALPM_QUESTION_LOCAL_NEWER: The pacman default is 1 and this is dead code
so there is no libalpm default. We return 1 on print.

ALPM_QUESTION_CORRUPTED_PKG: The pacman default is 1 and the libalpm
default is 0. We return 0 on print even though print should not
encounter this.

ALPM_QUESTION_IMPORT_KEY: The pacman default is 1 and the libalpm
default is 0. We return 0 on print even though print should not encounter this.

Signed-off-by: Connor Behan <connor.behan at gmail.com>
---
src/pacman/callback.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 71d9d04..711d116 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -309,6 +309,14 @@ void cb_question(alpm_question_t event, void *data1, void *data2,
                    void *data3, int *response)
{
if(config->print) {
+	 switch(event) {
+	 case ALPM_QUESTION_INSTALL_IGNOREPKG:
+	 case ALPM_QUESTION_LOCAL_NEWER:
+	 *response = 1;
+	 break;
+	 default:
+	 *response = 0;
+	 }
return;
}
switch(event) {
-- 
1.8.1.5




More information about the pacman-dev mailing list