Resolves: RHEL-22268 (Prefer VENDOR_NAME in app origin)

This commit is contained in:
Milan Crha 2024-05-27 08:26:41 +02:00 committed by root
parent dea866af08
commit bad7325f5d
3 changed files with 157 additions and 1 deletions

1
.gnome-software.metadata Normal file
View File

@ -0,0 +1 @@
5f8d9e12db5da6b9e82b2cd7ec23768e5ac3df0c gnome-software-45.3.tar.xz

View File

@ -0,0 +1,151 @@
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

View File

@ -24,7 +24,7 @@
Name: gnome-software Name: gnome-software
Version: 45.3 Version: 45.3
Release: 2%{?dist} Release: 3%{?dist}
Summary: A software center for GNOME Summary: A software center for GNOME
License: GPL-2.0-or-later License: GPL-2.0-or-later
@ -34,6 +34,7 @@ Source0: https://download.gnome.org/sources/gnome-software/45/%{name}-%{tarbal
Patch01: 0001-Lower_glib_dependency_to_2_68.patch Patch01: 0001-Lower_glib_dependency_to_2_68.patch
Patch02: 0002-Lower-pango-attributes.patch Patch02: 0002-Lower-pango-attributes.patch
Patch03: 0003-Verify-category-sizes.patch Patch03: 0003-Verify-category-sizes.patch
Patch04: 0004-prefer-vendor-name.patch
BuildRequires: docbook-style-xsl BuildRequires: docbook-style-xsl
BuildRequires: desktop-file-utils BuildRequires: desktop-file-utils
@ -250,6 +251,9 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop
%{_datadir}/gtk-doc/html/gnome-software/ %{_datadir}/gtk-doc/html/gnome-software/
%changelog %changelog
* Mon May 27 2024 Milan Crha <mcrha@redhat.com> - 45.3-3
- Resolves: RHEL-22268 (Prefer VENDOR_NAME in app origin)
* Mon May 06 2024 Milan Crha <mcrha@redhat.com> - 45.3-2 * Mon May 06 2024 Milan Crha <mcrha@redhat.com> - 45.3-2
- Resolves: RHEL-843 (Rebase GNOME Software to its GNOME 45 version) - Resolves: RHEL-843 (Rebase GNOME Software to its GNOME 45 version)