This repository has been archived by the owner on Dec 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
appstream-compose-Support-appdata-with-no-desktop-fi.patch
92 lines (84 loc) · 2.92 KB
/
appstream-compose-Support-appdata-with-no-desktop-fi.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
From be891e96e2fb5de33cb0764f9b75f212b13b0cea Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Wed, 18 Jan 2017 12:14:20 +0100
Subject: [PATCH] appstream-compose: Support appdata with no desktop files
For instance, this happens for the runtimes
---
client/as-compose.c | 48 ++++++++++++++++++++++++++----------------------
1 file changed, 26 insertions(+), 22 deletions(-)
diff --git a/client/as-compose.c b/client/as-compose.c
index 3b69129..a96e268 100644
--- a/client/as-compose.c
+++ b/client/as-compose.c
@@ -187,20 +187,12 @@ load_desktop (const gchar *prefix,
const gchar *icons_dir,
guint min_icon_size,
const gchar *app_name,
- const gchar *appdata_id,
+ const gchar *desktop_path,
GError **error)
{
AsIcon *icon;
- g_autofree gchar *desktop_basename = NULL;
- g_autofree gchar *desktop_path = NULL;
g_autoptr(AsApp) app = NULL;
- if (appdata_id != NULL)
- desktop_basename = g_strdup (appdata_id);
- else
- desktop_basename = g_strconcat (app_name, ".desktop", NULL);
- desktop_path = g_build_filename (prefix, "share/applications", desktop_basename, NULL);
-
app = as_app_new ();
if (!as_app_parse_file (app, desktop_path,
AS_APP_PARSE_FLAG_USE_HEURISTICS |
@@ -414,6 +406,9 @@ main (int argc, char **argv)
g_auto(GStrv) intl_domains = NULL;
g_autoptr(AsApp) app_appdata = NULL;
g_autoptr(AsApp) app_desktop = NULL;
+ g_autofree gchar *desktop_basename = NULL;
+ g_autofree gchar *desktop_path = NULL;
+ const gchar *appdata_id;
/* TRANSLATORS: we're generating the AppStream data */
g_print ("%s %s\n", _("Processing application"), app_name);
@@ -464,20 +459,29 @@ main (int argc, char **argv)
as_store_add_app (store, app_appdata);
- app_desktop = load_desktop (prefix,
- icons_dir,
- min_icon_size,
- app_name,
- as_app_get_id (app_appdata),
- &error);
- if (app_desktop == NULL) {
- /* TRANSLATORS: the .desktop file could not
- * be loaded */
- g_print ("%s: %s\n", _("Error loading desktop file"),
- error->message);
- return EXIT_FAILURE;
+ appdata_id = as_app_get_id (app_appdata);
+ if (appdata_id != NULL)
+ desktop_basename = g_strdup (appdata_id);
+ else
+ desktop_basename = g_strconcat (app_name, ".desktop", NULL);
+ desktop_path = g_build_filename (prefix, "share/applications", desktop_basename, NULL);
+
+ if (g_file_test (desktop_path, G_FILE_TEST_EXISTS)) {
+ app_desktop = load_desktop (prefix,
+ icons_dir,
+ min_icon_size,
+ app_name,
+ desktop_path,
+ &error);
+ if (app_desktop == NULL) {
+ /* TRANSLATORS: the .desktop file could not
+ * be loaded */
+ g_print ("%s: %s\n", _("Error loading desktop file"),
+ error->message);
+ return EXIT_FAILURE;
+ }
+ as_store_add_app (store, app_desktop);
}
- as_store_add_app (store, app_desktop);
}
/* create output directory */
--
2.9.3