diff options
author | James Antill <james@and.org> | 2014-10-22 01:21:14 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2014-10-23 10:21:17 -0400 |
commit | 52c0d89a8cd53cfec20041fa0e1a4fe382a1a2d2 (patch) | |
tree | 2edb298312f44268fcbf02237420806047d387dd | |
parent | 49de180191334ba1743d6d217590db3ec66309f6 (diff) | |
download | ostree-52c0d89a8cd53cfec20041fa0e1a4fe382a1a2d2.tar.gz |
admin: Add ot_admin_checksum_version to get a dup of the version for a commit
-rw-r--r-- | src/ostree/ot-admin-functions.c | 23 | ||||
-rw-r--r-- | src/ostree/ot-admin-functions.h | 4 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/ostree/ot-admin-functions.c b/src/ostree/ot-admin-functions.c index 34e5c6b2..ff623574 100644 --- a/src/ostree/ot-admin-functions.c +++ b/src/ostree/ot-admin-functions.c @@ -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); +} diff --git a/src/ostree/ot-admin-functions.h b/src/ostree/ot-admin-functions.h index ab830369..ea147c84 100644 --- a/src/ostree/ot-admin-functions.h +++ b/src/ostree/ot-admin-functions.h @@ -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 |