Print the target arch when using the %a format specifier
Adds the %a format specifier to allow printing of a target's arch when using --print-format. Signed-off-by: Jonathan Sköld <arch@skold.dev>
This commit is contained in:
parent
db1c1b6777
commit
bec22fcd41
2 changed files with 13 additions and 2 deletions
|
@ -235,8 +235,9 @@ Transaction Options (apply to '-S', '-R' and '-U')
|
||||||
|
|
||||||
*\--print-format* <format>::
|
*\--print-format* <format>::
|
||||||
Specify a printf-like format to control the output of the '\--print'
|
Specify a printf-like format to control the output of the '\--print'
|
||||||
operation. The possible attributes are: "%n" for pkgname, "%v" for pkgver,
|
operation. The possible attributes are: "%a" for arch, "%n" for pkgname,
|
||||||
"%l" for location, "%r" for repository, and "%s" for size. Implies '\--print'.
|
"%v" for pkgver, "%l" for location, "%r" for repository, and "%s" for size.
|
||||||
|
Implies '\--print'.
|
||||||
|
|
||||||
|
|
||||||
Upgrade Options (apply to '-S' and '-U')[[UO]]
|
Upgrade Options (apply to '-S' and '-U')[[UO]]
|
||||||
|
|
|
@ -1146,6 +1146,16 @@ void print_packages(const alpm_list_t *packages)
|
||||||
alpm_pkg_t *pkg = i->data;
|
alpm_pkg_t *pkg = i->data;
|
||||||
char *string = strdup(config->print_format);
|
char *string = strdup(config->print_format);
|
||||||
char *temp = string;
|
char *temp = string;
|
||||||
|
/* %a : arch */
|
||||||
|
if(strstr(temp, "%a")) {
|
||||||
|
const char *arch = alpm_pkg_get_arch(pkg);
|
||||||
|
if(arch == NULL) {
|
||||||
|
arch = "";
|
||||||
|
}
|
||||||
|
string = strreplace(temp, "%a", arch);
|
||||||
|
free(temp);
|
||||||
|
temp = string;
|
||||||
|
}
|
||||||
/* %n : pkgname */
|
/* %n : pkgname */
|
||||||
if(strstr(temp, "%n")) {
|
if(strstr(temp, "%n")) {
|
||||||
string = strreplace(temp, "%n", alpm_pkg_get_name(pkg));
|
string = strreplace(temp, "%n", alpm_pkg_get_name(pkg));
|
||||||
|
|
Loading…
Add table
Reference in a new issue