[gnome-builder/wip/chergert/flatpak-all-arches: 134/135] flatpak: bring back support for alt-arches
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/flatpak-all-arches: 134/135] flatpak: bring back support for alt-arches
- Date: Wed, 21 Jul 2021 03:51:58 +0000 (UTC)
commit 6a245aad02648ff27498318044a0fb63d88ccc79
Author: Christian Hergert <chergert redhat com>
Date: Wed May 5 13:43:00 2021 -0700
flatpak: bring back support for alt-arches
This fixes the subsummary issue that crept in when Flatpak removed all
arches from the summaries.
Requires https://github.com/flatpak/flatpak/pull/4256
.../flatpak/daemon/ipc-flatpak-service-impl.c | 38 +++++++++++++++-------
src/plugins/flatpak/daemon/test-flatpak.c | 14 ++++++++
2 files changed, 40 insertions(+), 12 deletions(-)
---
diff --git a/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
b/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
index 0b204bee4..788c3df75 100644
--- a/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
+++ b/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
@@ -493,6 +493,7 @@ is_known_worker (GTask *task,
const char *ref_branch;
gint64 download_size = 0;
gboolean found = FALSE;
+ FlatpakQueryFlags flags = 0;
g_assert (G_IS_TASK (task));
g_assert (IPC_IS_FLATPAK_SERVICE_IMPL (source_object));
@@ -506,6 +507,11 @@ is_known_worker (GTask *task,
ref_arch = flatpak_ref_get_arch (state->target);
ref_branch = flatpak_ref_get_branch (state->target);
+ if (str_equal0 (ref_arch, flatpak_get_default_arch ()))
+ flags |= FLATPAK_QUERY_FLAGS_ONLY_CACHED;
+ else
+ flags |= FLATPAK_QUERY_FLAGS_ALL_ARCHES;
+
for (guint z = 0; z < state->installs->len; z++)
{
FlatpakInstallation *install = g_ptr_array_index (state->installs, z);
@@ -519,7 +525,7 @@ is_known_worker (GTask *task,
const char *remote_name = flatpak_remote_get_name (remote);
g_autoptr(GPtrArray) refs = NULL;
- if (!(refs = flatpak_installation_list_remote_refs_sync (install, remote_name, NULL, NULL)))
+ if (!(refs = flatpak_installation_list_remote_refs_sync_full (install, remote_name, flags, NULL,
NULL)))
continue;
for (guint j = 0; j < refs->len; j++)
@@ -804,13 +810,23 @@ static char *
find_remote_for_ref (IpcFlatpakServiceImpl *self,
FlatpakRef *ref)
{
+ FlatpakQueryFlags flags = FLATPAK_QUERY_FLAGS_NONE;
+
g_assert (IPC_IS_FLATPAK_SERVICE_IMPL (self));
g_assert (FLATPAK_IS_REF (ref));
+ /* If this is not the default architecture, we need to force that we've
+ * loaded sub-summaries or we won't find any matches for the arch. Otherwise
+ * the cached form is fine (and faster).
+ */
+ if (str_equal0 (flatpak_get_default_arch (), flatpak_ref_get_arch (ref)))
+ flags |= FLATPAK_QUERY_FLAGS_ONLY_CACHED;
+ else
+ flags |= FLATPAK_QUERY_FLAGS_ALL_ARCHES;
+
/* Someday we might want to prompt the user for which remote to install from,
* but for now we'll just take the first.
*/
-
for (guint i = 0; i < self->installs_ordered->len; i++)
{
Install *install = g_ptr_array_index (self->installs_ordered, i);
@@ -823,9 +839,7 @@ find_remote_for_ref (IpcFlatpakServiceImpl *self,
{
FlatpakRemote *remote = g_ptr_array_index (remotes, j);
const char *name = flatpak_remote_get_name (remote);
- g_autoptr(GPtrArray) refs = flatpak_installation_list_remote_refs_sync_full
(install->installation, name,
-
FLATPAK_QUERY_FLAGS_ONLY_CACHED,
- NULL, NULL);
+ g_autoptr(GPtrArray) refs = flatpak_installation_list_remote_refs_sync_full
(install->installation, name, flags, NULL, NULL);
if (refs == NULL)
continue;
@@ -972,6 +986,7 @@ resolve_extension (GPtrArray *installations,
g_autoptr(GArray) maybe_extention_of = NULL;
g_autoptr(GArray) runtime_extensions = NULL;
g_autoptr(GStringChunk) strings = NULL;
+ FlatpakQueryFlags flags = FLATPAK_QUERY_FLAGS_NONE;
g_assert (installations != NULL);
g_assert (sdk != NULL);
@@ -987,6 +1002,11 @@ resolve_extension (GPtrArray *installations,
if (sdk_arch == NULL)
sdk_arch = g_strdup (flatpak_get_default_arch ());
+ if (str_equal0 (sdk_arch, flatpak_get_default_arch ()))
+ flags |= FLATPAK_QUERY_FLAGS_ONLY_CACHED;
+ else
+ flags |= FLATPAK_QUERY_FLAGS_ALL_ARCHES;
+
strings = g_string_chunk_new (4096);
maybe_extention_of = g_array_new (FALSE, FALSE, sizeof (ResolveExtension));
runtime_extensions = g_array_new (FALSE, FALSE, sizeof (ResolveExtension));
@@ -1005,13 +1025,7 @@ resolve_extension (GPtrArray *installations,
const char *name = flatpak_remote_get_name (remote);
g_autoptr(GPtrArray) refs = NULL;
- refs = flatpak_installation_list_remote_refs_sync_full (installation,
- name,
- FLATPAK_QUERY_FLAGS_ONLY_CACHED,
- NULL,
- NULL);
-
- if (refs == NULL)
+ if (!(refs = flatpak_installation_list_remote_refs_sync_full (installation, name, flags, NULL,
NULL)))
continue;
for (guint k = 0; k < refs->len; k++)
diff --git a/src/plugins/flatpak/daemon/test-flatpak.c b/src/plugins/flatpak/daemon/test-flatpak.c
index 82a59cacf..fd5012d85 100644
--- a/src/plugins/flatpak/daemon/test-flatpak.c
+++ b/src/plugins/flatpak/daemon/test-flatpak.c
@@ -147,6 +147,20 @@ add_install_cb (GObject *object,
g_message (" Resolved to %s", resolved);
g_assert_cmpstr (resolved, ==, "org.freedesktop.Sdk.Extension.rust-stable/x86_64/20.08");
+ g_message ("Resolving org.freedesktop.Sdk.Extension.rust-stable for org.gnome.Sdk/aarch64/40");
+ ret = ipc_flatpak_service_call_resolve_extension_sync (service, "org.gnome.Sdk/aarch64/40",
"org.freedesktop.Sdk.Extension.rust-stable", &resolved, NULL, &error);
+ g_assert_no_error (error);
+ g_assert_true (ret);
+ g_message (" Resolved to %s", resolved);
+ g_assert_cmpstr (resolved, ==, "org.freedesktop.Sdk.Extension.rust-stable/aarch64/20.08");
+
+ g_message ("Resolving org.freedesktop.Sdk.Extension.rust-stable for org.gnome.Sdk/aarch64/master");
+ ret = ipc_flatpak_service_call_resolve_extension_sync (service, "org.gnome.Sdk/aarch64/master",
"org.freedesktop.Sdk.Extension.rust-stable", &resolved, NULL, &error);
+ g_assert_no_error (error);
+ g_assert_true (ret);
+ g_message (" Resolved to %s", resolved);
+ g_assert_cmpstr (resolved, ==, "org.freedesktop.Sdk.Extension.rust-stable/aarch64/20.08");
+
g_main_loop_quit (main_loop);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]