diff options
author | Jelle van der Waa <jelle@vdwaa.nl> | 2022-03-26 16:54:21 +0100 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2022-07-21 19:56:18 +1000 |
commit | 00bc386d5a0481f29ebe6b74d62deb0620f32192 (patch) | |
tree | 5c4889ca80b59ecd89a43ed03a62d585eec138ff | |
parent | 7bcc2d9b233dea3d7ed3824cc33d635d024d0784 (diff) |
util.c: extend --print-format with %b for builddate
Signed-off-by: Jelle van der Waa <jelle@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r-- | doc/pacman.8.asciidoc | 10 | ||||
-rw-r--r-- | src/pacman/util.c | 11 |
2 files changed, 16 insertions, 5 deletions
diff --git a/doc/pacman.8.asciidoc b/doc/pacman.8.asciidoc index 49e392cb..8a9294fc 100644 --- a/doc/pacman.8.asciidoc +++ b/doc/pacman.8.asciidoc @@ -235,11 +235,11 @@ Transaction Options (apply to '-S', '-R' and '-U') *\--print-format* <format>:: Specify a printf-like format to control the output of the '\--print' - operation. The possible attributes are: "%a" for arch, "%d" for - description, "%e" for pkgbase, "%f" for filename, "%g" for base64 - encoded PGP signature, "%h" for sha256sum, "%n" for pkgname, "%p" for - packager, "%v" for pkgver, "%l" for location, "%r" for repository, and - "%s" for size. + operation. The possible attributes are: "%a" for arch, "%b" for + builddate, "%d" for description, "%e" for pkgbase, "%f" for filename, + "%g" for base64 encoded PGP signature, "%h" for sha256sum, "%n" for + pkgname, "%p" for packager, "%v" for pkgver, "%l" for location, "%r" + for repository, and "%s" for size. Implies '\--print'. diff --git a/src/pacman/util.c b/src/pacman/util.c index 3b92e678..2c222683 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1163,6 +1163,17 @@ void print_packages(const alpm_list_t *packages) free(temp); temp = string; } + /* %b : build date */ + if(strstr(temp, "%b")) { + char bdatestr[50] = ""; + time_t bdate = (time_t)alpm_pkg_get_builddate(pkg); + if(bdate != -1) { + strftime(bdatestr, 50, "%c", localtime(&bdate)); + string = strreplace(temp, "%b", bdatestr); + free(temp); + temp = string; + } + } /* %d : description */ VAL_FROM_FORMAT_STR(temp, "%d", alpm_pkg_get_desc) /* %e : pkgbase */ |