[ostree] admin: Add ot_admin_checksum_version to get a dup of the version for a commit
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] admin: Add ot_admin_checksum_version to get a dup of the version for a commit
- Date: Thu, 23 Oct 2014 15:26:36 +0000 (UTC)
commit 52c0d89a8cd53cfec20041fa0e1a4fe382a1a2d2
Author: James Antill <james and org>
Date: Wed Oct 22 01:21:14 2014 -0400
admin: Add ot_admin_checksum_version to get a dup of the version for a commit
src/ostree/ot-admin-functions.c | 23 +++++++++++++++++++++++
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 34e5c6b..ff62357 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 ab83036..ea147c8 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]