summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Antill <james@and.org>2014-10-22 01:59:36 -0400
committerColin Walters <walters@verbum.org>2014-10-23 11:24:29 -0400
commit81a484459a0110799c58dbd2d799db8f08309b23 (patch)
tree291e0c0fc6c278065fecd03df75f1ba27e9036f1
parentaab6e7bdf26f2a51e4d5bb9cd423443ec8748a93 (diff)
downloadostree-81a484459a0110799c58dbd2d799db8f08309b23.tar.gz
admin status: Print the version
-rw-r--r--src/ostree/ot-admin-builtin-status.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ostree/ot-admin-builtin-status.c b/src/ostree/ot-admin-builtin-status.c
index 1f7801f5..9ce2f433 100644
--- a/src/ostree/ot-admin-builtin-status.c
+++ b/src/ostree/ot-admin-builtin-status.c
@@ -33,11 +33,27 @@ static GOptionEntry options[] = {
{ NULL }
};
+static char *
+version_of_commit (OstreeRepo *repo, const char *checksum)
+{
+ gs_unref_variant GVariant *variant = NULL;
+
+ /* Shouldn't fail, but if it does, we ignore it */
+ if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum,
+ &variant, NULL))
+ goto out;
+
+ return ot_admin_checksum_version (variant);
+ out:
+ return NULL;
+}
+
gboolean
ot_admin_builtin_status (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error)
{
GOptionContext *context;
gboolean ret = FALSE;
+ gs_unref_object OstreeRepo *repo = NULL;
OstreeDeployment *booted_deployment = NULL;
gs_unref_ptrarray GPtrArray *deployments = NULL;
guint i;
@@ -52,6 +68,9 @@ ot_admin_builtin_status (int argc, char **argv, OstreeSysroot *sysroot, GCancell
if (!ostree_sysroot_load (sysroot, cancellable, error))
goto out;
+ if (!ostree_sysroot_get_repo (sysroot, &repo, cancellable, error))
+ goto out;
+
deployments = ostree_sysroot_get_deployments (sysroot);
booted_deployment = ostree_sysroot_get_booted_deployment (sysroot);
@@ -65,12 +84,16 @@ ot_admin_builtin_status (int argc, char **argv, OstreeSysroot *sysroot, GCancell
{
OstreeDeployment *deployment = deployments->pdata[i];
GKeyFile *origin;
+ const char *ref = ostree_deployment_get_csum (deployment);
+ gs_free gchar *version = version_of_commit (repo, ref);
g_print ("%c %s %s.%d\n",
deployment == booted_deployment ? '*' : ' ',
ostree_deployment_get_osname (deployment),
ostree_deployment_get_csum (deployment),
ostree_deployment_get_deployserial (deployment));
+ if (version)
+ g_print (" Version: %s\n", version);
origin = ostree_deployment_get_origin (deployment);
if (!origin)
g_print (" origin: none\n");