diff options
author | Richard Hughes <richard@hughsie.com> | 2016-12-06 20:02:56 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2016-12-06 20:02:59 +0000 |
commit | 4672b11be09c0133e3aaf98ce54125178d0be704 (patch) | |
tree | 3cbe2d4eb0dc34cb4b7f8f74247914c3576da55a | |
parent | 9ef273b43aa533942f65530fab731ba9c0dbf003 (diff) | |
download | appstream-glib-4672b11be09c0133e3aaf98ce54125178d0be704.tar.gz |
Do not absorb core addons into the main application
Adding this to the metadata means we do not have to look up the metadata source
using the package manager.
-rw-r--r-- | libappstream-builder/asb-self-test.c | 63 | ||||
-rw-r--r-- | libappstream-builder/plugins/Makefile.am | 6 | ||||
-rw-r--r-- | libappstream-builder/plugins/asb-plugin-absorb.c | 124 |
3 files changed, 15 insertions, 178 deletions
diff --git a/libappstream-builder/asb-self-test.c b/libappstream-builder/asb-self-test.c index bcba127..8515176 100644 --- a/libappstream-builder/asb-self-test.c +++ b/libappstream-builder/asb-self-test.c @@ -414,9 +414,9 @@ asb_test_context_test_func (AsbTestContextMode mode) g_assert_no_error (error); g_assert (ret); #ifdef HAVE_FONTS - g_assert_cmpint (as_store_get_size (store), ==, 4); + g_assert_cmpint (as_store_get_size (store), ==, 5); #else - g_assert_cmpint (as_store_get_size (store), ==, 3); + g_assert_cmpint (as_store_get_size (store), ==, 4); #endif app = as_store_get_app_by_pkgname (store, "app"); g_assert (app != NULL); @@ -465,28 +465,26 @@ asb_test_context_test_func (AsbTestContextMode mode) "</component>\n" #endif "<component type=\"addon\">\n" + "<id>app-core</id>\n" + "<pkgname>app</pkgname>\n" + "<name>Core</name>\n" + "<summary>Addons for core functionality</summary>\n" + "<project_license>GPL-2.0+</project_license>\n" + "<url type=\"homepage\">http://people.freedesktop.org/</url>\n" + "<extends>app.desktop</extends>\n" + "<metadata>\n" + "<value key=\"X-CacheID\">app-1-1.fc21.x86_64.rpm</value>\n" + "</metadata>\n" + "</component>\n" + "<component type=\"addon\">\n" "<id>app-extra</id>\n" "<pkgname>app-extra</pkgname>\n" "<source_pkgname>app</source_pkgname>\n" "<name>Extra</name>\n" "<summary>Addons for extra functionality</summary>\n" - "<kudos>\n" - "<kudo>ModernToolkit</kudo>\n" - "<kudo>SearchProvider</kudo>\n" - "</kudos>\n" "<project_license>GPL-2.0+</project_license>\n" "<url type=\"homepage\">http://people.freedesktop.org/</url>\n" "<extends>app.desktop</extends>\n" - "<releases>\n" - "<release timestamp=\"1407844800\" version=\"1\"/>\n" - "</releases>\n" - "<provides>\n" - "<dbus type=\"session\">org.freedesktop.AppStream</dbus>\n" - "</provides>\n" - "<languages>\n" - "<lang percentage=\"100\">en_GB</lang>\n" - "<lang percentage=\"33\">ru</lang>\n" - "</languages>\n" "<metadata>\n" "<value key=\"X-CacheID\">app-extra-1-1.fc21.noarch.rpm</value>\n" "</metadata>\n" @@ -574,7 +572,7 @@ asb_test_context_test_func (AsbTestContextMode mode) ret = as_store_from_file (store_failed, file_failed, NULL, NULL, &error); g_assert_no_error (error); g_assert (ret); - g_assert_cmpint (as_store_get_size (store_failed), ==, 2); + g_assert_cmpint (as_store_get_size (store_failed), ==, 1); // app = as_store_get_app_by_id (store_failed, "console1.desktop"); // g_assert (app != NULL); // app = as_store_get_app_by_id (store_failed, "console2.desktop"); @@ -623,37 +621,6 @@ asb_test_context_test_func (AsbTestContextMode mode) "</metadata>\n" "</component>\n" #endif - "<component type=\"addon\">\n" - "<id>app-core</id>\n" - "<pkgname>app</pkgname>\n" - "<name>Core</name>\n" - "<summary>Addons for core functionality</summary>\n" - "<kudos>\n" - "<kudo>ModernToolkit</kudo>\n" - "<kudo>SearchProvider</kudo>\n" - "<kudo>UserDocs</kudo>\n" - "</kudos>\n" - "<vetos>\n" - "<veto>partially absorbing app-core into app.desktop</veto>\n" - "</vetos>\n" - "<project_license>GPL-2.0+</project_license>\n" - "<url type=\"homepage\">http://people.freedesktop.org/</url>\n" - "<extends>app.desktop</extends>\n" - "<releases>\n" - "<release timestamp=\"1407844800\" version=\"1\"/>\n" - "</releases>\n" - "<provides>\n" - "<dbus type=\"session\">org.freedesktop.AppStream</dbus>\n" - "</provides>\n" - "<languages>\n" - "<lang percentage=\"100\">en_GB</lang>\n" - "<lang percentage=\"33\">ru</lang>\n" - "</languages>\n" - "<metadata>\n" - "<value key=\"X-CacheID\">app-1-1.fc21.x86_64.rpm</value>\n" - "<value key=\"X-Merge-With-Parent\">app.desktop</value>\n" - "</metadata>\n" - "</component>\n" "</components>\n"; ret = asb_test_compare_lines (xml_failed->str, expected_xml, &error); g_assert_no_error (error); diff --git a/libappstream-builder/plugins/Makefile.am b/libappstream-builder/plugins/Makefile.am index ec82301..1807a5f 100644 --- a/libappstream-builder/plugins/Makefile.am +++ b/libappstream-builder/plugins/Makefile.am @@ -15,7 +15,6 @@ AM_CPPFLAGS = \ plugindir = $(libdir)/asb-plugins-$(AS_PLUGIN_VERSION) plugin_LTLIBRARIES = \ - libasb_plugin_absorb.la \ libasb_plugin_appdata.la \ libasb_plugin_shell_extension.la \ libasb_plugin_desktop.la \ @@ -27,11 +26,6 @@ plugin_LTLIBRARIES += \ libasb_plugin_font.la endif -libasb_plugin_absorb_la_SOURCES = asb-plugin-absorb.c -libasb_plugin_absorb_la_LIBADD = $(GLIB_LIBS) -libasb_plugin_absorb_la_LDFLAGS = -module -avoid-version -libasb_plugin_absorb_la_CFLAGS = $(GLIB_CFLAGS) $(WARN_CFLAGS) - libasb_plugin_gettext_la_SOURCES = asb-plugin-gettext.c libasb_plugin_gettext_la_LIBADD = $(GLIB_LIBS) libasb_plugin_gettext_la_LDFLAGS = -module -avoid-version diff --git a/libappstream-builder/plugins/asb-plugin-absorb.c b/libappstream-builder/plugins/asb-plugin-absorb.c deleted file mode 100644 index 8f289ba..0000000 --- a/libappstream-builder/plugins/asb-plugin-absorb.c +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2014 Richard Hughes <richard@hughsie.com> - * - * 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 <config.h> - -#include <asb-plugin.h> -#include <fnmatch.h> - -const gchar * -asb_plugin_get_name (void) -{ - return "absorb"; -} - -static void -asb_plugin_absorb_parent_for_pkgname (GList *list, AsApp *parent, const gchar *pkgname) -{ - AsApp *app; - GList *l; - - for (l = list; l != NULL; l = l->next) { - app = AS_APP (l->data); - if (as_app_get_kind (app) != AS_APP_KIND_ADDON) - continue; - if (g_strcmp0 (as_app_get_pkgname_default (app), pkgname) != 0) - continue; - if (as_app_get_vetos(app)->len > 0) - continue; - g_debug ("Adding X-Merge-With-Parent on %s as %s depends on %s", - as_app_get_id (app), - as_app_get_pkgname_default (parent), - as_app_get_pkgname_default (app)); - as_app_add_metadata (app, - "X-Merge-With-Parent", - as_app_get_id (parent)); - } -} - -static void -asb_plugin_merge_prepare_deps (GList *list) -{ - AsApp *app; - AsbPackage *pkg; - GList *l; - - for (l = list; l != NULL; l = l->next) { - app = AS_APP (l->data); - if (as_app_get_kind (app) != AS_APP_KIND_DESKTOP) - continue; - if (!ASB_IS_APP (app)) - continue; - if (as_app_get_vetos(app)->len > 0) - continue; - pkg = asb_app_get_package (ASB_APP (app)); - asb_plugin_absorb_parent_for_pkgname (list, app, asb_package_get_name (pkg)); - } -} - -void -asb_plugin_merge (AsbPlugin *plugin, GList *list) -{ - AsApp *app; - AsApp *found; - GList *l; - const gchar *tmp; - g_autoptr(GHashTable) hash = NULL; - - /* add X-Merge-With-Parent on any metainfo files that are in a package - * required by a desktop package */ - asb_plugin_merge_prepare_deps (list); - - /* add all packages to the hash */ - hash = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, (GDestroyNotify) g_object_unref); - for (l = list; l != NULL; l = l->next) { - app = AS_APP (l->data); - g_hash_table_insert (hash, - g_strdup (as_app_get_id (app)), - g_object_ref (app)); - } - - /* absorb some apps into their parent */ - for (l = list; l != NULL; l = l->next) { - app = AS_APP (l->data); - - /* no absorb metadata */ - tmp = as_app_get_metadata_item (app, "X-Merge-With-Parent"); - if (tmp == NULL) - continue; - - /* find the parent app */ - found = g_hash_table_lookup (hash, tmp); - if (found == NULL) { - as_app_add_veto (app, "No referenced '%s'", tmp); - continue; - } - - /* partially absorb */ - as_app_add_veto (app, "partially absorbing %s into %s", - as_app_get_id (app), as_app_get_id (found)); - as_app_subsume_full (found, app, - AS_APP_SUBSUME_FLAG_NO_OVERWRITE | - AS_APP_SUBSUME_FLAG_MERGE); - as_app_remove_metadata (found, "X-Merge-With-Parent"); - } -} |