Message ID | 20210920183325.230559-1-arch@skold.dev |
---|---|
State | Superseded, archived |
Headers | show |
Series | [pacman-dev] Print the package arch using the %a format specifier. | expand |
On 21/9/21 04:33, Jonathan Sköld wrote: > Adds the %a format specifier to allow printing of the package arch when using --print-format. > > Signed-off-by: Jonathan Sköld <arch@skold.dev> Thanks - looks good to me. I do wish --print-format got implemented more widely in the pacman codebase... > --- > src/pacman/util.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/src/pacman/util.c b/src/pacman/util.c > index 5486e7a5..bb57e950 100644 > --- a/src/pacman/util.c > +++ b/src/pacman/util.c > @@ -1146,6 +1146,12 @@ void print_packages(const alpm_list_t *packages) > alpm_pkg_t *pkg = i->data; > char *string = strdup(config->print_format); > char *temp = string; > + /* %a : pkgarch */ > + if(strstr(temp, "%a")) { > + string = strreplace(temp, "%a", alpm_pkg_get_arch(pkg)); > + free(temp); > + temp = string; > + } > /* %n : pkgname */ > if(strstr(temp, "%n")) { > string = strreplace(temp, "%n", alpm_pkg_get_name(pkg));
On 2/1/22 21:21, Allan McRae wrote: > On 21/9/21 04:33, Jonathan Sköld wrote: >> Adds the %a format specifier to allow printing of the package arch >> when using --print-format. >> >> Signed-off-by: Jonathan Sköld <arch@skold.dev> > > Thanks - looks good to me. > > I do wish --print-format got implemented more widely in the pacman > codebase... > Replied to wrong version of the patch... but I have pulled v3.
diff --git a/src/pacman/util.c b/src/pacman/util.c index 5486e7a5..bb57e950 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1146,6 +1146,12 @@ void print_packages(const alpm_list_t *packages) alpm_pkg_t *pkg = i->data; char *string = strdup(config->print_format); char *temp = string; + /* %a : pkgarch */ + if(strstr(temp, "%a")) { + string = strreplace(temp, "%a", alpm_pkg_get_arch(pkg)); + free(temp); + temp = string; + } /* %n : pkgname */ if(strstr(temp, "%n")) { string = strreplace(temp, "%n", alpm_pkg_get_name(pkg));
Adds the %a format specifier to allow printing of the package arch when using --print-format. Signed-off-by: Jonathan Sköld <arch@skold.dev> --- src/pacman/util.c | 6 ++++++ 1 file changed, 6 insertions(+)