[gnome-software] flatpak: Always install the correct runtime architecture



commit 4b7087ccf3cee5d745166eccc4067ce179994331
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jul 17 19:57:23 2017 +0100

    flatpak: Always install the correct runtime architecture
    
    We need to filter by architecture if more than one version is available

 plugins/flatpak/gs-flatpak.c        |   33 +++++++++++++++++------------
 plugins/flatpak/gs-flatpak.h        |    4 ++-
 plugins/flatpak/gs-plugin-flatpak.c |   39 +++++++++++++++++++---------------
 3 files changed, 44 insertions(+), 32 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 1997b8b..7525c40 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -902,12 +902,14 @@ gs_flatpak_find_source_by_url (GsFlatpak *self,
 }
 
 gboolean
-gs_flatpak_find_app_by_name_branch (GsFlatpak *self,
-                                   const gchar *name,
-                                   const gchar *branch,
-                                   GsAppList *list,
-                                   GCancellable *cancellable,
-                                   GError **error)
+gs_flatpak_find_app (GsFlatpak *self,
+                    FlatpakRefKind kind,
+                    const gchar *name,
+                    const gchar *arch,
+                    const gchar *branch,
+                    GsAppList *list,
+                    GCancellable *cancellable,
+                    GError **error)
 {
        g_autoptr(GPtrArray) xremotes = NULL;
        g_autoptr(GPtrArray) xrefs = NULL;
@@ -927,7 +929,9 @@ gs_flatpak_find_app_by_name_branch (GsFlatpak *self,
        /* look at each installed xref */
        for (guint i = 0; i < xrefs->len; i++) {
                FlatpakInstalledRef *xref = g_ptr_array_index (xrefs, i);
-               if (g_strcmp0 (flatpak_ref_get_name (FLATPAK_REF (xref)), name) == 0 &&
+               if (flatpak_ref_get_kind (FLATPAK_REF (xref)) == kind &&
+                   g_strcmp0 (flatpak_ref_get_name (FLATPAK_REF (xref)), name) == 0 &&
+                   g_strcmp0 (flatpak_ref_get_arch (FLATPAK_REF (xref)), arch) == 0 &&
                    g_strcmp0 (flatpak_ref_get_branch (FLATPAK_REF (xref)), branch) == 0) {
                        g_autoptr(GsApp) app = gs_flatpak_create_installed (self, xref, error);
                        if (app == NULL)
@@ -954,7 +958,9 @@ gs_flatpak_find_app_by_name_branch (GsFlatpak *self,
                }
                for (guint j = 0; j < refs_remote->len; j++) {
                        FlatpakRef *xref = g_ptr_array_index (refs_remote, j);
-                       if (g_strcmp0 (flatpak_ref_get_name (xref), name) == 0 &&
+                       if (flatpak_ref_get_kind (FLATPAK_REF (xref)) == kind &&
+                           g_strcmp0 (flatpak_ref_get_name (xref), name) == 0 &&
+                           g_strcmp0 (flatpak_ref_get_arch (xref), arch) == 0 &&
                            g_strcmp0 (flatpak_ref_get_branch (xref), branch) == 0) {
                                g_autoptr(GsApp) app = gs_flatpak_create_app (self, xref);
 
@@ -1394,6 +1400,7 @@ gs_plugin_refine_item_origin (GsFlatpak *self,
                              GCancellable *cancellable,
                              GError **error)
 {
+       g_autofree gchar *ref_display = NULL;
        g_autoptr(AsProfileTask) ptask = NULL;
        g_autoptr(GError) local_error = NULL;
 
@@ -1414,10 +1421,8 @@ gs_plugin_refine_item_origin (GsFlatpak *self,
                return FALSE;
 
        /* find list of remotes */
-       g_debug ("looking for a remote for %s/%s/%s",
-                gs_flatpak_app_get_ref_name (app),
-                gs_flatpak_app_get_ref_arch (app),
-                gs_flatpak_app_get_ref_branch (app));
+       ref_display = gs_flatpak_app_get_ref_display (app);
+       g_debug ("looking for a remote for %s", ref_display);
 
        /* first check the plugin's own flatpak installation */
        if (!gs_flatpak_refine_origin_from_installation (self,
@@ -2217,8 +2222,8 @@ gs_flatpak_launch (GsFlatpak *self,
        /* launch the app */
        if (!flatpak_installation_launch (self->installation,
                                          gs_flatpak_app_get_ref_name (app),
-                                         NULL,
-                                         branch,
+                                         gs_flatpak_app_get_ref_arch (app),
+                                         gs_flatpak_app_get_ref_branch (app),
                                          NULL,
                                          cancellable,
                                          error)) {
diff --git a/plugins/flatpak/gs-flatpak.h b/plugins/flatpak/gs-flatpak.h
index 5b60a3e..09fae48 100644
--- a/plugins/flatpak/gs-flatpak.h
+++ b/plugins/flatpak/gs-flatpak.h
@@ -108,8 +108,10 @@ gboolean    gs_flatpak_find_source_by_url  (GsFlatpak              *self,
                                                 GsAppList              *list,
                                                 GCancellable           *cancellable,
                                                 GError                 **error);
-gboolean        gs_flatpak_find_app_by_name_branch (GsFlatpak          *self,
+gboolean        gs_flatpak_find_app            (GsFlatpak              *self,
+                                                FlatpakRefKind          kind,
                                                 const gchar            *id,
+                                                const gchar            *arch,
                                                 const gchar            *branch,
                                                 GsAppList              *list,
                                                 GCancellable           *cancellable,
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index 9274ed9..9699bc0 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -512,10 +512,12 @@ gs_plugin_flatpak_file_to_app_bundle (GsPlugin *plugin,
        list_tmp = gs_app_list_new ();
        for (guint i = 0; i < priv->flatpaks->len; i++) {
                GsFlatpak *flatpak = g_ptr_array_index (priv->flatpaks, i);
-               if (!gs_flatpak_find_app_by_name_branch (flatpak,
-                                                        gs_flatpak_app_get_ref_name (app_tmp),
-                                                        gs_flatpak_app_get_ref_branch (app_tmp),
-                                                        list_tmp, cancellable, error))
+               if (!gs_flatpak_find_app (flatpak,
+                                         gs_flatpak_app_get_ref_kind (app_tmp),
+                                         gs_flatpak_app_get_ref_name (app_tmp),
+                                         gs_flatpak_app_get_ref_arch (app_tmp),
+                                         gs_flatpak_app_get_ref_branch (app_tmp),
+                                         list_tmp, cancellable, error))
                        return FALSE;
        }
        for (guint i = 0; i < gs_app_list_length (list_tmp); i++) {
@@ -565,10 +567,12 @@ gs_plugin_flatpak_file_to_app_ref (GsPlugin *plugin,
        list_tmp = gs_app_list_new ();
        for (guint i = 0; i < priv->flatpaks->len; i++) {
                GsFlatpak *flatpak = g_ptr_array_index (priv->flatpaks, i);
-               if (!gs_flatpak_find_app_by_name_branch (flatpak,
-                                                        gs_flatpak_app_get_ref_name (app_tmp),
-                                                        gs_flatpak_app_get_ref_branch (app_tmp),
-                                                        list_tmp, cancellable, error))
+               if (!gs_flatpak_find_app (flatpak,
+                                         gs_flatpak_app_get_ref_kind (app_tmp),
+                                         gs_flatpak_app_get_ref_name (app_tmp),
+                                         gs_flatpak_app_get_ref_arch (app_tmp),
+                                         gs_flatpak_app_get_ref_branch (app_tmp),
+                                         list_tmp, cancellable, error))
                        return FALSE;
        }
        for (guint i = 0; i < gs_app_list_length (list_tmp); i++) {
@@ -589,18 +593,19 @@ gs_plugin_flatpak_file_to_app_ref (GsPlugin *plugin,
        runtime_app = gs_app_get_runtime (app_tmp);
        if (runtime_app != NULL &&
            gs_app_get_state (runtime_app) != AS_APP_STATE_INSTALLED) {
+               g_autofree gchar *ref_display = gs_flatpak_app_get_ref_display (runtime_app);
                g_autoptr(GsAppList) list_runtimes = gs_app_list_new ();
                for (guint i = 0; i < priv->flatpaks->len; i++) {
                        GsFlatpak *flatpak = g_ptr_array_index (priv->flatpaks, i);
-                       g_debug ("looking for %s//%s in %s",
-                                gs_flatpak_app_get_ref_name (runtime_app),
-                                gs_flatpak_app_get_ref_branch (runtime_app),
-                                gs_flatpak_get_id (flatpak));
-                       if (!gs_flatpak_find_app_by_name_branch (flatpak,
-                                                                gs_flatpak_app_get_ref_name (runtime_app),
-                                                                gs_flatpak_app_get_ref_branch (runtime_app),
-                                                                list_runtimes,
-                                                                cancellable, error))
+                       g_debug ("looking for %s in %s",
+                                ref_display, gs_flatpak_get_id (flatpak));
+                       if (!gs_flatpak_find_app (flatpak,
+                                                 gs_flatpak_app_get_ref_kind (runtime_app),
+                                                 gs_flatpak_app_get_ref_name (runtime_app),
+                                                 gs_flatpak_app_get_ref_arch (runtime_app),
+                                                 gs_flatpak_app_get_ref_branch (runtime_app),
+                                                 list_runtimes,
+                                                 cancellable, error))
                                return FALSE;
                }
                for (guint i = 0; i < gs_app_list_length (list_runtimes); i++) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]