[pacman-dev] [PATCH] Print the package arch using the %a format specifier.

Allan McRae allan at archlinux.org
Sun Jan 2 11:21:10 UTC 2022


On 21/9/21 04:33, Jonathan Sköld wrote:
> Adds the %a format specifier to allow printing of the package arch when using --print-format.
> 
> Signed-off-by: Jonathan Sköld <arch at skold.dev>

Thanks - looks good to me.

I do wish --print-format got implemented more widely in the pacman 
codebase...

> ---
>   src/pacman/util.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/src/pacman/util.c b/src/pacman/util.c
> index 5486e7a5..bb57e950 100644
> --- a/src/pacman/util.c
> +++ b/src/pacman/util.c
> @@ -1146,6 +1146,12 @@ void print_packages(const alpm_list_t *packages)
>   		alpm_pkg_t *pkg = i->data;
>   		char *string = strdup(config->print_format);
>   		char *temp = string;
> +		/* %a : pkgarch */
> +		if(strstr(temp, "%a")) {
> +			string = strreplace(temp, "%a", alpm_pkg_get_arch(pkg));
> +			free(temp);
> +			temp = string;
> +		}
>   		/* %n : pkgname */
>   		if(strstr(temp, "%n")) {
>   			string = strreplace(temp, "%n", alpm_pkg_get_name(pkg));



More information about the pacman-dev mailing list