summaryrefslogtreecommitdiff
path: root/src/ostree/ot-admin-builtin-status.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ostree/ot-admin-builtin-status.c')
-rw-r--r--src/ostree/ot-admin-builtin-status.c110
1 files changed, 49 insertions, 61 deletions
diff --git a/src/ostree/ot-admin-builtin-status.c b/src/ostree/ot-admin-builtin-status.c
index 672882bd..3addfd16 100644
--- a/src/ostree/ot-admin-builtin-status.c
+++ b/src/ostree/ot-admin-builtin-status.c
@@ -21,25 +21,23 @@
#include "config.h"
-#include "ot-main.h"
+#include "libglnx.h"
+#include "ostree.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
-#include "ostree.h"
-#include "libglnx.h"
+#include "ot-main.h"
#include <glib/gi18n.h>
static gboolean opt_verify;
-static GOptionEntry options[] = {
- { "verify", 'V', 0, G_OPTION_ARG_NONE, &opt_verify, "Print the commit verification status", NULL },
- { NULL }
-};
+static GOptionEntry options[] = { { "verify", 'V', 0, G_OPTION_ARG_NONE, &opt_verify,
+ "Print the commit verification status", NULL },
+ { NULL } };
#ifndef OSTREE_DISABLE_GPGME
static gboolean
-deployment_get_gpg_verify (OstreeDeployment *deployment,
- OstreeRepo *repo)
+deployment_get_gpg_verify (OstreeDeployment *deployment, OstreeRepo *repo)
{
/* XXX Something like this could be added to the OstreeDeployment
* API in libostree if the OstreeRepo parameter is acceptable. */
@@ -59,38 +57,32 @@ deployment_get_gpg_verify (OstreeDeployment *deployment,
gboolean gpg_verify = FALSE;
if (remote)
- (void) ostree_repo_remote_get_gpg_verify (repo, remote, &gpg_verify, NULL);
+ (void)ostree_repo_remote_get_gpg_verify (repo, remote, &gpg_verify, NULL);
return gpg_verify;
}
#endif /* OSTREE_DISABLE_GPGME */
-
static gboolean
-deployment_print_status (OstreeSysroot *sysroot,
- OstreeRepo *repo,
- OstreeDeployment *deployment,
- gboolean is_booted,
- gboolean is_pending,
- gboolean is_rollback,
- GCancellable *cancellable,
- GError **error)
+deployment_print_status (OstreeSysroot *sysroot, OstreeRepo *repo, OstreeDeployment *deployment,
+ gboolean is_booted, gboolean is_pending, gboolean is_rollback,
+ GCancellable *cancellable, GError **error)
{
const char *ref = ostree_deployment_get_csum (deployment);
/* Load the backing commit; shouldn't normally fail, but if it does,
* we stumble on.
*/
- g_autoptr(GVariant) commit = NULL;
- (void)ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, ref,
- &commit, NULL);
- g_autoptr(GVariant) commit_metadata = NULL;
+ g_autoptr (GVariant) commit = NULL;
+ (void)ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, ref, &commit, NULL);
+ g_autoptr (GVariant) commit_metadata = NULL;
if (commit)
commit_metadata = g_variant_get_child_value (commit, 0);
- g_autoptr(GVariant) commit_detached_metadata = NULL;
+ g_autoptr (GVariant) commit_detached_metadata = NULL;
if (commit)
{
- if (!ostree_repo_read_commit_detached_metadata (repo, ref, &commit_detached_metadata, cancellable, error))
+ if (!ostree_repo_read_commit_detached_metadata (repo, ref, &commit_detached_metadata,
+ cancellable, error))
return FALSE;
}
@@ -98,8 +90,9 @@ deployment_print_status (OstreeSysroot *sysroot,
const char *source_title = NULL;
if (commit_metadata)
{
- (void) g_variant_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_VERSION, "&s", &version);
- (void) g_variant_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_SOURCE_TITLE, "&s", &source_title);
+ (void)g_variant_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_VERSION, "&s", &version);
+ (void)g_variant_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_SOURCE_TITLE, "&s",
+ &source_title);
}
GKeyFile *origin = ostree_deployment_get_origin (deployment);
@@ -111,11 +104,8 @@ deployment_print_status (OstreeSysroot *sysroot,
deployment_status = " (pending)";
else if (is_rollback)
deployment_status = " (rollback)";
- g_print ("%c %s %s.%d%s\n",
- is_booted ? '*' : ' ',
- ostree_deployment_get_osname (deployment),
- ostree_deployment_get_csum (deployment),
- ostree_deployment_get_deployserial (deployment),
+ g_print ("%c %s %s.%d%s\n", is_booted ? '*' : ' ', ostree_deployment_get_osname (deployment),
+ ostree_deployment_get_csum (deployment), ostree_deployment_get_deployserial (deployment),
deployment_status);
if (version)
g_print (" Version: %s\n", version);
@@ -127,8 +117,8 @@ deployment_print_status (OstreeSysroot *sysroot,
break;
default:
g_print (" %s%sUnlocked: %s%s%s\n", ot_get_red_start (), ot_get_bold_start (),
- ostree_deployment_unlocked_state_to_string (unlocked),
- ot_get_bold_end (), ot_get_red_end ());
+ ostree_deployment_unlocked_state_to_string (unlocked), ot_get_bold_end (),
+ ot_get_red_end ());
}
if (ostree_deployment_is_pinned (deployment))
g_print (" Pinned: yes\n");
@@ -148,14 +138,13 @@ deployment_print_status (OstreeSysroot *sysroot,
#ifndef OSTREE_DISABLE_GPGME
if (!opt_verify && deployment_get_gpg_verify (deployment, repo))
{
- g_autoptr(GString) output_buffer = g_string_sized_new (256);
+ g_autoptr (GString) output_buffer = g_string_sized_new (256);
/* Print any digital signatures on this commit. */
const char *osname = ostree_deployment_get_osname (deployment);
- g_autoptr(GError) local_error = NULL;
- g_autoptr(OstreeGpgVerifyResult) result =
- ostree_repo_verify_commit_for_remote (repo, ref, osname,
- cancellable, &local_error);
+ g_autoptr (GError) local_error = NULL;
+ g_autoptr (OstreeGpgVerifyResult) result
+ = ostree_repo_verify_commit_for_remote (repo, ref, osname, cancellable, &local_error);
/* G_IO_ERROR_NOT_FOUND just means the commit is not signed. */
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
@@ -172,8 +161,8 @@ deployment_print_status (OstreeSysroot *sysroot,
const guint n_signatures = ostree_gpg_verify_result_count_all (result);
for (guint jj = 0; jj < n_signatures; jj++)
{
- ostree_gpg_verify_result_describe (result, jj, output_buffer, " GPG: ",
- OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT);
+ ostree_gpg_verify_result_describe (result, jj, output_buffer,
+ " GPG: ", OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT);
}
g_print ("%s", output_buffer->str);
@@ -196,11 +185,13 @@ deployment_print_status (OstreeSysroot *sysroot,
if (remote == NULL)
return glnx_throw (error, "Cannot verify deployment without remote");
- g_autoptr(GBytes) commit_data = g_variant_get_data_as_bytes (commit);
- g_autoptr(GBytes) commit_detached_metadata_bytes =
- commit_detached_metadata ? g_variant_get_data_as_bytes (commit_detached_metadata) : NULL;
+ g_autoptr (GBytes) commit_data = g_variant_get_data_as_bytes (commit);
+ g_autoptr (GBytes) commit_detached_metadata_bytes
+ = commit_detached_metadata ? g_variant_get_data_as_bytes (commit_detached_metadata)
+ : NULL;
g_autofree char *verify_text = NULL;
- if (!ostree_repo_signature_verify_commit_data (repo, remote, commit_data, commit_detached_metadata_bytes, 0, &verify_text, error))
+ if (!ostree_repo_signature_verify_commit_data (
+ repo, remote, commit_data, commit_detached_metadata_bytes, 0, &verify_text, error))
return FALSE;
g_print ("%s\n", verify_text);
}
@@ -209,28 +200,28 @@ deployment_print_status (OstreeSysroot *sysroot,
}
gboolean
-ot_admin_builtin_status (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ot_admin_builtin_status (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = g_option_context_new ("");
+ g_autoptr (GOptionContext) context = g_option_context_new ("");
- g_autoptr(OstreeSysroot) sysroot = NULL;
+ g_autoptr (OstreeSysroot) sysroot = NULL;
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
- OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
- invocation, &sysroot, cancellable, error))
+ OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED, invocation, &sysroot,
+ cancellable, error))
return FALSE;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
if (!ostree_sysroot_get_repo (sysroot, &repo, cancellable, error))
return FALSE;
- g_autoptr(GPtrArray) deployments = ostree_sysroot_get_deployments (sysroot);
+ g_autoptr (GPtrArray) deployments = ostree_sysroot_get_deployments (sysroot);
OstreeDeployment *booted_deployment = ostree_sysroot_get_booted_deployment (sysroot);
- g_autoptr(OstreeDeployment) pending_deployment = NULL;
- g_autoptr(OstreeDeployment) rollback_deployment = NULL;
+ g_autoptr (OstreeDeployment) pending_deployment = NULL;
+ g_autoptr (OstreeDeployment) rollback_deployment = NULL;
if (booted_deployment)
- ostree_sysroot_query_deployments_for (sysroot, NULL, &pending_deployment,
- &rollback_deployment);
+ ostree_sysroot_query_deployments_for (sysroot, NULL, &pending_deployment, &rollback_deployment);
if (deployments->len == 0)
{
@@ -241,12 +232,9 @@ ot_admin_builtin_status (int argc, char **argv, OstreeCommandInvocation *invocat
for (guint i = 0; i < deployments->len; i++)
{
OstreeDeployment *deployment = deployments->pdata[i];
- if (!deployment_print_status (sysroot, repo, deployment,
- deployment == booted_deployment,
+ if (!deployment_print_status (sysroot, repo, deployment, deployment == booted_deployment,
deployment == pending_deployment,
- deployment == rollback_deployment,
- cancellable,
- error))
+ deployment == rollback_deployment, cancellable, error))
return FALSE;
}
}