332 lines
12 KiB
Diff
332 lines
12 KiB
Diff
From 03ea59cc8db6bec34d56205d62ec495315e9ea96 Mon Sep 17 00:00:00 2001
|
|
From: Milan Crha <mcrha@redhat.com>
|
|
Date: Tue, 21 Sep 2021 13:55:57 +0200
|
|
Subject: [PATCH 1/5] gs-page: Use correct action when install/remove repo app
|
|
|
|
Since the split of the install/remove action for apps and repos
|
|
the GsPage should use correct action too. This can happen for example
|
|
when installing a .flatpakrepo file.
|
|
---
|
|
src/gs-page.c | 10 ++++++++--
|
|
1 file changed, 8 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/gs-page.c b/src/gs-page.c
|
|
index ca1fbfc70..dfaadbc39 100644
|
|
--- a/src/gs-page.c
|
|
+++ b/src/gs-page.c
|
|
@@ -280,7 +280,10 @@ gs_page_install_app (GsPage *page,
|
|
}
|
|
|
|
helper = g_slice_new0 (GsPageHelper);
|
|
- helper->action = GS_PLUGIN_ACTION_INSTALL;
|
|
+ if (gs_app_get_kind (app) == AS_COMPONENT_KIND_REPOSITORY)
|
|
+ helper->action = GS_PLUGIN_ACTION_INSTALL_REPO;
|
|
+ else
|
|
+ helper->action = GS_PLUGIN_ACTION_INSTALL;
|
|
helper->app = g_object_ref (app);
|
|
helper->page = g_object_ref (page);
|
|
helper->cancellable = g_object_ref (cancellable);
|
|
@@ -466,7 +469,10 @@ gs_page_remove_app (GsPage *page, GsApp *app, GCancellable *cancellable)
|
|
|
|
/* pending install */
|
|
helper = g_slice_new0 (GsPageHelper);
|
|
- helper->action = GS_PLUGIN_ACTION_REMOVE;
|
|
+ if (gs_app_get_kind (app) == AS_COMPONENT_KIND_REPOSITORY)
|
|
+ helper->action = GS_PLUGIN_ACTION_REMOVE_REPO;
|
|
+ else
|
|
+ helper->action = GS_PLUGIN_ACTION_REMOVE;
|
|
helper->app = g_object_ref (app);
|
|
helper->page = g_object_ref (page);
|
|
helper->cancellable = cancellable != NULL ? g_object_ref (cancellable) : NULL;
|
|
--
|
|
GitLab
|
|
|
|
|
|
From 576f9e6d25fcd3edd7fdf769e342a382af1307e3 Mon Sep 17 00:00:00 2001
|
|
From: Milan Crha <mcrha@redhat.com>
|
|
Date: Tue, 21 Sep 2021 13:58:03 +0200
|
|
Subject: [PATCH 2/5] flatpak: Save also remote's filter on the flatpak-app
|
|
|
|
This can be used when updating existing remote, to reflect the new
|
|
filter. It can be also used to verify the installed and existing
|
|
remotes match with its filter.
|
|
---
|
|
plugins/flatpak/gs-flatpak-app.c | 12 ++++++++++++
|
|
plugins/flatpak/gs-flatpak-app.h | 3 +++
|
|
2 files changed, 15 insertions(+)
|
|
|
|
diff --git a/plugins/flatpak/gs-flatpak-app.c b/plugins/flatpak/gs-flatpak-app.c
|
|
index cf98248a8..b59515b2f 100644
|
|
--- a/plugins/flatpak/gs-flatpak-app.c
|
|
+++ b/plugins/flatpak/gs-flatpak-app.c
|
|
@@ -176,3 +176,15 @@ gs_flatpak_app_get_main_app_ref_name (GsApp *app)
|
|
{
|
|
return gs_app_get_metadata_item (app, "flatpak::mainApp");
|
|
}
|
|
+
|
|
+void
|
|
+gs_flatpak_app_set_repo_filter (GsApp *app, const gchar *filter)
|
|
+{
|
|
+ gs_app_set_metadata (app, "flatpak::RepoFilter", filter);
|
|
+}
|
|
+
|
|
+const gchar *
|
|
+gs_flatpak_app_get_repo_filter (GsApp *app)
|
|
+{
|
|
+ return gs_app_get_metadata_item (app, "flatpak::RepoFilter");
|
|
+}
|
|
diff --git a/plugins/flatpak/gs-flatpak-app.h b/plugins/flatpak/gs-flatpak-app.h
|
|
index ab6c10af4..610c8a8f3 100644
|
|
--- a/plugins/flatpak/gs-flatpak-app.h
|
|
+++ b/plugins/flatpak/gs-flatpak-app.h
|
|
@@ -58,5 +58,8 @@ void gs_flatpak_app_set_runtime_url (GsApp *app,
|
|
void gs_flatpak_app_set_main_app_ref_name (GsApp *app,
|
|
const gchar *main_app_ref);
|
|
const gchar *gs_flatpak_app_get_main_app_ref_name (GsApp *app);
|
|
+void gs_flatpak_app_set_repo_filter (GsApp *app,
|
|
+ const gchar *filter);
|
|
+const gchar *gs_flatpak_app_get_repo_filter (GsApp *app);
|
|
|
|
G_END_DECLS
|
|
--
|
|
GitLab
|
|
|
|
|
|
From cb809158e81157b53245e4c290ada418d5bcd03d Mon Sep 17 00:00:00 2001
|
|
From: Milan Crha <mcrha@redhat.com>
|
|
Date: Tue, 21 Sep 2021 14:02:47 +0200
|
|
Subject: [PATCH 3/5] flatpak: Store filter and description on a remote app
|
|
|
|
Store the description also on an installed remote, not only on the file
|
|
remote. Similarly store also the filters for the remotes.
|
|
---
|
|
plugins/flatpak/gs-flatpak-utils.c | 14 ++++++++++++++
|
|
1 file changed, 14 insertions(+)
|
|
|
|
diff --git a/plugins/flatpak/gs-flatpak-utils.c b/plugins/flatpak/gs-flatpak-utils.c
|
|
index 8b107b37c..7aa735b0b 100644
|
|
--- a/plugins/flatpak/gs-flatpak-utils.c
|
|
+++ b/plugins/flatpak/gs-flatpak-utils.c
|
|
@@ -72,6 +72,8 @@ gs_flatpak_app_new_from_remote (GsPlugin *plugin,
|
|
{
|
|
g_autofree gchar *title = NULL;
|
|
g_autofree gchar *url = NULL;
|
|
+ g_autofree gchar *filter = NULL;
|
|
+ g_autofree gchar *description = NULL;
|
|
g_autoptr(GsApp) app = NULL;
|
|
|
|
app = gs_flatpak_app_new (flatpak_remote_get_name (xremote));
|
|
@@ -101,11 +103,19 @@ gs_flatpak_app_new_from_remote (GsPlugin *plugin,
|
|
* not the remote title */
|
|
gs_app_set_origin_ui (app, _("Applications"));
|
|
|
|
+ description = flatpak_remote_get_description (xremote);
|
|
+ if (description != NULL)
|
|
+ gs_app_set_description (app, GS_APP_QUALITY_NORMAL, description);
|
|
+
|
|
/* url */
|
|
url = flatpak_remote_get_url (xremote);
|
|
if (url != NULL)
|
|
gs_app_set_url (app, AS_URL_KIND_HOMEPAGE, url);
|
|
|
|
+ filter = flatpak_remote_get_filter (xremote);
|
|
+ if (filter != NULL)
|
|
+ gs_flatpak_app_set_repo_filter (app, filter);
|
|
+
|
|
/* success */
|
|
return g_steal_pointer (&app);
|
|
}
|
|
@@ -127,6 +137,7 @@ gs_flatpak_app_new_from_repo_file (GFile *file,
|
|
g_autofree gchar *repo_id = NULL;
|
|
g_autofree gchar *repo_title = NULL;
|
|
g_autofree gchar *repo_url = NULL;
|
|
+ g_autofree gchar *repo_filter = NULL;
|
|
g_autoptr(GError) error_local = NULL;
|
|
g_autoptr(GKeyFile) kf = NULL;
|
|
g_autoptr(GsApp) app = NULL;
|
|
@@ -229,6 +240,9 @@ gs_flatpak_app_new_from_repo_file (GFile *file,
|
|
g_autoptr(GIcon) icon = gs_remote_icon_new (repo_icon);
|
|
gs_app_add_icon (app, icon);
|
|
}
|
|
+ repo_filter = g_key_file_get_string (kf, "Flatpak Repo", "Filter", NULL);
|
|
+ if (repo_filter != NULL && *repo_filter != '\0')
|
|
+ gs_flatpak_app_set_repo_filter (app, repo_filter);
|
|
|
|
/* success */
|
|
return g_steal_pointer (&app);
|
|
--
|
|
GitLab
|
|
|
|
|
|
From a4f8501e3e54b702b5ff2af4bb9aaf6f8d6c324c Mon Sep 17 00:00:00 2001
|
|
From: Milan Crha <mcrha@redhat.com>
|
|
Date: Tue, 21 Sep 2021 14:05:03 +0200
|
|
Subject: [PATCH 4/5] flatpak: Match existing and file remote only if it
|
|
matches also the filter
|
|
|
|
The filter can change the content, thus match two remotes only if also
|
|
the filter matches.
|
|
---
|
|
plugins/flatpak/gs-plugin-flatpak.c | 2 ++
|
|
1 file changed, 2 insertions(+)
|
|
|
|
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
|
|
index 9bdfa80bf..29ba29700 100644
|
|
--- a/plugins/flatpak/gs-plugin-flatpak.c
|
|
+++ b/plugins/flatpak/gs-plugin-flatpak.c
|
|
@@ -1287,6 +1287,8 @@ gs_plugin_flatpak_file_to_app_repo (GsPlugin *plugin,
|
|
g_debug ("%s", error_local->message);
|
|
continue;
|
|
}
|
|
+ if (g_strcmp0 (gs_flatpak_app_get_repo_filter (app), gs_flatpak_app_get_repo_filter (app_tmp)) != 0)
|
|
+ continue;
|
|
return g_steal_pointer (&app_tmp);
|
|
}
|
|
|
|
--
|
|
GitLab
|
|
|
|
|
|
From 2a94efbda64d94ba6ac27cfd08190b62f52df000 Mon Sep 17 00:00:00 2001
|
|
From: Milan Crha <mcrha@redhat.com>
|
|
Date: Tue, 21 Sep 2021 14:06:35 +0200
|
|
Subject: [PATCH 5/5] flatpak: Update existing remote from a .flatpakref file
|
|
|
|
Update existing remote's title, description and filter when installing
|
|
a .flatpakref file, to match what had been installed, with new-enough
|
|
flatpak library.
|
|
|
|
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1453
|
|
---
|
|
plugins/flatpak/gs-flatpak-utils.c | 6 ++++++
|
|
plugins/flatpak/gs-flatpak.c | 11 +++++++++--
|
|
2 files changed, 15 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/plugins/flatpak/gs-flatpak-utils.c b/plugins/flatpak/gs-flatpak-utils.c
|
|
index 7aa735b0b..ec0b397e3 100644
|
|
--- a/plugins/flatpak/gs-flatpak-utils.c
|
|
+++ b/plugins/flatpak/gs-flatpak-utils.c
|
|
@@ -72,8 +72,10 @@ gs_flatpak_app_new_from_remote (GsPlugin *plugin,
|
|
{
|
|
g_autofree gchar *title = NULL;
|
|
g_autofree gchar *url = NULL;
|
|
+ #if FLATPAK_CHECK_VERSION(1, 4, 0)
|
|
g_autofree gchar *filter = NULL;
|
|
g_autofree gchar *description = NULL;
|
|
+ #endif
|
|
g_autoptr(GsApp) app = NULL;
|
|
|
|
app = gs_flatpak_app_new (flatpak_remote_get_name (xremote));
|
|
@@ -103,18 +105,22 @@ gs_flatpak_app_new_from_remote (GsPlugin *plugin,
|
|
* not the remote title */
|
|
gs_app_set_origin_ui (app, _("Applications"));
|
|
|
|
+ #if FLATPAK_CHECK_VERSION(1, 4, 0)
|
|
description = flatpak_remote_get_description (xremote);
|
|
if (description != NULL)
|
|
gs_app_set_description (app, GS_APP_QUALITY_NORMAL, description);
|
|
+ #endif
|
|
|
|
/* url */
|
|
url = flatpak_remote_get_url (xremote);
|
|
if (url != NULL)
|
|
gs_app_set_url (app, AS_URL_KIND_HOMEPAGE, url);
|
|
|
|
+ #if FLATPAK_CHECK_VERSION(1, 4, 0)
|
|
filter = flatpak_remote_get_filter (xremote);
|
|
if (filter != NULL)
|
|
gs_flatpak_app_set_repo_filter (app, filter);
|
|
+ #endif
|
|
|
|
/* success */
|
|
return g_steal_pointer (&app);
|
|
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
|
|
index 55a91af2a..fa7df00c9 100644
|
|
--- a/plugins/flatpak/gs-flatpak.c
|
|
+++ b/plugins/flatpak/gs-flatpak.c
|
|
@@ -1608,9 +1608,16 @@ gs_flatpak_app_install_source (GsFlatpak *self,
|
|
gs_app_get_id (app),
|
|
cancellable, NULL);
|
|
if (xremote != NULL) {
|
|
- /* if the remote already exists, just enable it */
|
|
- g_debug ("enabling existing remote %s", flatpak_remote_get_name (xremote));
|
|
+ /* if the remote already exists, just enable it and update it */
|
|
+ g_debug ("modifying existing remote %s", flatpak_remote_get_name (xremote));
|
|
flatpak_remote_set_disabled (xremote, FALSE);
|
|
+ if (gs_flatpak_app_get_file_kind (app) == GS_FLATPAK_APP_FILE_KIND_REPO) {
|
|
+ flatpak_remote_set_title (xremote, gs_app_get_origin_ui (app));
|
|
+ #if FLATPAK_CHECK_VERSION(1, 4, 0)
|
|
+ flatpak_remote_set_filter (xremote, gs_flatpak_app_get_repo_filter (app));
|
|
+ flatpak_remote_set_description (xremote, gs_app_get_description (app));
|
|
+ #endif
|
|
+ }
|
|
} else if (!is_install) {
|
|
g_set_error (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED, "Cannot enable flatpak remote '%s', remote not found", gs_app_get_id (app));
|
|
} else {
|
|
--
|
|
GitLab
|
|
|
|
From 1a32bd3eaaf7ec0322c46599e3b949080a410806 Mon Sep 17 00:00:00 2001
|
|
From: Milan Crha <mcrha@redhat.com>
|
|
Date: Thu, 7 Oct 2021 19:28:38 +0200
|
|
Subject: [PATCH] flatpak: Update remote appstream data when its filter changed
|
|
|
|
When overwriting existing remote, make sure the appstream data is updated
|
|
as well when the filter changed, to have shown relevant applications.
|
|
|
|
Related to https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1453
|
|
---
|
|
plugins/flatpak/gs-flatpak.c | 18 +++++++++++++++++-
|
|
1 file changed, 17 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
|
|
index bd87d57ed..88bb69a72 100644
|
|
--- a/plugins/flatpak/gs-flatpak.c
|
|
+++ b/plugins/flatpak/gs-flatpak.c
|
|
@@ -1623,6 +1623,9 @@ gs_flatpak_app_install_source (GsFlatpak *self,
|
|
GError **error)
|
|
{
|
|
g_autoptr(FlatpakRemote) xremote = NULL;
|
|
+ #if FLATPAK_CHECK_VERSION(1, 4, 0)
|
|
+ gboolean filter_changed = FALSE;
|
|
+ #endif
|
|
|
|
xremote = flatpak_installation_get_remote_by_name (self->installation,
|
|
gs_app_get_id (app),
|
|
@@ -1632,11 +1635,13 @@ gs_flatpak_app_install_source (GsFlatpak *self,
|
|
g_debug ("modifying existing remote %s", flatpak_remote_get_name (xremote));
|
|
flatpak_remote_set_disabled (xremote, FALSE);
|
|
if (gs_flatpak_app_get_file_kind (app) == GS_FLATPAK_APP_FILE_KIND_REPO) {
|
|
- flatpak_remote_set_title (xremote, gs_app_get_origin_ui (app));
|
|
#if FLATPAK_CHECK_VERSION(1, 4, 0)
|
|
+ g_autofree gchar *current_filter = flatpak_remote_get_filter (xremote);
|
|
+ filter_changed = g_strcmp0 (current_filter, gs_flatpak_app_get_repo_filter (app)) != 0;
|
|
flatpak_remote_set_filter (xremote, gs_flatpak_app_get_repo_filter (app));
|
|
flatpak_remote_set_description (xremote, gs_app_get_description (app));
|
|
#endif
|
|
+ flatpak_remote_set_title (xremote, gs_app_get_origin_ui (app));
|
|
}
|
|
} else if (!is_install) {
|
|
g_set_error (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED, "Cannot enable flatpak remote '%s', remote not found", gs_app_get_id (app));
|
|
@@ -1666,6 +1671,17 @@ gs_flatpak_app_install_source (GsFlatpak *self,
|
|
/* success */
|
|
gs_app_set_state (app, GS_APP_STATE_INSTALLED);
|
|
|
|
+ #if FLATPAK_CHECK_VERSION(1, 4, 0)
|
|
+ if (filter_changed) {
|
|
+ g_autoptr(GError) local_error = NULL;
|
|
+ const gchar *remote_name = flatpak_remote_get_name (xremote);
|
|
+ if (!flatpak_installation_update_appstream_sync (self->installation, remote_name, NULL, NULL, cancellable, &local_error) &&
|
|
+ !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
|
|
+ g_warning ("Failed to update appstream data for flatpak remote '%s': %s",
|
|
+ remote_name, local_error->message);
|
|
+ }
|
|
+ }
|
|
+ #endif
|
|
gs_plugin_repository_changed (self->plugin, app);
|
|
|
|
return TRUE;
|
|
--
|
|
GitLab
|
|
|