admin: Add ot_admin_checksum_version to get a dup of the version for a commit

This commit is contained in:
James Antill 2014-10-22 01:21:14 -04:00 committed by Colin Walters
parent 49de180191
commit 52c0d89a8c
2 changed files with 27 additions and 0 deletions

View File

@ -48,3 +48,26 @@ ot_admin_require_booted_deployment_or_osname (OstreeSysroot *sysroot,
out:
return ret;
}
/**
* ot_admin_checksum_version:
* @checksum: A GVariant from an ostree checksum.
*
*
* Get the version metadata string from a commit variant object, if it exists.
*
* Returns: A newly allocated string of the version, or %NULL is none
*/
char *
ot_admin_checksum_version (GVariant *checksum)
{
gs_unref_variant GVariant *metadata = NULL;
const char *ret = NULL;
metadata = g_variant_get_child_value (checksum, 0);
if (!g_variant_lookup (metadata, "version", "&s", &ret))
return NULL;
return g_strdup (ret);
}

View File

@ -32,5 +32,9 @@ ot_admin_require_booted_deployment_or_osname (OstreeSysroot *sysroot,
const char *osname,
GCancellable *cancellable,
GError **error);
char *
ot_admin_checksum_version (GVariant *checksum);
G_END_DECLS