1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

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 <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-11-03 10:58:19 +01:00
parent 0ed6a6df5a
commit d10b67b9bc
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 23 additions and 7 deletions

View File

@ -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

View File

@ -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,