Resubmission: Print the package arch using the %a format specifier.

Message ID 20210921180526.218356-1-arch@skold.dev
State Superseded, archived
Headers show
Series Resubmission: Print the package arch using the %a format specifier. | expand

Commit Message

Jonathan Sköld Sept. 21, 2021, 6:05 p.m. UTC
This is a resubmission of this patch, since my email got DMARC'ed the first time around.
That should hopefully be fixed now and I apologise to anyone who received this email twice.

Adds the %a format specifier to allow printing of the package arch when using --print-format.

Signed-off-by: Jonathan Sköld <arch@skold.dev>
---
 src/pacman/util.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch

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));