util.c: extend --print-format with "%H"

Add a new print attribute "%H" which shows conflicts.

Signed-off-by: Jelle van der Waa <jelle@archlinux.org>
This commit is contained in:
Jelle van der Waa 2022-09-16 11:17:58 +02:00 committed by Allan McRae
parent 909f2e86c3
commit 06db927a1a
2 changed files with 11 additions and 2 deletions

View file

@ -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'.

View file

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