[pacman-dev] Print relevant information about file conflicts or corrupted packages to stderr instead of stdout.

Message ID 20210602152916.23765-1-o.roesler@oscloud.info
State New
Headers show
Series [pacman-dev] Print relevant information about file conflicts or corrupted packages to stderr instead of stdout. | expand

Commit Message

Oskar Roesler \(bionade24\) June 2, 2021, 3:29 p.m. UTC
Signed-off-by: Oskar Roesler (bionade24) <o.roesler@oscloud.info>
---
 lib/libalpm/conflict.c | 4 ++--
 src/pacman/sync.c      | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

Comments

Allan McRae June 2, 2021, 11:47 p.m. UTC | #1
On 3/6/21 1:29 am, Oskar Roesler (bionade24) via pacman-dev wrote:
> Signed-off-by: Oskar Roesler (bionade24) <o.roesler@oscloud.info>
> ---
>  lib/libalpm/conflict.c | 4 ++--
>  src/pacman/sync.c      | 8 ++++----
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
> index b471bf21..56d24a37 100644
> --- a/lib/libalpm/conflict.c
> +++ b/lib/libalpm/conflict.c
> @@ -456,10 +456,10 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
>  					 * conflicts as the path from p1 is returned */
>  					if(_alpm_can_overwrite_file(handle, filename, path)
>  							&& alpm_filelist_contains(p2_files, filename)) {
> -						_alpm_log(handle, ALPM_LOG_DEBUG,
> +						_alpm_log(handle, ALPM_LOG_ERROR,
>  							"%s exists in both '%s' and '%s'\n", filename,
>  							p1->name, p2->name);
> -						_alpm_log(handle, ALPM_LOG_DEBUG,
> +						_alpm_log(handle, ALPM_LOG_ERROR,
>  							"file-file conflict being forced\n");
>  						continue;
>  					}'


These should not be changed.  They are only printed with --debug.

> diff --git a/src/pacman/sync.c b/src/pacman/sync.c
> index b6da1a36..b0507d84 100644
> --- a/src/pacman/sync.c
> +++ b/src/pacman/sync.c
> @@ -836,15 +836,15 @@ int sync_prepare_execute(void)
>  					alpm_fileconflict_t *conflict = i->data;
>  					switch(conflict->type) {
>  						case ALPM_FILECONFLICT_TARGET:
> -							printf(_("%s exists in both '%s' and '%s'\n"),
> +							pm_printf(ALPM_LOG_ERROR, _("%s exists in both '%s' and '%s'\n"),

This adds "error: " to the start of the message, which is not needed as
this is the clarification of the error.

Use "fprintf(stderr, _(...))" instead.

>  									conflict->file, conflict->target, conflict->ctarget);
>  							break;
>  						case ALPM_FILECONFLICT_FILESYSTEM:
>  							if(conflict->ctarget[0]) {
> -								printf(_("%s: %s exists in filesystem (owned by %s)\n"),
> +								pm_printf(ALPM_LOG_ERROR, _("%s: %s exists in filesystem (owned by %s)\n"),
>  										conflict->target, conflict->file, conflict->ctarget);
>  							} else {
> -								printf(_("%s: %s exists in filesystem\n"),
> +								pm_printf(ALPM_LOG_ERROR, _("%s: %s exists in filesystem\n"),
>  										conflict->target, conflict->file);
>  							}
>  							break;
> @@ -857,7 +857,7 @@ int sync_prepare_execute(void)
>  			case ALPM_ERR_PKG_INVALID_SIG:
>  				for(i = data; i; i = alpm_list_next(i)) {
>  					char *filename = i->data;
> -					printf(_("%s is invalid or corrupted\n"), filename);
> +					pm_printf(ALPM_LOG_ERROR, _("%s is invalid or corrupted\n"), filename);
>  					free(filename);
>  				}
>  				break;
>
Oskar Roesler \(bionade24\) June 3, 2021, 9:12 a.m. UTC | #2
Am Donnerstag, 3. Juni 2021 01:47:48 CEST schrieb Allan McRae:
> On 3/6/21 1:29 am, Oskar Roesler (bionade24) via pacman-dev wrote:
>> Signed-off-by: Oskar Roesler (bionade24) <o.roesler@oscloud.info>
>> ---
>>  lib/libalpm/conflict.c | 4 ++--
>>  src/pacman/sync.c      | 8 ++++----
>>  2 files changed, 6 insertions(+), 6 deletions(-) ...
>
>
> These should not be changed.  They are only printed with --debug.
Ah, after looking at pacman code more deeply, those messages would be 
redundant then.
>
>> diff --git a/src/pacman/sync.c b/src/pacman/sync.c
>> index b6da1a36..b0507d84 100644
>> --- a/src/pacman/sync.c
>> +++ b/src/pacman/sync.c
>> @@ -836,15 +836,15 @@ int sync_prepare_execute(void) ...
>
> This adds "error: " to the start of the message, which is not needed as
> this is the clarification of the error.
>
> Use "fprintf(stderr, _(...))" instead.
I should have looked more deeply into the code here before using it, I'll 
change it.
>
>>  									conflict->file, conflict->target, conflict->ctarget);
>>  							break;
>>  						case ALPM_FILECONFLICT_FILESYSTEM:
>>  							if(conflict->ctarget[0]) {
>> -								printf(_("%s: %s exists in filesystem (owned by %s)\n"), ...
>
>
>

Patch

diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index b471bf21..56d24a37 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -456,10 +456,10 @@  alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
 					 * conflicts as the path from p1 is returned */
 					if(_alpm_can_overwrite_file(handle, filename, path)
 							&& alpm_filelist_contains(p2_files, filename)) {
-						_alpm_log(handle, ALPM_LOG_DEBUG,
+						_alpm_log(handle, ALPM_LOG_ERROR,
 							"%s exists in both '%s' and '%s'\n", filename,
 							p1->name, p2->name);
-						_alpm_log(handle, ALPM_LOG_DEBUG,
+						_alpm_log(handle, ALPM_LOG_ERROR,
 							"file-file conflict being forced\n");
 						continue;
 					}
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index b6da1a36..b0507d84 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -836,15 +836,15 @@  int sync_prepare_execute(void)
 					alpm_fileconflict_t *conflict = i->data;
 					switch(conflict->type) {
 						case ALPM_FILECONFLICT_TARGET:
-							printf(_("%s exists in both '%s' and '%s'\n"),
+							pm_printf(ALPM_LOG_ERROR, _("%s exists in both '%s' and '%s'\n"),
 									conflict->file, conflict->target, conflict->ctarget);
 							break;
 						case ALPM_FILECONFLICT_FILESYSTEM:
 							if(conflict->ctarget[0]) {
-								printf(_("%s: %s exists in filesystem (owned by %s)\n"),
+								pm_printf(ALPM_LOG_ERROR, _("%s: %s exists in filesystem (owned by %s)\n"),
 										conflict->target, conflict->file, conflict->ctarget);
 							} else {
-								printf(_("%s: %s exists in filesystem\n"),
+								pm_printf(ALPM_LOG_ERROR, _("%s: %s exists in filesystem\n"),
 										conflict->target, conflict->file);
 							}
 							break;
@@ -857,7 +857,7 @@  int sync_prepare_execute(void)
 			case ALPM_ERR_PKG_INVALID_SIG:
 				for(i = data; i; i = alpm_list_next(i)) {
 					char *filename = i->data;
-					printf(_("%s is invalid or corrupted\n"), filename);
+					pm_printf(ALPM_LOG_ERROR, _("%s is invalid or corrupted\n"), filename);
 					free(filename);
 				}
 				break;