[gnome-software: 1/2] gs-plugin-os-release: Use the OS ID rather than NAME in the app ID




commit 0344246643731363cf9a1c07d6c188ed52e71026
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Sep 15 14:30:21 2021 +0100

    gs-plugin-os-release: Use the OS ID rather than NAME in the app ID
    
    When building a `GsApp` to represent the OS, use the `ID` field from
    `/etc/os-release` in the app’s ID, rather than the `NAME` field.
    
    On Debian, in particular, the `NAME` field is problematic as it’s
    ‘Debian GNU/Linux’, with both the space and the `/` not being valid
    characters for an ID. They cause these warnings:
    ```
    09:38:54:0415 XbSilo ignoring for OR statement: predicate [text()='debian.www.Debian GNU was unfinished, 
missing ']'
    ```
    
    On Fedora, the `GsApp`’s ID is now `org.fedoraproject.fedora-34`.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #508

 plugins/core/gs-plugin-os-release.c                                | 7 +++++--
 plugins/core/gs-self-test.c                                        | 4 ++--
 .../fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c  | 2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/plugins/core/gs-plugin-os-release.c b/plugins/core/gs-plugin-os-release.c
index 977aae0da..db94ff045 100644
--- a/plugins/core/gs-plugin-os-release.c
+++ b/plugins/core/gs-plugin-os-release.c
@@ -38,6 +38,7 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
        const gchar *home_url;
        const gchar *name;
        const gchar *version;
+       const gchar *os_id;
        g_autoptr(GsOsRelease) os_release = NULL;
 
        /* parse os-release, wherever it may be */
@@ -54,6 +55,8 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
        if (version != NULL)
                gs_app_set_version (priv->app_system, version);
 
+       os_id = gs_os_release_get_id (os_release);
+
        /* use libsoup to convert a URL */
        home_url = gs_os_release_get_home_url (os_release);
        if (home_url != NULL) {
@@ -62,7 +65,7 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
                /* homepage */
                gs_app_set_url (priv->app_system, AS_URL_KIND_HOMEPAGE, home_url);
 
-               /* build ID from the reverse-DNS URL and the name version */
+               /* Build ID from the reverse-DNS URL and the ID and version. */
                uri = soup_uri_new (home_url);
                if (uri != NULL) {
                        g_auto(GStrv) split = NULL;
@@ -73,7 +76,7 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
                                id = g_strdup_printf ("%s.%s.%s-%s",
                                                      split[1],
                                                      split[0],
-                                                     (name != NULL) ? name : "unnamed",
+                                                     (os_id != NULL) ? os_id : "unnamed",
                                                      (version != NULL) ? version : "unversioned");
                                gs_app_set_id (priv->app_system, id);
                        }
diff --git a/plugins/core/gs-self-test.c b/plugins/core/gs-self-test.c
index dac3925d7..16894b915 100644
--- a/plugins/core/gs-self-test.c
+++ b/plugins/core/gs-self-test.c
@@ -79,7 +79,7 @@ gs_plugins_core_os_release_func (GsPluginLoader *plugin_loader)
        g_assert (ret);
 
        /* make sure there is valid content */
-       g_assert_cmpstr (gs_app_get_id (app), ==, "org.fedoraproject.Fedora-25");
+       g_assert_cmpstr (gs_app_get_id (app), ==, "org.fedoraproject.fedora-25");
        g_assert_cmpint (gs_app_get_kind (app), ==, AS_COMPONENT_KIND_OPERATING_SYSTEM);
        g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_INSTALLED);
        g_assert_cmpstr (gs_app_get_name (app), ==, "Fedora");
@@ -240,7 +240,7 @@ main (int argc, char **argv)
                "    <pkgname>arachne</pkgname>\n"
                "  </component>\n"
                "  <component type=\"os-upgrade\">\n"
-               "    <id>org.fedoraproject.Fedora-25</id>\n"
+               "    <id>org.fedoraproject.fedora-25</id>\n"
                "    <name>Fedora</name>\n"
                "    <summary>Fedora Workstation</summary>\n"
                "    <pkgname>fedora-release</pkgname>\n"
diff --git a/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c 
b/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
index 648d4c10a..42ec40232 100644
--- a/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
+++ b/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
@@ -296,7 +296,7 @@ _create_upgrade_from_info (GsPlugin *plugin, PkgdbItem *item)
        if (app != NULL)
                return app;
 
-       app_id = g_strdup_printf ("org.fedoraproject.Fedora-%u", item->version);
+       app_id = g_strdup_printf ("org.fedoraproject.fedora-%u", item->version);
        app_version = g_strdup_printf ("%u", item->version);
 
        /* icon from disk */


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