[gnome-software] snap: Use snap "common ID" as the package ID



commit bdd593b9421681ce4c0c2a1a5628d0c112fbc099
Author: Robert Ancell <robert ancell canonical com>
Date:   Wed Jun 27 12:02:31 2018 +1200

    snap: Use snap "common ID" as the package ID

 meson.build                   | 2 +-
 plugins/snap/gs-plugin-snap.c | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/meson.build b/meson.build
index b83e9b63..5b0e6870 100644
--- a/meson.build
+++ b/meson.build
@@ -171,7 +171,7 @@ if get_option('enable-gudev')
 endif
 
 if get_option('enable-snap')
-  snap = dependency('snapd-glib', version : '>= 1.19')
+  snap = dependency('snapd-glib', version : '>= 1.41')
 endif
 
 gnome = import('gnome')
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index 2a26fe6a..14571efe 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -265,14 +265,19 @@ static GsApp *
 snap_to_app (GsPlugin *plugin, SnapdSnap *snap)
 {
        GsPluginData *priv = gs_plugin_get_data (plugin);
+       GStrv common_ids;
        g_autofree gchar *appstream_id = NULL;
        g_autofree gchar *unique_id = NULL;
        GsApp *cached_app;
        g_autoptr(GsApp) app = NULL;
        SnapdConfinement confinement;
 
-       /* generate an AppStream ID for this snap - when Snaps support an AppStream field we can override 
this */
-       appstream_id = g_strdup_printf ("io.snapcraft.%s-%s", snapd_snap_get_name (snap), snapd_snap_get_id 
(snap));
+       /* Get the AppStream ID from the snap, or generate a fallback one */
+       common_ids = snapd_snap_get_common_ids (snap);
+       if (g_strv_length (common_ids) == 1)
+               appstream_id = g_strdup (common_ids[0]);
+       else
+               appstream_id = g_strdup_printf ("io.snapcraft.%s-%s", snapd_snap_get_name (snap), 
snapd_snap_get_id (snap));
 
        switch (snapd_snap_get_snap_type (snap)) {
        case SNAPD_SNAP_TYPE_APP:


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