pull: Print GPG signature status as soon as its known
This commit is contained in:
parent
20076ff201
commit
d7a6f257a0
|
|
@ -40,6 +40,20 @@ static int opt_depth = 0;
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
gpg_verify_result_cb (OstreeRepo *repo,
|
||||||
|
const char *checksum,
|
||||||
|
OstreeGpgVerifyResult *result,
|
||||||
|
GSConsole *console)
|
||||||
|
{
|
||||||
|
/* Temporarily place the GSConsole stream (which is just stdout)
|
||||||
|
* back in normal mode before printing GPG verification results. */
|
||||||
|
gs_console_end_status_line (console, NULL, NULL);
|
||||||
|
|
||||||
|
g_print ("\n");
|
||||||
|
ostree_print_gpg_verify_result (result);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **error)
|
ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||||
{
|
{
|
||||||
|
|
@ -51,6 +65,7 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **
|
||||||
GSConsole *console = NULL;
|
GSConsole *console = NULL;
|
||||||
gs_unref_ptrarray GPtrArray *refs_to_fetch = NULL;
|
gs_unref_ptrarray GPtrArray *refs_to_fetch = NULL;
|
||||||
gs_unref_object OstreeAsyncProgress *progress = NULL;
|
gs_unref_object OstreeAsyncProgress *progress = NULL;
|
||||||
|
gulong signal_handler_id = 0;
|
||||||
|
|
||||||
context = g_option_context_new ("REMOTE [BRANCH...] - Download data from remote repository");
|
context = g_option_context_new ("REMOTE [BRANCH...] - Download data from remote repository");
|
||||||
|
|
||||||
|
|
@ -100,6 +115,9 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **
|
||||||
{
|
{
|
||||||
gs_console_begin_status_line (console, "", NULL, NULL);
|
gs_console_begin_status_line (console, "", NULL, NULL);
|
||||||
progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, console);
|
progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, console);
|
||||||
|
signal_handler_id = g_signal_connect (repo, "gpg-verify-result",
|
||||||
|
G_CALLBACK (gpg_verify_result_cb),
|
||||||
|
console);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -116,7 +134,7 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **
|
||||||
g_variant_new_variant (g_variant_new_strv ((const char *const*) refs_to_fetch->pdata, -1)));
|
g_variant_new_variant (g_variant_new_strv ((const char *const*) refs_to_fetch->pdata, -1)));
|
||||||
g_variant_builder_add (&builder, "{s@v}", "depth",
|
g_variant_builder_add (&builder, "{s@v}", "depth",
|
||||||
g_variant_new_variant (g_variant_new_int32 (opt_depth)));
|
g_variant_new_variant (g_variant_new_int32 (opt_depth)));
|
||||||
|
|
||||||
if (!ostree_repo_pull_with_options (repo, remote, g_variant_builder_end (&builder),
|
if (!ostree_repo_pull_with_options (repo, remote, g_variant_builder_end (&builder),
|
||||||
progress, cancellable, error))
|
progress, cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -127,6 +145,9 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
out:
|
||||||
|
if (signal_handler_id > 0)
|
||||||
|
g_signal_handler_disconnect (repo, signal_handler_id);
|
||||||
|
|
||||||
if (console)
|
if (console)
|
||||||
gs_console_end_status_line (console, NULL, NULL);
|
gs_console_end_status_line (console, NULL, NULL);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -385,3 +385,27 @@ ostree_ensure_repo_writable (OstreeRepo *repo,
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ostree_print_gpg_verify_result (OstreeGpgVerifyResult *result)
|
||||||
|
{
|
||||||
|
GString *buffer;
|
||||||
|
guint n_sigs, ii;
|
||||||
|
|
||||||
|
n_sigs = ostree_gpg_verify_result_count_all (result);
|
||||||
|
|
||||||
|
/* XXX If we ever add internationalization, use ngettext() here. */
|
||||||
|
g_print ("Found %u signature%s:\n", n_sigs, n_sigs == 1 ? "" : "s");
|
||||||
|
|
||||||
|
buffer = g_string_sized_new (256);
|
||||||
|
|
||||||
|
for (ii = 0; ii < n_sigs; ii++)
|
||||||
|
{
|
||||||
|
g_string_append_c (buffer, '\n');
|
||||||
|
ostree_gpg_verify_result_describe (result, ii, buffer, " ",
|
||||||
|
OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_print ("%s", buffer->str);
|
||||||
|
g_string_free (buffer, TRUE);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,3 +59,5 @@ gboolean ostree_admin_option_context_parse (GOptionContext *context,
|
||||||
GCancellable *cancellable, GError **error);
|
GCancellable *cancellable, GError **error);
|
||||||
|
|
||||||
gboolean ostree_ensure_repo_writable (OstreeRepo *repo, GError **error);
|
gboolean ostree_ensure_repo_writable (OstreeRepo *repo, GError **error);
|
||||||
|
|
||||||
|
void ostree_print_gpg_verify_result (OstreeGpgVerifyResult *result);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue