summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-07-15 18:48:59 +0100
committerRichard Hughes <richard@hughsie.com>2014-07-15 18:48:59 +0100
commitb502fa22e04197a3ce25d0e54b617d11938fad21 (patch)
treed88b5905b0398657bc7d0d86a0c0b87880923a56
parent4be7ad724266f69224f9b5d3c7d0c465836741e0 (diff)
downloadappstream-glib-b502fa22e04197a3ce25d0e54b617d11938fad21.tar.gz
Do not fail to build packages with invalid KDE service files
-rw-r--r--libappstream-builder/plugins/asb-plugin-kde-services.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/libappstream-builder/plugins/asb-plugin-kde-services.c b/libappstream-builder/plugins/asb-plugin-kde-services.c
index 1d7fe69..b0257e9 100644
--- a/libappstream-builder/plugins/asb-plugin-kde-services.c
+++ b/libappstream-builder/plugins/asb-plugin-kde-services.c
@@ -43,6 +43,30 @@ asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs)
}
/**
+ * asb_plugin_process_filename:
+ */
+static gboolean
+asb_plugin_process_filename (const gchar *filename,
+ AsbApp *app,
+ const gchar *tmpdir,
+ GError **error)
+{
+ _cleanup_free_ gchar *types = NULL;
+ _cleanup_keyfile_unref_ GKeyFile *kf = NULL;
+ kf = g_key_file_new ();
+ if (!g_key_file_load_from_file (kf, filename, G_KEY_FILE_NONE, error))
+ return FALSE;
+ types = g_key_file_get_string (kf, G_KEY_FILE_DESKTOP_GROUP,
+ "X-KDE-ServiceTypes", NULL);
+ if (types == NULL)
+ return TRUE;
+ if (g_strcmp0 (types, "Plasma/Runner") != 0)
+ return TRUE;
+ as_app_add_kudo_kind (AS_APP (app), AS_KUDO_KIND_SEARCH_PROVIDER);
+ return TRUE;
+}
+
+/**
* asb_plugin_process_app:
*/
gboolean
@@ -58,20 +82,21 @@ asb_plugin_process_app (AsbPlugin *plugin,
/* look for a krunner provider */
filelist = asb_package_get_filelist (pkg);
for (i = 0; filelist[i] != NULL; i++) {
- _cleanup_keyfile_unref_ GKeyFile *kf = NULL;
+ _cleanup_error_free_ GError *error_local = NULL;
_cleanup_free_ gchar *filename = NULL;
- _cleanup_free_ gchar *types = NULL;
if (fnmatch ("/usr/share/kde4/services/*.desktop", filelist[i], 0) != 0)
continue;
- kf = g_key_file_new ();
filename = g_build_filename (tmpdir, filelist[i], NULL);
- if (!g_key_file_load_from_file (kf, filename, G_KEY_FILE_NONE, error))
- return FALSE;
- types = g_key_file_get_string (kf, G_KEY_FILE_DESKTOP_GROUP, "X-KDE-ServiceTypes", NULL);
- if (g_strcmp0 (types, "Plasma/Runner") == 0) {
- as_app_add_kudo_kind (AS_APP (app),
- AS_KUDO_KIND_SEARCH_PROVIDER);
- break;
+ if (!asb_plugin_process_filename (filename,
+ app,
+ tmpdir,
+ &error_local)) {
+ asb_package_log (pkg,
+ ASB_PACKAGE_LOG_LEVEL_INFO,
+ "Failed to read KDE service file %s: %s",
+ filelist[i],
+ error_local->message);
+ g_clear_error (&error_local);
}
}