[gnome-software: 3/6] flatpak: Follow end-of-life-rebase redirects
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 3/6] flatpak: Follow end-of-life-rebase redirects
- Date: Thu, 3 Dec 2020 14:35:51 +0000 (UTC)
commit c4c80869e015fb48b4faaf2f9bd6f0f46859a4a0
Author: Phaedrus Leeds <mwleeds endlessos org>
Date: Wed Nov 4 12:50:28 2020 -0800
flatpak: Follow end-of-life-rebase redirects
When an app is renamed, appropriate metadata is set server-side so that
FlatpakTransaction::end-of-lifed-with-rebase is emitted. On the CLI the
user can choose whether to install the renamed app. GNOME Software
currently ignores the signal so such apps stay on their old names
forever. This commit makes g-s follow such redirects and install the new
app without user interaction, since that is what most users will want. A
follow-up commit will add a message in the UI so the user can be
informed in case the application's name is changing (as opposed to only
the application ID changing, which shouldn't be user-visible).
Note that in the special case where the installed commit is the one with
the eol-rebase metadata (as opposed to being an older commit), such apps
will not be returned by
flatpak_installation_list_installed_refs_for_update() without this
patch: https://github.com/flatpak/flatpak/pull/3945
plugins/flatpak/gs-flatpak-transaction.c | 40 ++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
---
diff --git a/plugins/flatpak/gs-flatpak-transaction.c b/plugins/flatpak/gs-flatpak-transaction.c
index d35ec5d1..4a74a0d7 100644
--- a/plugins/flatpak/gs-flatpak-transaction.c
+++ b/plugins/flatpak/gs-flatpak-transaction.c
@@ -710,6 +710,43 @@ _transaction_end_of_lifed (FlatpakTransaction *transaction,
//FIXME: show something in the UI
}
+#if FLATPAK_CHECK_VERSION(1,4,1)
+static gboolean
+_transaction_end_of_lifed_with_rebase (FlatpakTransaction *transaction,
+ const gchar *remote,
+ const gchar *ref,
+ const gchar *reason,
+ const gchar *rebased_to_ref,
+ const gchar **previous_ids)
+{
+ if (rebased_to_ref) {
+ g_message ("%s is end-of-life, in favor of %s", ref, rebased_to_ref);
+ } else if (reason) {
+ g_message ("%s is end-of-life, with reason: %s", ref, reason);
+ }
+
+ if (rebased_to_ref && remote) {
+ g_autoptr(GError) local_error = NULL;
+
+ //FIXME: show something in the UI
+ if (!flatpak_transaction_add_rebase (transaction, remote, rebased_to_ref,
+ NULL, previous_ids, &local_error) ||
+ !flatpak_transaction_add_uninstall (transaction, ref, &local_error)) {
+ /* There's no way to make the whole transaction fail on
+ * this error path, so just print a warning and return
+ * FALSE, which will cause the operation on the
+ * end-of-lifed ref not to be skipped.
+ */
+ g_warning ("Failed to rebase %s to %s: %s", ref, rebased_to_ref,
local_error->message);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ return FALSE;
+}
+#endif
+
static gboolean
_transaction_add_new_remote (FlatpakTransaction *transaction,
FlatpakTransactionRemoteReason reason,
@@ -766,6 +803,9 @@ gs_flatpak_transaction_class_init (GsFlatpakTransactionClass *klass)
transaction_class->operation_error = _transaction_operation_error;
transaction_class->choose_remote_for_ref = _transaction_choose_remote_for_ref;
transaction_class->end_of_lifed = _transaction_end_of_lifed;
+#if FLATPAK_CHECK_VERSION(1,4,1)
+ transaction_class->end_of_lifed_with_rebase = _transaction_end_of_lifed_with_rebase;
+#endif
#if !FLATPAK_CHECK_VERSION(1,5,1)
object_class->set_property = gs_flatpak_transaction_set_property;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]