[gnome-software/wip/mcrha/m733-to-gnome-40] gs-plugin-repos: Special-case when rpm repo name doesn't match appstream origin



commit 83373ecfb45fb6472d731754221930891b2b3657
Author: Milan Crha <mcrha redhat com>
Date:   Wed May 5 18:37:47 2021 +0200

    gs-plugin-repos: Special-case when rpm repo name doesn't match appstream origin
    
    For example rpmfusion uses "rpmfusion-free" as the repo name, but the appstream's
    origin is set to "rpmfusion-free-NN", where the NN is a Fedora version number.
    Try to catch such cases, thus the origin is known and the details page shows
    the origin URL (without it the URL is not shown).

 plugins/repos/gs-plugin-repos.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
---
diff --git a/plugins/repos/gs-plugin-repos.c b/plugins/repos/gs-plugin-repos.c
index 0a5f7e8b9..10281ee82 100644
--- a/plugins/repos/gs-plugin-repos.c
+++ b/plugins/repos/gs-plugin-repos.c
@@ -204,6 +204,28 @@ refine_app_locked (GsPlugin             *plugin,
                tmp = g_hash_table_lookup (priv->urls, gs_app_get_origin (app));
                if (tmp != NULL)
                        gs_app_set_origin_hostname (app, tmp);
+               else {
+                       GHashTableIter iter;
+                       gpointer key, value;
+                       const gchar *origin;
+
+                       origin = gs_app_get_origin (app);
+
+                       /* Some repos, such as rpmfusion, can have set the name with a distribution
+                          number in the appstream file, thus check those specifically */
+                       g_hash_table_iter_init (&iter, priv->urls);
+                       while (g_hash_table_iter_next (&iter, &key, &value)) {
+                               if (g_str_has_prefix (origin, key)) {
+                                       const gchar *rest = origin + strlen (key);
+                                       while (*rest == '-' || (*rest >= '0' && *rest <= '9'))
+                                               rest++;
+                                       if (!*rest) {
+                                               gs_app_set_origin_hostname (app, value);
+                                               break;
+                                       }
+                               }
+                       }
+               }
                break;
        }
 


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