cli-transaction: Use the new rebase support

Switch to the new eol signal and call flatpak_transaction_add_rebase()
if a rebase was requested.

Closes: #2775
Approved by: alexlarsson
This commit is contained in:
Ryan Gonzalez
2019-03-30 16:37:15 -05:00
committed by Atomic Bot
parent 7185a00c85
commit 7357b2bc63

View File

@@ -501,35 +501,48 @@ operation_error (FlatpakTransaction *transaction,
return TRUE; /* Continue */
}
static void
end_of_lifed (FlatpakTransaction *transaction,
const char *ref,
const char *reason,
const char *rebase)
static gboolean
end_of_lifed_with_rebase (FlatpakTransaction *transaction,
const char *remote,
const char *ref,
const char *reason,
const char *rebased_to_ref,
const char **previous_ids)
{
FlatpakCliTransaction *self = FLATPAK_CLI_TRANSACTION (transaction);
g_autoptr(FlatpakRef) rref = flatpak_ref_parse (ref, NULL);
g_autofree char *msg = NULL;
if (rebase)
msg = g_strdup_printf (_("Info: %s is end-of-life, in preference of %s"),
flatpak_ref_get_name (rref), rebase);
if (rebased_to_ref)
g_print (_("Info: %s is end-of-life, in preference of %s\n"), flatpak_ref_get_name (rref), rebased_to_ref);
else if (reason)
msg = g_strdup_printf (_("Info: %s is end-of-life, with reason: %s\n"),
flatpak_ref_get_name (rref), reason);
g_print (_("Info: %s is end-of-life, with reason: %s\n"), flatpak_ref_get_name (rref), reason);
if (flatpak_fancy_output ())
if (rebased_to_ref && remote)
{
flatpak_table_printer_set_cell (self->printer, self->progress_row, 0, msg);
self->progress_row++;
flatpak_table_printer_add_span (self->printer, "");
flatpak_table_printer_finish_row (self->printer);
redraw (self);
}
else
g_print ("\r%-*s\n", self->table_width, msg);
}
if (self->disable_interaction ||
flatpak_yes_no_prompt (FALSE, _("Replace it with %s?"), flatpak_ref_get_name (rref)))
{
g_autoptr(GError) error = NULL;
if (self->disable_interaction)
g_print (_("Updating to rebased version\n"));
if (!flatpak_transaction_add_uninstall (transaction, ref, &error) ||
!flatpak_transaction_add_rebase (transaction, remote, rebased_to_ref, NULL, previous_ids, &error))
{
g_propagate_prefixed_error (&self->first_operation_error,
g_error_copy (error),
_("Failed to rebase %s to %s: "),
flatpak_ref_get_name (rref), rebased_to_ref);
return FALSE;
}
return TRUE;
}
}
return FALSE;
}
static int
cmpstringp (const void *p1, const void *p2)
@@ -1039,7 +1052,7 @@ flatpak_cli_transaction_class_init (FlatpakCliTransactionClass *klass)
transaction_class->operation_done = operation_done;
transaction_class->operation_error = operation_error;
transaction_class->choose_remote_for_ref = choose_remote_for_ref;
transaction_class->end_of_lifed = end_of_lifed;
transaction_class->end_of_lifed_with_rebase = end_of_lifed_with_rebase;
transaction_class->run = flatpak_cli_transaction_run;
}