[pacman-dev] [PATCH] Give the frontend control over responses for print
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@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
On 16/04/13 13:42, Connor Behan wrote:
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.
So... I get here and I have to go back and re-read this several times to understand what the actual change is. You provide details for many things that are not changed at all by the patch. Just detail what is changed (ALPM_QUESTION_INSTALL_IGNOREPKG). Something like: Unify front and backend responses for --print When libalpm asks the user a question, there are two possible defaults. One default for pacman (used when the user presses enter without typing and for --noconfirm) and the libalpm default. Currently the libalpm default gets used for the pacman "--print" option. This affects the printing of ignored packages as "ALPM_QUESTION_INSTALL_IGNOREPKG" as the defaults differ. Adjust the response of this case when using --print so pacman acts consistently.
Signed-off-by: Connor Behan <connor.behan@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:
If that is dead code, why propagate it? It should just be removed altogether (in another commit...). Which would leave a fairly redundant case statement.
+ *response = 1; + break; + default: + *response = 0; + } return; } switch(event) {
On 16/04/13 09:55 PM, Allan McRae wrote:
You provide details for many things that are not changed at all by the patch. Just detail what is changed (ALPM_QUESTION_INSTALL_IGNOREPKG).
I wouldn't've written all that if I were just setting *response = 1 in that case and returning. But I am setting *response = 0 in all other cases because previous discussion was leaning towards the view that the frontend should know what is going to happen no matter what the question is.
If that is dead code, why propagate it? It should just be removed altogether (in another commit...). Which would leave a fairly redundant case statement.
ALPM_QUESTION_IMPORT_KEY was dead code up until a few commits ago... but yeah ALPM_QUESTION_LOCAL_NEWER is almost certainly not part of upcoming plans.
On 17/04/13 19:39, Connor Behan wrote:
ALPM_QUESTION_IMPORT_KEY was dead code up until a few commits ago...
If by a few commits ago you mean between 2011-09-23 01:35:52 when it was first committed and 2011-09-23 07:01:10 when it was first used... :P
participants (2)
-
Allan McRae
-
Connor Behan