[gnome-software/pk-url-to-app: 2/2] id_like is an array
- From: Iain Lane <iainl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/pk-url-to-app: 2/2] id_like is an array
- Date: Mon, 6 Nov 2017 18:44:14 +0000 (UTC)
commit 37770bc8251ddf792189dab46b81f68f7c16cc50
Author: Iain Lane <iain orangesquash org uk>
Date: Mon Nov 6 18:43:45 2017 +0000
id_like is an array
lib/gs-os-release.c | 13 ++++++++-----
lib/gs-os-release.h | 2 +-
plugins/packagekit/gs-plugin-packagekit-refine.c | 4 ++--
3 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/lib/gs-os-release.c b/lib/gs-os-release.c
index 231b91c..dd13f93 100644
--- a/lib/gs-os-release.c
+++ b/lib/gs-os-release.c
@@ -43,7 +43,7 @@ struct _GsOsRelease
gchar *name;
gchar *version;
gchar *id;
- gchar *id_like;
+ gchar **id_like;
gchar *version_id;
gchar *pretty_name;
gchar *cpe_name;
@@ -113,7 +113,7 @@ gs_os_release_initable_init (GInitable *initable,
continue;
}
if (g_strcmp0 (lines[i], "ID_LIKE") == 0) {
- os_release->id_like = g_strdup (tmp);
+ os_release->id_like = g_strsplit (tmp, " ", 0);
continue;
}
if (g_strcmp0 (lines[i], "VERSION_ID") == 0) {
@@ -195,13 +195,15 @@ gs_os_release_get_id (GsOsRelease *os_release)
* gs_os_release_get_id_like:
* @os_release: A #GsOsRelease
*
- * Gets the ID_LIKE from the os-release parser.
+ * Gets the ID_LIKE from the os-release parser. This is a list of operating
+ * systems that are "closely related" to the local operating system, possibly
+ * by being a derivative distribution.
*
- * Returns: a string, or %NULL
+ * Returns: a %NULL terminated list
*
* Since: 3.26.2
**/
-const gchar *
+const gchar * const *
gs_os_release_get_id_like (GsOsRelease *os_release)
{
g_return_val_if_fail (GS_IS_OS_RELEASE (os_release), NULL);
@@ -300,6 +302,7 @@ gs_os_release_finalize (GObject *object)
g_free (os_release->name);
g_free (os_release->version);
g_free (os_release->id);
+ g_strfreev (os_release->id_like);
g_free (os_release->version_id);
g_free (os_release->pretty_name);
g_free (os_release->cpe_name);
diff --git a/lib/gs-os-release.h b/lib/gs-os-release.h
index d789b12..ed73c98 100644
--- a/lib/gs-os-release.h
+++ b/lib/gs-os-release.h
@@ -37,7 +37,7 @@ GsOsRelease *gs_os_release_new (GError **error);
const gchar *gs_os_release_get_name (GsOsRelease *os_release);
const gchar *gs_os_release_get_version (GsOsRelease *os_release);
const gchar *gs_os_release_get_id (GsOsRelease *os_release);
-const gchar *gs_os_release_get_id_like (GsOsRelease *os_release);
+const gchar * const *gs_os_release_get_id_like (GsOsRelease *os_release);
const gchar *gs_os_release_get_version_id (GsOsRelease *os_release);
const gchar *gs_os_release_get_pretty_name (GsOsRelease *os_release);
const gchar *gs_os_release_get_cpe_name (GsOsRelease *os_release);
diff --git a/plugins/packagekit/gs-plugin-packagekit-refine.c
b/plugins/packagekit/gs-plugin-packagekit-refine.c
index 07f9701..bfee27a 100644
--- a/plugins/packagekit/gs-plugin-packagekit-refine.c
+++ b/plugins/packagekit/gs-plugin-packagekit-refine.c
@@ -1047,7 +1047,7 @@ gs_plugin_url_to_app (GsPlugin *plugin,
g_autofree gchar *scheme = NULL;
g_autofree gchar *path = NULL;
const gchar *id = NULL;
- const gchar *id_like = NULL;
+ const gchar * const *id_like = NULL;
g_auto(GStrv) package_ids = NULL;
g_autoptr(PkResults) results = NULL;
g_autoptr(GsApp) app = NULL;
@@ -1074,7 +1074,7 @@ gs_plugin_url_to_app (GsPlugin *plugin,
scheme = gs_utils_get_url_scheme (url);
if (!(g_strcmp0 (scheme, "apt") == 0 &&
(g_strcmp0 (id, "debian") == 0 ||
- g_strcmp0 (id_like, "debian") == 0))) {
+ g_strv_contains (id_like, "debian")))) {
return TRUE;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]