From 06db927a1a83d681f6714b10dc7407c3426d6417 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Fri, 16 Sep 2022 11:17:58 +0200 Subject: [PATCH] util.c: extend --print-format with "%H" Add a new print attribute "%H" which shows conflicts. Signed-off-by: Jelle van der Waa --- doc/pacman.8.asciidoc | 4 ++-- src/pacman/util.c | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/pacman.8.asciidoc b/doc/pacman.8.asciidoc index cd573d57..a933275b 100644 --- a/doc/pacman.8.asciidoc +++ b/doc/pacman.8.asciidoc @@ -240,8 +240,8 @@ Transaction Options (apply to '-S', '-R' and '-U') "%g" for base64 encoded PGP signature, "%h" for sha256sum, "%n" for pkgname, "%p" for packager, "%v" for pkgver, "%l" for location, "%r" for repository, "%s" for size, "%C" for checkdepends, "%D" for depends, - "%L" for licenses, and "%M" for makedepends, "%O" for optional depends, - "%P" for provides and "%R" for replaces. + "%H" for conflicts, "%L" for licenses, "%M" for makedepends, "%O" for + optional depends, "%P" for provides and "%R" for replaces. Implies '\--print'. diff --git a/src/pacman/util.c b/src/pacman/util.c index 1b5a68d9..455b7b2c 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1270,6 +1270,15 @@ void print_packages(const alpm_list_t *packages) free(temp); temp = string; } + /* %H : conflicts */ + if(strstr(temp, "%H")) { + alpm_list_t *lst = alpm_pkg_get_conflicts(pkg); + char *depends = concat_list(lst, (formatfn)alpm_dep_compute_string); + string = strreplace(temp, "%H", depends); + free(depends); + free(temp); + temp = string; + } /* %M : makedepends */ if(strstr(temp, "%M")) { alpm_list_t *lst = alpm_pkg_get_makedepends(pkg);