152 lines
4.9 KiB
Diff
152 lines
4.9 KiB
Diff
diff --git a/lib/gs-app.c b/lib/gs-app.c
|
|
index fa266cdc1..66a5acad7 100644
|
|
--- a/lib/gs-app.c
|
|
+++ b/lib/gs-app.c
|
|
@@ -6319,8 +6319,11 @@ gs_app_dup_origin_ui (GsApp *app,
|
|
if (gs_app_has_quirk (app, GS_APP_QUIRK_PROVENANCE) &&
|
|
gs_app_get_kind (app) != AS_COMPONENT_KIND_REPOSITORY) {
|
|
os_release = gs_os_release_new (NULL);
|
|
- if (os_release != NULL)
|
|
- origin_str = gs_os_release_get_name (os_release);
|
|
+ if (os_release != NULL) {
|
|
+ origin_str = gs_os_release_get_vendor_name (os_release);
|
|
+ if (origin_str == NULL)
|
|
+ origin_str = gs_os_release_get_name (os_release);
|
|
+ }
|
|
}
|
|
|
|
priv = gs_app_get_instance_private (app);
|
|
diff --git a/lib/gs-os-release.c b/lib/gs-os-release.c
|
|
index 85ea24e2e..380c9c84e 100644
|
|
--- a/lib/gs-os-release.c
|
|
+++ b/lib/gs-os-release.c
|
|
@@ -37,6 +37,7 @@ struct _GsOsRelease
|
|
gchar *distro_codename;
|
|
gchar *home_url;
|
|
gchar *logo;
|
|
+ gchar *vendor_name;
|
|
};
|
|
|
|
static void gs_os_release_initable_iface_init (GInitableIface *iface);
|
|
@@ -44,6 +45,18 @@ static void gs_os_release_initable_iface_init (GInitableIface *iface);
|
|
G_DEFINE_TYPE_WITH_CODE (GsOsRelease, gs_os_release, G_TYPE_OBJECT,
|
|
G_IMPLEMENT_INTERFACE(G_TYPE_INITABLE, gs_os_release_initable_iface_init))
|
|
|
|
+static void
|
|
+gs_os_release_set_string_nonempty (gchar **inout_string,
|
|
+ const gchar *value)
|
|
+{
|
|
+ if (*inout_string == value)
|
|
+ return;
|
|
+
|
|
+ g_clear_pointer (inout_string, g_free);
|
|
+ if (value != NULL && *value != '\0')
|
|
+ *inout_string = g_strdup (value);
|
|
+}
|
|
+
|
|
static gboolean
|
|
gs_os_release_initable_init (GInitable *initable,
|
|
GCancellable *cancellable,
|
|
@@ -89,43 +102,49 @@ gs_os_release_initable_init (GInitable *initable,
|
|
|
|
/* match fields we're interested in */
|
|
if (g_strcmp0 (lines[i], "NAME") == 0) {
|
|
- os_release->name = g_strdup (tmp);
|
|
+ gs_os_release_set_string_nonempty (&os_release->name, tmp);
|
|
continue;
|
|
}
|
|
if (g_strcmp0 (lines[i], "VERSION") == 0) {
|
|
- os_release->version = g_strdup (tmp);
|
|
+ gs_os_release_set_string_nonempty (&os_release->version, tmp);
|
|
continue;
|
|
}
|
|
if (g_strcmp0 (lines[i], "ID") == 0) {
|
|
- os_release->id = g_strdup (tmp);
|
|
+ gs_os_release_set_string_nonempty (&os_release->id, tmp);
|
|
continue;
|
|
}
|
|
if (g_strcmp0 (lines[i], "ID_LIKE") == 0) {
|
|
+ if (os_release->id_like != NULL)
|
|
+ g_strfreev (os_release->id_like);
|
|
os_release->id_like = g_strsplit (tmp, " ", 0);
|
|
continue;
|
|
}
|
|
if (g_strcmp0 (lines[i], "VERSION_ID") == 0) {
|
|
- os_release->version_id = g_strdup (tmp);
|
|
+ gs_os_release_set_string_nonempty (&os_release->version_id, tmp);
|
|
continue;
|
|
}
|
|
if (g_strcmp0 (lines[i], "PRETTY_NAME") == 0) {
|
|
- os_release->pretty_name = g_strdup (tmp);
|
|
+ gs_os_release_set_string_nonempty (&os_release->pretty_name, tmp);
|
|
continue;
|
|
}
|
|
if (g_strcmp0 (lines[i], "CPE_NAME") == 0) {
|
|
- os_release->cpe_name = g_strdup (tmp);
|
|
+ gs_os_release_set_string_nonempty (&os_release->cpe_name, tmp);
|
|
continue;
|
|
}
|
|
if (g_strcmp0 (lines[i], "UBUNTU_CODENAME") == 0) {
|
|
- os_release->distro_codename = g_strdup (tmp);
|
|
+ gs_os_release_set_string_nonempty (&os_release->distro_codename, tmp);
|
|
continue;
|
|
}
|
|
if (g_strcmp0 (lines[i], "HOME_URL") == 0) {
|
|
- os_release->home_url = g_strdup (tmp);
|
|
+ gs_os_release_set_string_nonempty (&os_release->home_url, tmp);
|
|
continue;
|
|
}
|
|
if (g_strcmp0 (lines[i], "LOGO") == 0) {
|
|
- os_release->logo = g_strdup (tmp);
|
|
+ gs_os_release_set_string_nonempty (&os_release->logo, tmp);
|
|
+ continue;
|
|
+ }
|
|
+ if (g_strcmp0 (lines[i], "VENDOR_NAME") == 0) {
|
|
+ gs_os_release_set_string_nonempty (&os_release->vendor_name, tmp);
|
|
continue;
|
|
}
|
|
}
|
|
@@ -304,6 +323,23 @@ gs_os_release_get_logo (GsOsRelease *os_release)
|
|
return os_release->logo;
|
|
}
|
|
|
|
+/**
|
|
+ * gs_os_release_get_vendor_name:
|
|
+ * @os_release: A #GsOsRelease
|
|
+ *
|
|
+ * Gets the vendor name from the os-release parser.
|
|
+ *
|
|
+ * Returns: (nullable): a string, or %NULL
|
|
+ *
|
|
+ * Since: 46.3
|
|
+ **/
|
|
+const gchar *
|
|
+gs_os_release_get_vendor_name (GsOsRelease *os_release)
|
|
+{
|
|
+ g_return_val_if_fail (GS_IS_OS_RELEASE (os_release), NULL);
|
|
+ return os_release->vendor_name;
|
|
+}
|
|
+
|
|
static void
|
|
gs_os_release_finalize (GObject *object)
|
|
{
|
|
@@ -318,6 +354,7 @@ gs_os_release_finalize (GObject *object)
|
|
g_free (os_release->distro_codename);
|
|
g_free (os_release->home_url);
|
|
g_free (os_release->logo);
|
|
+ g_free (os_release->vendor_name);
|
|
|
|
G_OBJECT_CLASS (gs_os_release_parent_class)->finalize (object);
|
|
}
|
|
diff --git a/lib/gs-os-release.h b/lib/gs-os-release.h
|
|
index e219e5c96..6d52ecdd2 100644
|
|
--- a/lib/gs-os-release.h
|
|
+++ b/lib/gs-os-release.h
|
|
@@ -30,5 +30,6 @@ const gchar *gs_os_release_get_cpe_name (GsOsRelease *os_release);
|
|
const gchar *gs_os_release_get_distro_codename (GsOsRelease *os_release);
|
|
const gchar *gs_os_release_get_home_url (GsOsRelease *os_release);
|
|
const gchar *gs_os_release_get_logo (GsOsRelease *os_release);
|
|
+const gchar *gs_os_release_get_vendor_name (GsOsRelease *os_release);
|
|
|
|
G_END_DECLS
|