From d10b67b9bc32e8feff1be86e6646fc23e58fe45d Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 3 Nov 2016 10:58:19 +0100 Subject: [PATCH] gpgconf: Add a new field to the --query-swdb output. * tools/gpgconf.c (query_swdb): Insert new field with the installed version. Check that the supplied version does not contain a colon. Signed-off-by: Werner Koch --- doc/tools.texi | 9 +++++++-- tools/gpgconf.c | 21 ++++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/doc/tools.texi b/doc/tools.texi index 2d2ccefe8..6e578a3ad 100644 --- a/doc/tools.texi +++ b/doc/tools.texi @@ -984,6 +984,11 @@ special name which is replaced by the actual package implementing this version of GnuPG. For this name it is also not required to specify a version because @command{gpgconf} takes its own version in this case. +@item iversion +The currently installed version or an empty string. The value is +taken from the command line argument but may be provided by gpg +if not given. + @item status The status of the software package according to this table: @table @code @@ -995,9 +1000,9 @@ The given name is not known in the online database. @item u An update of the software is available. @item c -The specified version of the software is current. +The installed version of the software is current. @item n -The specified version is already newer than the released version. +The installed version is already newer than the released version. @end table @item urgency diff --git a/tools/gpgconf.c b/tools/gpgconf.c index 1f00418ee..e43f49d40 100644 --- a/tools/gpgconf.c +++ b/tools/gpgconf.c @@ -232,6 +232,7 @@ valid_swdb_name_p (const char *name) * output written to OUT is a colon delimited line with these fields: * * name :: The name of the package + * curvers:: The installed version if given. * status :: This value tells the status of the software package * '-' :: No information available * (error or CURRENT_VERSION not given) @@ -301,7 +302,8 @@ query_swdb (estream_t out, const char *name, const char *current_version) current_version = self_version; } - if (current_version && compare_version_strings (current_version, NULL)) + if (current_version && (strchr (current_version, ':') + || compare_version_strings (current_version, NULL))) { log_error ("error in version string '%s': %s\n", current_version, gpg_strerror (GPG_ERR_INV_ARG)); @@ -313,7 +315,10 @@ query_swdb (estream_t out, const char *name, const char *current_version) if (!fp) { err = gpg_error_from_syserror (); - es_fprintf (out, "%s:-::%u:::::::\n", name, gpg_err_code (err)); + es_fprintf (out, "%s:%s:-::%u:::::::\n", + name, + current_version? current_version : "", + gpg_err_code (err)); if (gpg_err_code (err) != GPG_ERR_ENOENT) log_error (_("error opening '%s': %s\n"), fname, gpg_strerror (err)); goto leave; @@ -381,13 +386,18 @@ query_swdb (estream_t out, const char *name, const char *current_version) if (!*filedate || !*verified) { err = gpg_error (GPG_ERR_INV_TIME); - es_fprintf (out, "%s:-::%u:::::::\n", name, gpg_err_code (err)); + es_fprintf (out, "%s:%s:-::%u:::::::\n", + name, + current_version? current_version : "", + gpg_err_code (err)); goto leave; } if (!value_ver) { - es_fprintf (out, "%s:?:::::::::\n", name); + es_fprintf (out, "%s:%s:?:::::::::\n", + name, + current_version? current_version : ""); goto leave; } @@ -414,8 +424,9 @@ query_swdb (estream_t out, const char *name, const char *current_version) else status = 'n'; - es_fprintf (out, "%s:%c::%d:%s:%s:%s:%s:%lu:%s:\n", + es_fprintf (out, "%s:%s:%c::%d:%s:%s:%s:%s:%lu:%s:\n", name, + current_version? current_version : "", status, err, filedate,