summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-01-20 16:49:24 +0000
committerRichard Hughes <richard@hughsie.com>2016-01-21 08:42:41 +0000
commit2cd9adfd06cf8fe676eda43e8611abb17c63dc6c (patch)
tree833db4f4d8b47dc1db79d7df335741f8c1b37711
parent021b4a8d875ea63bc096f8e2992dd4ee75335e5f (diff)
downloadappstream-glib-wip/hughsie/xdg-app.tar.gz
Set the xdg-app origin using the filenamewip/hughsie/xdg-app
The origin in the XML itself isn't much use as the user could have a different name for the remote entirely.
-rw-r--r--libappstream-glib/as-store.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c
index cf8994e..80afbb1 100644
--- a/libappstream-glib/as-store.c
+++ b/libappstream-glib/as-store.c
@@ -858,6 +858,19 @@ as_store_match_addons (AsStore *store)
}
/**
+ * as_store_set_origin_for_xdg_app:
+ **/
+static void
+as_store_set_origin_for_xdg_app (AsStore *store, const gchar *fn)
+{
+ g_auto(GStrv) split = g_strsplit (fn, "/", -1);
+ guint chunks = g_strv_length (split);
+ if (chunks < 5)
+ return;
+ as_store_set_origin (store, split[chunks - 4]);
+}
+
+/**
* as_store_from_root:
**/
static gboolean
@@ -904,8 +917,12 @@ as_store_from_root (AsStore *store,
/* set in the XML file */
tmp = as_node_get_attribute (apps, "origin");
- if (tmp != NULL)
- as_store_set_origin (store, tmp);
+ if (tmp != NULL) {
+ if (g_strcmp0 (tmp, "xdg-app") == 0)
+ as_store_set_origin_for_xdg_app (store, source_filename);
+ else
+ as_store_set_origin (store, tmp);
+ }
/* set in the XML file */
tmp = as_node_get_attribute (apps, "builder_id");