upgrade: Print any GPG signatures while upgrading
This commit is contained in:
parent
3e6f877282
commit
750a8889f0
@ -99,6 +99,31 @@ rpmostree_option_context_parse (GOptionContext *context,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
rpmostree_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 ("GPG: Verification enabled, 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\n", buffer->str);
|
||||
g_string_free (buffer, TRUE);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
|
@ -45,6 +45,20 @@ static GOptionEntry option_entries[] = {
|
||||
{ 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");
|
||||
rpmostree_print_gpg_verify_result (result);
|
||||
}
|
||||
|
||||
gboolean
|
||||
rpmostree_builtin_upgrade (int argc,
|
||||
char **argv,
|
||||
@ -63,6 +77,7 @@ rpmostree_builtin_upgrade (int argc,
|
||||
|
||||
gs_free char *origin_description = NULL;
|
||||
gs_unref_object OstreeRepo *repo = NULL;
|
||||
gulong signal_handler_id = 0;
|
||||
|
||||
if (!rpmostree_option_context_parse (context, option_entries, &argc, &argv, error))
|
||||
goto out;
|
||||
@ -89,6 +104,10 @@ rpmostree_builtin_upgrade (int argc,
|
||||
{
|
||||
gs_console_begin_status_line (console, "", NULL, NULL);
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
if (opt_allow_downgrade)
|
||||
@ -185,5 +204,8 @@ rpmostree_builtin_upgrade (int argc,
|
||||
if (console)
|
||||
(void) gs_console_end_status_line (console, NULL, NULL);
|
||||
|
||||
if (signal_handler_id > 0)
|
||||
g_signal_handler_disconnect (repo, signal_handler_id);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -46,5 +46,7 @@ gboolean rpmostree_option_context_parse (GOptionContext *context,
|
||||
char ***argv,
|
||||
GError **error);
|
||||
|
||||
void rpmostree_print_gpg_verify_result (OstreeGpgVerifyResult *result);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user