From 420423afe4320a8e780742a3ae06251e0dc69fad Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 22 Jan 2016 13:12:36 +0000 Subject: Remove the GIR and GResource, nm and KDE-specific plugins Applications have to specify the kudos upstream and relying on these hacky heuristics only worked some of the time for packages, and none of the time for xdg-app and Limba. --- libappstream-builder/plugins/Makefile.am | 32 +---- libappstream-builder/plugins/asb-plugin-gir.c | 133 --------------------- .../plugins/asb-plugin-gresource.c | 110 ----------------- .../plugins/asb-plugin-kde-notifyrc.c | 76 ------------ .../plugins/asb-plugin-kde-services.c | 112 ----------------- libappstream-builder/plugins/asb-plugin-nm.c | 129 -------------------- 6 files changed, 1 insertion(+), 591 deletions(-) delete mode 100644 libappstream-builder/plugins/asb-plugin-gir.c delete mode 100644 libappstream-builder/plugins/asb-plugin-gresource.c delete mode 100644 libappstream-builder/plugins/asb-plugin-kde-notifyrc.c delete mode 100644 libappstream-builder/plugins/asb-plugin-kde-services.c delete mode 100644 libappstream-builder/plugins/asb-plugin-nm.c (limited to 'libappstream-builder/plugins') diff --git a/libappstream-builder/plugins/Makefile.am b/libappstream-builder/plugins/Makefile.am index 6e0a910..3709321 100644 --- a/libappstream-builder/plugins/Makefile.am +++ b/libappstream-builder/plugins/Makefile.am @@ -18,13 +18,8 @@ plugin_LTLIBRARIES = \ libasb_plugin_appdata.la \ libasb_plugin_dbus.la \ libasb_plugin_desktop.la \ - libasb_plugin_gir.la \ - libasb_plugin_gresource.la \ libasb_plugin_gettext.la \ - libasb_plugin_hardcoded.la \ - libasb_plugin_kde_services.la \ - libasb_plugin_kde_notifyrc.la \ - libasb_plugin_nm.la + libasb_plugin_hardcoded.la if HAVE_FONTS plugin_LTLIBRARIES += \ @@ -41,16 +36,6 @@ libasb_plugin_absorb_la_LIBADD = $(GLIB_LIBS) libasb_plugin_absorb_la_LDFLAGS = -module -avoid-version libasb_plugin_absorb_la_CFLAGS = $(GLIB_CFLAGS) $(WARNINGFLAGS_C) -libasb_plugin_kde_services_la_SOURCES = asb-plugin-kde-services.c -libasb_plugin_kde_services_la_LIBADD = $(GLIB_LIBS) -libasb_plugin_kde_services_la_LDFLAGS = -module -avoid-version -libasb_plugin_kde_services_la_CFLAGS = $(GLIB_CFLAGS) $(WARNINGFLAGS_C) - -libasb_plugin_kde_notifyrc_la_SOURCES = asb-plugin-kde-notifyrc.c -libasb_plugin_kde_notifyrc_la_LIBADD = $(GLIB_LIBS) -libasb_plugin_kde_notifyrc_la_LDFLAGS = -module -avoid-version -libasb_plugin_kde_notifyrc_la_CFLAGS = $(GLIB_CFLAGS) $(WARNINGFLAGS_C) - libasb_plugin_gettext_la_SOURCES = asb-plugin-gettext.c libasb_plugin_gettext_la_LIBADD = $(GLIB_LIBS) libasb_plugin_gettext_la_LDFLAGS = -module -avoid-version @@ -66,26 +51,11 @@ libasb_plugin_desktop_la_LIBADD = $(GLIB_LIBS) $(GDKPIXBUF_LIBS) libasb_plugin_desktop_la_LDFLAGS = -module -avoid-version libasb_plugin_desktop_la_CFLAGS = $(GLIB_CFLAGS) $(WARNINGFLAGS_C) -libasb_plugin_gir_la_SOURCES = asb-plugin-gir.c -libasb_plugin_gir_la_LIBADD = $(GLIB_LIBS) $(GDKPIXBUF_LIBS) -libasb_plugin_gir_la_LDFLAGS = -module -avoid-version -libasb_plugin_gir_la_CFLAGS = $(GLIB_CFLAGS) $(WARNINGFLAGS_C) - -libasb_plugin_gresource_la_SOURCES = asb-plugin-gresource.c -libasb_plugin_gresource_la_LIBADD = $(GLIB_LIBS) $(GDKPIXBUF_LIBS) -libasb_plugin_gresource_la_LDFLAGS = -module -avoid-version -libasb_plugin_gresource_la_CFLAGS = $(GLIB_CFLAGS) $(WARNINGFLAGS_C) - libasb_plugin_appdata_la_SOURCES = asb-plugin-appdata.c libasb_plugin_appdata_la_LIBADD = $(GLIB_LIBS) $(GDKPIXBUF_LIBS) libasb_plugin_appdata_la_LDFLAGS = -module -avoid-version libasb_plugin_appdata_la_CFLAGS = $(GLIB_CFLAGS) $(WARNINGFLAGS_C) -libasb_plugin_nm_la_SOURCES = asb-plugin-nm.c -libasb_plugin_nm_la_LIBADD = $(GLIB_LIBS) -libasb_plugin_nm_la_LDFLAGS = -module -avoid-version -libasb_plugin_nm_la_CFLAGS = $(GLIB_CFLAGS) $(WARNINGFLAGS_C) - if HAVE_FONTS libasb_plugin_font_la_SOURCES = asb-plugin-font.c libasb_plugin_font_la_LIBADD = $(GLIB_LIBS) $(FREETYPE_LIBS) $(GDKPIXBUF_LIBS) $(GTK_LIBS) diff --git a/libappstream-builder/plugins/asb-plugin-gir.c b/libappstream-builder/plugins/asb-plugin-gir.c deleted file mode 100644 index 5c51704..0000000 --- a/libappstream-builder/plugins/asb-plugin-gir.c +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2014 Richard Hughes - * - * Licensed under the GNU Lesser General Public License Version 2.1 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -#include - -/** - * asb_plugin_get_name: - */ -const gchar * -asb_plugin_get_name (void) -{ - return "gir"; -} - -/** - * asb_plugin_add_globs: - */ -void -asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs) -{ - asb_plugin_add_glob (globs, "/usr/share/*/*.gir"); -} - -/** - * _asb_plugin_check_filename: - */ -static gboolean -_asb_plugin_check_filename (const gchar *filename) -{ - if (asb_plugin_match_glob ("/usr/share/*/*.gir", filename)) - return TRUE; - return FALSE; -} - -/** - * asb_plugin_process_gir: - */ -static gboolean -asb_plugin_process_gir (AsbApp *app, - const gchar *tmpdir, - const gchar *filename, - GError **error) -{ - GNode *l; - GNode *node = NULL; - const gchar *name; - const gchar *version; - gboolean ret = TRUE; - g_autofree gchar *filename_full = NULL; - g_autoptr(GFile) file = NULL; - - /* load file */ - filename_full = g_build_filename (tmpdir, filename, NULL); - file = g_file_new_for_path (filename_full); - node = as_node_from_file (file, AS_NODE_FROM_XML_FLAG_NONE, NULL, error); - if (node == NULL) { - ret = FALSE; - goto out; - } - - /* look for includes */ - l = as_node_find (node, "repository"); - if (l == NULL) - goto out; - for (l = l->children; l != NULL; l = l->next) { - if (g_strcmp0 (as_node_get_name (l), "include") != 0) - continue; - name = as_node_get_attribute (l, "name"); - version = as_node_get_attribute (l, "version"); - if (g_strcmp0 (name, "Gtk") == 0 && - g_strcmp0 (version, "3.0") == 0) { - asb_package_log (asb_app_get_package (app), - ASB_PACKAGE_LOG_LEVEL_DEBUG, - "Auto-adding kudo ModernToolkit for %s", - as_app_get_id (AS_APP (app))); - as_app_add_kudo_kind (AS_APP (app), - AS_KUDO_KIND_MODERN_TOOLKIT); - } - } -out: - if (node != NULL) - as_node_unref (node); - return ret; -} - -/** - * asb_plugin_process_app: - */ -gboolean -asb_plugin_process_app (AsbPlugin *plugin, - AsbPackage *pkg, - AsbApp *app, - const gchar *tmpdir, - GError **error) -{ - gchar **filelist; - guint i; - - /* already set */ - if (as_app_has_kudo_kind (AS_APP (app), AS_KUDO_KIND_MODERN_TOOLKIT)) - return TRUE; - - /* look for any GIR files */ - filelist = asb_package_get_filelist (pkg); - for (i = 0; filelist[i] != NULL; i++) { - if (!_asb_plugin_check_filename (filelist[i])) - continue; - if (!asb_plugin_process_gir (app, tmpdir, filelist[i], error)) - return FALSE; - } - return TRUE; -} diff --git a/libappstream-builder/plugins/asb-plugin-gresource.c b/libappstream-builder/plugins/asb-plugin-gresource.c deleted file mode 100644 index c2ab652..0000000 --- a/libappstream-builder/plugins/asb-plugin-gresource.c +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2014 Richard Hughes - * - * Licensed under the GNU Lesser General Public License Version 2.1 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include - -/** - * asb_plugin_get_name: - */ -const gchar * -asb_plugin_get_name (void) -{ - return "gresource"; -} - -/** - * asb_plugin_add_globs: - */ -void -asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs) -{ - asb_plugin_add_glob (globs, "/usr/bin/*"); -} - -static gboolean -asb_plugin_gresource_app (AsbApp *app, const gchar *filename, GError **error) -{ - gboolean ret; - g_autofree gchar *data_err = NULL; - g_autofree gchar *data_out = NULL; - const gchar *argv[] = { "/usr/bin/gresource", - "list", - filename, - NULL }; - - ret = g_spawn_sync (NULL, (gchar **) argv, NULL, -#if GLIB_CHECK_VERSION(2,40,0) - G_SPAWN_CLOEXEC_PIPES, -#else - G_SPAWN_DEFAULT, -#endif - NULL, NULL, - &data_out, - &data_err, - NULL, error); - if (!ret) - return FALSE; - if (g_strstr_len (data_out, -1, "gtk/menus.ui") != NULL) { - asb_package_log (asb_app_get_package (app), - ASB_PACKAGE_LOG_LEVEL_DEBUG, - "Auto-adding kudo AppMenu for %s", - as_app_get_id (AS_APP (app))); - as_app_add_kudo_kind (AS_APP (app), AS_KUDO_KIND_APP_MENU); - } - return TRUE; -} - -/** - * asb_plugin_process_app: - */ -gboolean -asb_plugin_process_app (AsbPlugin *plugin, - AsbPackage *pkg, - AsbApp *app, - const gchar *tmpdir, - GError **error) -{ - gchar **filelist; - guint i; - - filelist = asb_package_get_filelist (pkg); - for (i = 0; filelist[i] != NULL; i++) { - GError *error_local = NULL; - g_autofree gchar *filename = NULL; - - if (!asb_plugin_match_glob ("/usr/bin/*", filelist[i])) - continue; - if (as_app_has_kudo_kind (AS_APP (app), AS_KUDO_KIND_APP_MENU)) - break; - filename = g_build_filename (tmpdir, filelist[i], NULL); - if (!asb_plugin_gresource_app (app, filename, &error_local)) { - asb_package_log (pkg, - ASB_PACKAGE_LOG_LEVEL_WARNING, - "Failed to get resources from %s: %s", - filename, - error_local->message); - g_clear_error (&error_local); - } - } - return TRUE; -} diff --git a/libappstream-builder/plugins/asb-plugin-kde-notifyrc.c b/libappstream-builder/plugins/asb-plugin-kde-notifyrc.c deleted file mode 100644 index b5fd3dd..0000000 --- a/libappstream-builder/plugins/asb-plugin-kde-notifyrc.c +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2014 Richard Hughes - * - * Licensed under the GNU Lesser General Public License Version 2.1 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include -#include - -/** - * asb_plugin_get_name: - */ -const gchar * -asb_plugin_get_name (void) -{ - return "kde-notifyrc"; -} - -/** - * asb_plugin_add_globs: - */ -void -asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs) -{ - asb_plugin_add_glob (globs, "/usr/share/kde4/apps/*/*.notifyrc"); -} - -/** - * asb_plugin_process_app: - */ -gboolean -asb_plugin_process_app (AsbPlugin *plugin, - AsbPackage *pkg, - AsbApp *app, - const gchar *tmpdir, - GError **error) -{ - gchar **filelist; - guint i; - - /* already set */ - if (as_app_has_kudo_kind (AS_APP (app), AS_KUDO_KIND_NOTIFICATIONS)) - return TRUE; - - /* look for a shell search provider */ - filelist = asb_package_get_filelist (pkg); - for (i = 0; filelist[i] != NULL; i++) { - if (!asb_plugin_match_glob ("/usr/share/kde4/apps/*/*.notifyrc", filelist[i])) - continue; - asb_package_log (pkg, - ASB_PACKAGE_LOG_LEVEL_DEBUG, - "Auto-adding kudo Notifications for %s", - as_app_get_id (AS_APP (app))); - as_app_add_kudo_kind (AS_APP (app), AS_KUDO_KIND_NOTIFICATIONS); - break; - } - - return TRUE; -} diff --git a/libappstream-builder/plugins/asb-plugin-kde-services.c b/libappstream-builder/plugins/asb-plugin-kde-services.c deleted file mode 100644 index 48e3773..0000000 --- a/libappstream-builder/plugins/asb-plugin-kde-services.c +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2014 Richard Hughes - * - * Licensed under the GNU Lesser General Public License Version 2.1 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include -#include - -/** - * asb_plugin_get_name: - */ -const gchar * -asb_plugin_get_name (void) -{ - return "kde-services"; -} - -/** - * asb_plugin_add_globs: - */ -void -asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs) -{ - asb_plugin_add_glob (globs, "/usr/share/kde4/services/*.desktop"); -} - -/** - * asb_plugin_process_filename: - */ -static gboolean -asb_plugin_process_filename (const gchar *filename, - AsbApp *app, - const gchar *tmpdir, - GError **error) -{ - g_autofree gchar *types = NULL; - g_autoptr(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; - asb_package_log (asb_app_get_package (app), - ASB_PACKAGE_LOG_LEVEL_DEBUG, - "Auto-adding kudo SearchProvider for %s", - as_app_get_id (AS_APP (app))); - as_app_add_kudo_kind (AS_APP (app), AS_KUDO_KIND_SEARCH_PROVIDER); - return TRUE; -} - -/** - * asb_plugin_process_app: - */ -gboolean -asb_plugin_process_app (AsbPlugin *plugin, - AsbPackage *pkg, - AsbApp *app, - const gchar *tmpdir, - GError **error) -{ - gchar **filelist; - guint i; - - /* already set */ - if (as_app_has_kudo_kind (AS_APP (app), AS_KUDO_KIND_SEARCH_PROVIDER)) - return TRUE; - - /* look for a krunner provider */ - filelist = asb_package_get_filelist (pkg); - for (i = 0; filelist[i] != NULL; i++) { - g_autoptr(GError) error_local = NULL; - g_autofree gchar *filename = NULL; - if (!asb_plugin_match_glob ("/usr/share/kde4/services/*.desktop", filelist[i])) - continue; - filename = g_build_filename (tmpdir, filelist[i], NULL); - 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); - } - } - - return TRUE; -} diff --git a/libappstream-builder/plugins/asb-plugin-nm.c b/libappstream-builder/plugins/asb-plugin-nm.c deleted file mode 100644 index 4f7ce14..0000000 --- a/libappstream-builder/plugins/asb-plugin-nm.c +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2014 Richard Hughes - * - * Licensed under the GNU Lesser General Public License Version 2.1 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include - -/** - * asb_plugin_get_name: - */ -const gchar * -asb_plugin_get_name (void) -{ - return "nm"; -} - -/** - * asb_plugin_add_globs: - */ -void -asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs) -{ - asb_plugin_add_glob (globs, "/usr/bin/*"); -} - -static gboolean -asb_plugin_nm_app (AsbApp *app, const gchar *filename, GError **error) -{ - gboolean ret; - g_autofree gchar *data_err = NULL; - g_autofree gchar *data_out = NULL; - const gchar *argv[] = { "/usr/bin/nm", - "--dynamic", - "--no-sort", - "--undefined-only", - filename, - NULL }; - - ret = g_spawn_sync (NULL, (gchar **) argv, NULL, -#if GLIB_CHECK_VERSION(2,40,0) - G_SPAWN_CLOEXEC_PIPES, -#else - G_SPAWN_DEFAULT, -#endif - NULL, NULL, - &data_out, - &data_err, - NULL, error); - if (!ret) - return FALSE; - if (g_strstr_len (data_out, -1, "gtk_application_new") != NULL) { - if (!as_app_has_kudo_kind (AS_APP (app), AS_KUDO_KIND_MODERN_TOOLKIT)) { - asb_package_log (asb_app_get_package (app), - ASB_PACKAGE_LOG_LEVEL_DEBUG, - "Auto-adding kudo AppMenu for %s", - as_app_get_id (AS_APP (app))); - as_app_add_kudo_kind (AS_APP (app), AS_KUDO_KIND_MODERN_TOOLKIT); - } - } - if (g_strstr_len (data_out, -1, "gtk_application_set_app_menu") != NULL || - g_strstr_len (data_out, -1, "gtk_application_get_menu_by_id") != NULL) { - if (!as_app_has_kudo_kind (AS_APP (app), AS_KUDO_KIND_APP_MENU)) { - asb_package_log (asb_app_get_package (app), - ASB_PACKAGE_LOG_LEVEL_DEBUG, - "Auto-adding kudo AppMenu for %s", - as_app_get_id (AS_APP (app))); - as_app_add_kudo_kind (AS_APP (app), AS_KUDO_KIND_APP_MENU); - } - } - return TRUE; -} - -/** - * asb_plugin_process_app: - */ -gboolean -asb_plugin_process_app (AsbPlugin *plugin, - AsbPackage *pkg, - AsbApp *app, - const gchar *tmpdir, - GError **error) -{ - gchar **filelist; - guint i; - - /* already set */ - if (as_app_has_kudo_kind (AS_APP (app), AS_KUDO_KIND_APP_MENU) && - as_app_has_kudo_kind (AS_APP (app), AS_KUDO_KIND_MODERN_TOOLKIT)) - return TRUE; - - filelist = asb_package_get_filelist (pkg); - for (i = 0; filelist[i] != NULL; i++) { - GError *error_local = NULL; - g_autofree gchar *filename = NULL; - - if (!asb_plugin_match_glob ("/usr/bin/*", filelist[i])) - continue; - if (as_app_has_kudo_kind (AS_APP (app), AS_KUDO_KIND_APP_MENU)) - break; - filename = g_build_filename (tmpdir, filelist[i], NULL); - if (!asb_plugin_nm_app (app, filename, &error_local)) { - asb_package_log (pkg, - ASB_PACKAGE_LOG_LEVEL_WARNING, - "Failed to run nm on %s: %s", - filename, - error_local->message); - g_clear_error (&error_local); - } - } - return TRUE; -} -- cgit v1.2.1