Commit 73f3f421 authored by Kalev Lember's avatar Kalev Lember

flatpak: Match origin when searching appstream

When parsing system installed appstream data for packages we usually
have one appstream file that covers multiple repos (e.g.
/usr/share/app-info/xmls/fedora.xml.gz and "fedora", "updates",
"updates-testing" repos). In this case, when parsing the appstream we
can't set app origin based on the appstream origin as there is no
one-to-one mapping from appstream origin to the repo where the package
actually comes from.

For flatpaks, however, we always have per-remote appstream data and we
need to keep track of the origin to match the correct app from the
correct remote. If we don't do that then we end up refining flatpak apps
with the first entry that appstream finds, which may be from a wrong
remote.

This is harmless when only one repo provides each flatpak app, but as
soon as we have two (e.g. Flathub and Fedora) we need to make sure to
match the correct appstream entry with the correct flatpak.

This regressed in commit d3648252 that took out the origin adding in
gs_appstream_create_app(). This commit now adds it back and makes it
work again for the new libxmlb parsing code.

Partially fixes: #547
parent 5681c042
......@@ -860,6 +860,16 @@ gs_appstream_refine_app (GsPlugin *plugin,
}
}
/* set origin for flatpaks */
if (gs_app_get_origin (app) == NULL &&
gs_app_get_bundle_kind (app) == AS_BUNDLE_KIND_FLATPAK) {
g_autoptr(XbNode) parent = xb_node_get_parent (component);
if (parent != NULL) {
tmp = xb_node_get_attr (parent, "origin");
gs_app_set_origin (app, tmp);
}
}
/* set addons */
if (refine_flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_ADDONS) {
if (!gs_appstream_refine_add_addons (plugin, app, silo, error))
......
......@@ -2099,14 +2099,15 @@ gs_flatpak_refine_appstream (GsFlatpak *self,
GError **error)
{
const gchar *id = gs_app_get_id (app);
const gchar *origin = gs_app_get_origin (app);
g_autofree gchar *xpath = NULL;
g_autoptr(XbNode) component = NULL;
if (id == NULL)
return TRUE;
/* find using ID */
xpath = g_strdup_printf ("components/component/id[text()='%s']/..", id);
/* find using ID and origin */
xpath = g_strdup_printf ("components[@origin='%s']/component/id[text()='%s']/..", origin, id);
component = xb_silo_query_first (silo, xpath, NULL);
if (component == NULL)
return TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment