util.c: extend --print-format with %R and %P

Add provides "%P" and replaces "%R" as format attribute.

Signed-off-by: Jelle van der Waa <jelle@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Jelle van der Waa 2022-09-16 11:12:39 +02:00 committed by Allan McRae
parent c1d4a6198c
commit 5bd0b98b42
2 changed files with 20 additions and 1 deletions

View file

@ -240,7 +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.
"%L" for licenses, and "%M" for makedepends, "%P" for provides and
"%R" for replaces.
Implies '\--print'.

View file

@ -1279,6 +1279,24 @@ void print_packages(const alpm_list_t *packages)
free(temp);
temp = string;
}
/* %P : provides */
if(strstr(temp, "%P")) {
alpm_list_t *lst = alpm_pkg_get_provides(pkg);
char *depends = concat_list(lst, (formatfn)alpm_dep_compute_string);
string = strreplace(temp, "%P", depends);
free(depends);
free(temp);
temp = string;
}
/* %R : replaces */
if(strstr(temp, "%R")) {
alpm_list_t *lst = alpm_pkg_get_replaces(pkg);
char *depends = concat_list(lst, (formatfn)alpm_dep_compute_string);
string = strreplace(temp, "%R", depends);
free(depends);
free(temp);
temp = string;
}
/* %L : license */
if(strstr(temp, "%L")) {
alpm_list_t *lst = alpm_pkg_get_licenses(pkg);