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

Add a new print attribute "%G" which prints groups.

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Jelle van der Waa 2022-09-16 12:18:42 +02:00 committed by Allan McRae
parent 06db927a1a
commit 6968f77026
2 changed files with 12 additions and 2 deletions

View file

@ -240,8 +240,9 @@ 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,
"%H" for conflicts, "%L" for licenses, "%M" for makedepends, "%O" for
optional depends, "%P" for provides and "%R" for replaces.
"%G" for groups, "%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;
}
/* %G : groups */
if(strstr(temp, "%G")) {
alpm_list_t *lst = alpm_pkg_get_groups(pkg);
char *depends = concat_list(lst, NULL);
string = strreplace(temp, "%G", depends);
free(depends);
free(temp);
temp = string;
}
/* %H : conflicts */
if(strstr(temp, "%H")) {
alpm_list_t *lst = alpm_pkg_get_conflicts(pkg);