From 7dd92d8a9be2e14313e2cda7dea44298fbb005a4 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 19 Apr 2018 09:49:24 +0200 Subject: [PATCH] build-update-repo: Fix org.telegram.desktop icons The telegram app id is org.telegram.desktop, and its appstream component id is org.telegram.desktop.desktop, which we did not properly handle (we special cased the app-id-ends-with-desktop case and then did not remote .desktop). This replaces that with a more approach that *always* matches the whole app id as prefix, and then replaces a ".desktop" in the suffix part only. Closes: #1593 Approved by: alexlarsson --- common/flatpak-utils.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c index ef949898..99cd9be5 100644 --- a/common/flatpak-utils.c +++ b/common/flatpak-utils.c @@ -3482,6 +3482,7 @@ extract_appstream (OstreeRepo *repo, { FlatpakXml *component_id, *component_id_text_node; g_autofree char *component_id_text = NULL; + char *component_id_suffix; if (g_strcmp0 (component->element_name, "component") != 0) { @@ -3494,18 +3495,22 @@ extract_appstream (OstreeRepo *repo, component_id_text = g_strstrip (g_strdup (component_id_text_node->text)); - /* .desktop suffix in component ID is suggested, not required - (unless app ID actually ends in .desktop) */ - if (g_str_has_suffix (component_id_text, ".desktop") && - !g_str_has_suffix (id, ".desktop")) - component_id_text[strlen (component_id_text) - strlen (".desktop")] = 0; + /* We're looking for a component that matches the app-id (id), but it + may have some further elements (separated by dot) and can also have + ".desktop" at the end which we need to strip out. Further complicating + things, some actual app ids ends in .desktop, such as org.telegram.desktop. */ - if (!g_str_has_prefix (component_id_text, id)) + component_id_suffix = component_id_text + strlen (id); /* Don't deref before we check for prefix match! */ + if (!g_str_has_prefix (component_id_text, id) || + (component_id_suffix[0] != 0 && component_id_suffix[0] != '.')) { component = component->next_sibling; continue; } + if (g_str_has_suffix (component_id_suffix, ".desktop")) + component_id_suffix[strlen (component_id_suffix) - strlen (".desktop")] = 0; + g_print (_("Extracting icons for component %s\n"), component_id_text); if (!copy_icon (component_id_text, root, dest, "64x64", &my_error))