admin status: Print the version
This commit is contained in:
parent
aab6e7bdf2
commit
81a484459a
|
|
@ -33,11 +33,27 @@ static GOptionEntry options[] = {
|
||||||
{ NULL }
|
{ 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
|
gboolean
|
||||||
ot_admin_builtin_status (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error)
|
ot_admin_builtin_status (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error)
|
||||||
{
|
{
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
gs_unref_object OstreeRepo *repo = NULL;
|
||||||
OstreeDeployment *booted_deployment = NULL;
|
OstreeDeployment *booted_deployment = NULL;
|
||||||
gs_unref_ptrarray GPtrArray *deployments = NULL;
|
gs_unref_ptrarray GPtrArray *deployments = NULL;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
@ -52,6 +68,9 @@ ot_admin_builtin_status (int argc, char **argv, OstreeSysroot *sysroot, GCancell
|
||||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
if (!ostree_sysroot_get_repo (sysroot, &repo, cancellable, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
deployments = ostree_sysroot_get_deployments (sysroot);
|
deployments = ostree_sysroot_get_deployments (sysroot);
|
||||||
booted_deployment = ostree_sysroot_get_booted_deployment (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];
|
OstreeDeployment *deployment = deployments->pdata[i];
|
||||||
GKeyFile *origin;
|
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",
|
g_print ("%c %s %s.%d\n",
|
||||||
deployment == booted_deployment ? '*' : ' ',
|
deployment == booted_deployment ? '*' : ' ',
|
||||||
ostree_deployment_get_osname (deployment),
|
ostree_deployment_get_osname (deployment),
|
||||||
ostree_deployment_get_csum (deployment),
|
ostree_deployment_get_csum (deployment),
|
||||||
ostree_deployment_get_deployserial (deployment));
|
ostree_deployment_get_deployserial (deployment));
|
||||||
|
if (version)
|
||||||
|
g_print (" Version: %s\n", version);
|
||||||
origin = ostree_deployment_get_origin (deployment);
|
origin = ostree_deployment_get_origin (deployment);
|
||||||
if (!origin)
|
if (!origin)
|
||||||
g_print (" origin: none\n");
|
g_print (" origin: none\n");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue