Commit d3648252 authored by Richard Hughes's avatar Richard Hughes

Use libxmlb to parse AppStream XML

The libxmlb library is much faster to load and query as it does not require
the client to parse all the XML metadata at startup. It's a zero-copy mmap
design that is more modern and less clunky. In case of memory pressure on low
RAM machines, the compressed XML is evicted from memory and automatically
reloaded when required.

For a single operation, startup time has decreased by 40%, and RSS usage is
down by a massive 78%. The GUI process has similar wins, with a reduction in
startup time by 13% and RSS usage is down by 45%. This now means the idle
process uses less than 50Mb with all plugins enabled.
parent 04920ec4
......@@ -7,6 +7,7 @@ before_script:
# Update and use base build deps
- dnf update -y && dnf -y install dnf-plugins-core @buildsys-build
- dnf install -y https://people.freedesktop.org/~hughsient/temp/libappstream-glib-0.7.14-0.641.20181015git.fc29.x86_64.rpm https://people.freedesktop.org/~hughsient/temp/libappstream-glib-devel-0.7.14-0.641.20181015git.fc29.x86_64.rpm
- dnf install -y https://people.freedesktop.org/~hughsient/temp/libxmlb-0.1.2-0.49.20181016git.fc29.x86_64.rpm https://people.freedesktop.org/~hughsient/temp/libxmlb-devel-0.1.2-0.49.20181016git.fc29.x86_64.rpm
- dnf --enablerepo updates-testing -y builddep gnome-software
# Some deps may not be sync'd
- dnf -y install rpm-ostree-devel
......
......@@ -98,6 +98,7 @@ conf.set('HAVE_LINUX_UNISTD_H', cc.has_header('linux/unistd.h'))
appstream_glib = dependency('appstream-glib', version : '>= 0.7.14')
gdk_pixbuf = dependency('gdk-pixbuf-2.0', version : '>= 2.32.0')
libxmlb = dependency('xmlb', version : '>= 0.1.2')
gio_unix = dependency('gio-unix-2.0', version : '>= 2.56.0')
gmodule = dependency('gmodule-2.0')
gtk = dependency('gtk+-3.0', version : '>= 3.22.4')
......
This diff is collapsed.
......@@ -23,57 +23,67 @@
#define __APPSTREAM_COMMON_H
#include <gnome-software.h>
#include <xmlb.h>
G_BEGIN_DECLS
GsApp *gs_appstream_create_app (GsPlugin *plugin,
AsApp *item,
XbSilo *silo,
XbNode *component,
GError **error);
gboolean gs_appstream_refine_app (GsPlugin *plugin,
GsApp *app,
AsApp *item,
XbSilo *silo,
XbNode *component,
GsPluginRefineFlags flags,
GError **error);
gboolean gs_appstream_store_search (GsPlugin *plugin,
AsStore *store,
gboolean gs_appstream_search (GsPlugin *plugin,
XbSilo *silo,
gchar **values,
GsAppList *list,
GCancellable *cancellable,
GError **error);
gboolean gs_appstream_store_add_categories (GsPlugin *plugin,
AsStore *store,
gboolean gs_appstream_add_categories (GsPlugin *plugin,
XbSilo *silo,
GPtrArray *list,
GCancellable *cancellable,
GError **error);
gboolean gs_appstream_store_add_category_apps (GsPlugin *plugin,
AsStore *store,
gboolean gs_appstream_add_category_apps (GsPlugin *plugin,
XbSilo *silo,
GsCategory *category,
GsAppList *list,
GCancellable *cancellable,
GError **error);
gboolean gs_appstream_add_popular (GsPlugin *plugin,
AsStore *store,
XbSilo *silo,
GsAppList *list,
GCancellable *cancellable,
GError **error);
gboolean gs_appstream_add_featured (GsPlugin *plugin,
AsStore *store,
XbSilo *silo,
GsAppList *list,
GCancellable *cancellable,
GError **error);
gboolean gs_appstream_add_alternates (GsPlugin *plugin,
AsStore *store,
XbSilo *silo,
GsApp *app,
GsAppList *list,
GCancellable *cancellable,
GError **error);
gboolean gs_appstream_add_recent (GsPlugin *plugin,
AsStore *store,
XbSilo *silo,
GsAppList *list,
guint64 age,
GCancellable *cancellable,
GError **error);
void gs_appstream_add_extra_info (GsPlugin *plugin,
AsApp *app);
void gs_appstream_component_add_extra_info (GsPlugin *plugin,
XbBuilderNode *component);
void gs_appstream_component_add_keyword (XbBuilderNode *component,
const gchar *str);
void gs_appstream_component_add_category (XbBuilderNode *component,
const gchar *str);
void gs_appstream_component_add_icon (XbBuilderNode *component,
const gchar *str);
G_END_DECLS
......
This diff is collapsed.
......@@ -21,6 +21,8 @@
#include "config.h"
#include <glib/gstdio.h>
#include "gnome-software-private.h"
#include "gs-appstream.h"
......@@ -37,6 +39,7 @@ gs_plugins_core_search_repo_name_func (GsPluginLoader *plugin_loader)
g_autoptr(GsPluginJob) plugin_job = NULL;
/* drop all caches */
g_unlink ("/var/tmp/self-test/appstream/components.xmlb");
gs_plugin_loader_setup_again (plugin_loader);
/* force this app to be installed */
......@@ -70,6 +73,7 @@ gs_plugins_core_os_release_func (GsPluginLoader *plugin_loader)
g_autoptr(GError) error = NULL;
/* drop all caches */
g_unlink ("/var/tmp/self-test/appstream/components.xmlb");
gs_plugin_loader_setup_again (plugin_loader);
/* refine system application */
......@@ -120,6 +124,7 @@ gs_plugins_core_generic_updates_func (GsPluginLoader *plugin_loader)
g_autoptr(GsAppList) list_wildcard = NULL;
/* drop all caches */
g_unlink ("/var/tmp/self-test/appstream/components.xmlb");
gs_plugin_loader_setup_again (plugin_loader);
/* create a list with generic apps */
......@@ -204,7 +209,7 @@ main (int argc, char **argv)
g_test_init (&argc, &argv, NULL);
g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
g_setenv ("GS_SELF_TEST_CORE_DATADIR", tmp_root, TRUE);
g_setenv ("GS_SELF_TEST_CACHEDIR", tmp_root, TRUE);
os_release_filename = gs_test_get_filename (TESTDATADIR, "os-release");
g_assert (os_release_filename != NULL);
......@@ -235,10 +240,10 @@ main (int argc, char **argv)
" <component type=\"os-upgrade\">\n"
" <id>org.fedoraproject.Fedora-25</id>\n"
" <summary>Fedora Workstation</summary>\n"
" <pkgname>fedora-release</pkgname>\n"
" </component>\n"
"</components>\n";
g_setenv ("GS_SELF_TEST_APPSTREAM_XML", xml, TRUE);
g_setenv ("GS_SELF_TEST_ALL_ORIGIN_KEYWORDS", "1", TRUE);
/* only critical and error are fatal */
g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
......
......@@ -92,7 +92,10 @@ shared_module(
install : true,
install_dir: plugin_dir,
c_args : cargs,
dependencies : plugin_libs
dependencies : [
plugin_libs,
libxmlb,
],
)
shared_module(
......@@ -208,6 +211,7 @@ if get_option('tests')
],
dependencies : [
plugin_libs,
libxmlb,
],
link_with : [
libgnomesoftware
......
......@@ -804,6 +804,7 @@ gs_plugin_add_distro_upgrades (GsPlugin *plugin,
app = gs_app_new ("org.fedoraproject.release-rawhide.upgrade");
gs_app_set_scope (app, AS_APP_SCOPE_USER);
gs_app_set_kind (app, AS_APP_KIND_OS_UPGRADE);
gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE);
gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
gs_app_set_name (app, GS_APP_QUALITY_LOWEST, "Fedora");
gs_app_set_summary (app, GS_APP_QUALITY_NORMAL,
......
......@@ -21,6 +21,8 @@
#include "config.h"
#include <glib/gstdio.h>
#include "gnome-software-private.h"
#include "gs-test.h"
......@@ -104,6 +106,7 @@ gs_plugins_dummy_error_func (GsPluginLoader *plugin_loader)
g_autoptr(GsPluginJob) plugin_job = NULL;
/* drop all caches */
g_unlink ("/var/tmp/self-test/appstream/components.xmlb");
gs_plugin_loader_setup_again (plugin_loader);
/* update, which should cause an error to be emitted */
......@@ -426,7 +429,7 @@ gs_plugins_dummy_search_func (GsPluginLoader *plugin_loader)
/* get search result based on addon keyword */
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_SEARCH,
"search", "spell",
"search", "zeus",
"refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
NULL);
list = gs_plugin_loader_job_process (plugin_loader, plugin_job, NULL, &error);
......@@ -480,6 +483,7 @@ gs_plugins_dummy_hang_func (GsPluginLoader *plugin_loader)
g_autoptr(GsPluginJob) plugin_job = NULL;
/* drop all caches */
g_unlink ("/var/tmp/self-test/appstream/components.xmlb");
gs_plugin_loader_setup_again (plugin_loader);
/* get search result based on addon keyword */
......@@ -736,6 +740,7 @@ gs_plugins_dummy_limit_parallel_ops_func (GsPluginLoader *plugin_loader)
g_autoptr(GsDummyTestHelper) helper3 = gs_dummy_test_helper_new ();
/* drop all caches */
g_unlink ("/var/tmp/self-test/appstream/components.xmlb");
gs_plugin_loader_setup_again (plugin_loader);
/* get the updates list */
......@@ -827,6 +832,7 @@ gs_plugins_dummy_limit_parallel_ops_func (GsPluginLoader *plugin_loader)
int
main (int argc, char **argv)
{
const gchar *tmp_root = "/var/tmp/self-test";
gboolean ret;
g_autofree gchar *xml = NULL;
g_autoptr(GError) error = NULL;
......@@ -847,6 +853,7 @@ main (int argc, char **argv)
g_test_init (&argc, &argv, NULL);
g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
g_setenv ("GS_XMLB_VERBOSE", "1", TRUE);
/* set all the things required as a dummy test harness */
g_setenv ("GS_SELF_TEST_LOCALE", "en_GB", TRUE);
......@@ -855,6 +862,7 @@ main (int argc, char **argv)
g_setenv ("GS_SELF_TEST_PROVENANCE_LICENSE_SOURCES", "london*,boston", TRUE);
g_setenv ("GS_SELF_TEST_PROVENANCE_LICENSE_URL", "https://www.debian.org/", TRUE);
g_setenv ("GNOME_SOFTWARE_POPULAR", "", TRUE);
g_setenv ("GS_SELF_TEST_CACHEDIR", tmp_root, TRUE);
xml = g_strdup ("<?xml version=\"1.0\"?>\n"
"<components version=\"0.9\">\n"
......@@ -900,6 +908,7 @@ main (int argc, char **argv)
" <component type=\"os-upgrade\">\n"
" <id>org.fedoraproject.release-rawhide.upgrade</id>\n"
" <summary>Release specific tagline</summary>\n"
" <pkgname>fedora-release</pkgname>\n"
" </component>\n"
"</components>\n");
g_setenv ("GS_SELF_TEST_APPSTREAM_XML", xml, TRUE);
......
......@@ -70,6 +70,7 @@ main (int argc, char **argv)
g_test_init (&argc, &argv, NULL);
g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
g_setenv ("GS_XMLB_VERBOSE", "1", TRUE);
fn = gs_test_get_filename (TESTDATADIR, "icons/hicolor/scalable/org.gnome.Software.svg");
g_assert (fn != NULL);
......@@ -78,6 +79,7 @@ main (int argc, char **argv)
" <component type=\"webapp\">\n"
" <id>arachne.desktop</id>\n"
" <name>test</name>\n"
" <pkgname>test</pkgname>\n"
" <icon type=\"remote\">file://%s</icon>\n"
" </component>\n"
"</components>\n", fn);
......
......@@ -24,10 +24,8 @@
#include <locale.h>
#include <stdlib.h>
#include <appstream-glib.h>
#include <gio/gio.h>
#include <xmlb.h>
#include <glib/gi18n.h>
#include <glib-object.h>
#include "gs-external-appstream-utils.h"
......@@ -59,8 +57,12 @@ static gboolean
gs_install_appstream_check_content_type (GFile *file, GError **error)
{
const gchar *type;
g_autoptr(AsStore) store = NULL;
g_autoptr(GError) error_local = NULL;
g_autoptr(GFileInfo) info = NULL;
g_autoptr(GPtrArray) components = NULL;
g_autoptr(XbBuilder) builder = xb_builder_new ();
g_autoptr(XbBuilderSource) source = xb_builder_source_new ();
g_autoptr(XbSilo) silo = NULL;
/* check is correct type */
info = g_file_query_info (file,
......@@ -80,14 +82,38 @@ gs_install_appstream_check_content_type (GFile *file, GError **error)
}
/* check is an AppStream file */
store = as_store_new ();
if (!as_store_from_file (store, file, NULL, NULL, error))
if (!xb_builder_source_load_file (source, file,
XB_BUILDER_SOURCE_FLAG_NONE,
NULL, &error_local)) {
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"Failed to import XML: %s", error_local->message);
return FALSE;
if (as_store_get_size (store) == 0) {
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"No applications found in the AppStream XML");
}
xb_builder_import_source (builder, source);
silo = xb_builder_compile (builder, XB_BUILDER_COMPILE_FLAG_NONE,
NULL, &error_local);
if (silo == NULL) {
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"Failed to parse XML: %s", error_local->message);
return FALSE;
}
components = xb_silo_query (silo, "components/component", 0, &error_local);
if (components == NULL) {
if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"No applications found in the AppStream XML");
return FALSE;
}
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"Failed to query XML: %s", error_local->message);
return FALSE;
}
......
......@@ -9,7 +9,10 @@ executable(
include_directories : [
include_directories('../..'),
],
dependencies : [gio_unix, appstream_glib],
dependencies : [
gio_unix,
libxmlb,
],
c_args : cargs,
install : true,
install_dir : get_option('libexecdir')
......
This diff is collapsed.
......@@ -22,6 +22,8 @@
#include "config.h"
#include <glib/gstdio.h>
#include "gnome-software-private.h"
#include "gs-flatpak-app.h"
......@@ -230,6 +232,8 @@ gs_plugins_flatpak_app_with_runtime_func (GsPluginLoader *plugin_loader)
g_autoptr(GsPluginJob) plugin_job = NULL;
/* drop all caches */
g_unlink ("/var/tmp/self-test/flatpak-user/components.xmlb");
g_unlink ("/var/tmp/self-test/appstream/components.xmlb");
gs_plugin_loader_setup_again (plugin_loader);
/* no flatpak, abort */
......@@ -323,6 +327,8 @@ gs_plugins_flatpak_app_with_runtime_func (GsPluginLoader *plugin_loader)
"refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_HOSTNAME |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_PERMISSIONS |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_KUDOS |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
NULL);
list = gs_plugin_loader_job_process (plugin_loader, plugin_job, NULL, &error);
......@@ -332,7 +338,7 @@ gs_plugins_flatpak_app_with_runtime_func (GsPluginLoader *plugin_loader)
/* make sure there is one entry, the flatpak app */
g_assert_cmpint (gs_app_list_length (list), ==, 1);
app = gs_app_list_index (list, 0);
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron.desktop");
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
g_assert_cmpint (gs_app_get_kind (app), ==, AS_APP_KIND_DESKTOP);
g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_AVAILABLE);
g_assert_cmpint ((gint64) gs_app_get_kudos (app), ==,
......@@ -496,6 +502,8 @@ gs_plugins_flatpak_app_missing_runtime_func (GsPluginLoader *plugin_loader)
g_autoptr(GsPluginJob) plugin_job = NULL;
/* drop all caches */
g_unlink ("/var/tmp/self-test/flatpak-user/components.xmlb");
g_unlink ("/var/tmp/self-test/appstream/components.xmlb");
gs_plugin_loader_setup_again (plugin_loader);
/* no flatpak, abort */
......@@ -552,7 +560,7 @@ gs_plugins_flatpak_app_missing_runtime_func (GsPluginLoader *plugin_loader)
/* make sure there is one entry, the flatpak app */
g_assert_cmpint (gs_app_list_length (list), ==, 1);
app = gs_app_list_index (list, 0);
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron.desktop");
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_AVAILABLE);
/* install, also installing runtime */
......@@ -642,6 +650,8 @@ gs_plugins_flatpak_runtime_repo_func (GsPluginLoader *plugin_loader)
g_autoptr(GsPluginJob) plugin_job = NULL;
/* drop all caches */
g_unlink ("/var/tmp/self-test/flatpak-user/components.xmlb");
g_unlink ("/var/tmp/self-test/appstream/components.xmlb");
gs_plugin_loader_setup_again (plugin_loader);
/* write a flatpakrepo file */
......@@ -675,9 +685,9 @@ gs_plugins_flatpak_runtime_repo_func (GsPluginLoader *plugin_loader)
g_assert (app != NULL);
g_assert_cmpint (gs_app_get_kind (app), ==, AS_APP_KIND_DESKTOP);
g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_AVAILABLE_LOCAL);
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron.desktop");
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
g_assert (as_utils_unique_id_equal (gs_app_get_unique_id (app),
"user/flatpak/org.test.Chiron-origin/desktop/org.test.Chiron.desktop/master"));
"user/flatpak/*/desktop/org.test.Chiron/master"));
g_assert (gs_app_get_local_file (app) != NULL);
/* get runtime */
......@@ -777,6 +787,8 @@ gs_plugins_flatpak_runtime_repo_redundant_func (GsPluginLoader *plugin_loader)
g_autoptr(GsPluginJob) plugin_job = NULL;
/* drop all caches */
g_unlink ("/var/tmp/self-test/flatpak-user/components.xmlb");
g_unlink ("/var/tmp/self-test/appstream/components.xmlb");
gs_plugin_loader_setup_again (plugin_loader);
/* write a flatpakrepo file */
......@@ -839,9 +851,9 @@ gs_plugins_flatpak_runtime_repo_redundant_func (GsPluginLoader *plugin_loader)
g_assert (app != NULL);
g_assert_cmpint (gs_app_get_kind (app), ==, AS_APP_KIND_DESKTOP);
g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_AVAILABLE_LOCAL);
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron.desktop");
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
g_assert (as_utils_unique_id_equal (gs_app_get_unique_id (app),
"user/flatpak/org.test.Chiron-origin/desktop/org.test.Chiron.desktop/master"));
"user/flatpak/*/desktop/org.test.Chiron/master"));
g_assert (gs_app_get_local_file (app) != NULL);
/* get runtime */
......@@ -930,6 +942,8 @@ gs_plugins_flatpak_broken_remote_func (GsPluginLoader *plugin_loader)
g_autoptr(GsPluginJob) plugin_job = NULL;
/* drop all caches */
g_unlink ("/var/tmp/self-test/flatpak-user/components.xmlb");
g_unlink ("/var/tmp/self-test/appstream/components.xmlb");
gs_plugin_loader_setup_again (plugin_loader);
/* no flatpak, abort */
......@@ -974,9 +988,9 @@ gs_plugins_flatpak_broken_remote_func (GsPluginLoader *plugin_loader)
g_assert (app != NULL);
g_assert_cmpint (gs_app_get_kind (app), ==, AS_APP_KIND_DESKTOP);
g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_AVAILABLE_LOCAL);
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron.desktop");
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
g_assert (as_utils_unique_id_equal (gs_app_get_unique_id (app),
"user/flatpak/org.test.Chiron-origin/desktop/org.test.Chiron.desktop/master"));
"user/flatpak/org.test.Chiron-origin/desktop/org.test.Chiron/master"));
g_assert_cmpstr (gs_app_get_url (app, AS_URL_KIND_HOMEPAGE), ==, "http://127.0.0.1/");
g_assert_cmpstr (gs_app_get_name (app), ==, "Chiron");
g_assert_cmpstr (gs_app_get_summary (app), ==, "Single line synopsis");
......@@ -1018,6 +1032,8 @@ gs_plugins_flatpak_ref_func (GsPluginLoader *plugin_loader)
g_autoptr(GString) str = g_string_new (NULL);
/* drop all caches */
g_unlink ("/var/tmp/self-test/flatpak-user/components.xmlb");
g_unlink ("/var/tmp/self-test/appstream/components.xmlb");
gs_plugin_loader_setup_again (plugin_loader);
/* no flatpak, abort */
......@@ -1093,6 +1109,8 @@ gs_plugins_flatpak_ref_func (GsPluginLoader *plugin_loader)
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_FILE_TO_APP,
"file", file,
"refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_URL |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME,
NULL);
app = gs_plugin_loader_job_process_app (plugin_loader, plugin_job, NULL, &error);
......@@ -1100,9 +1118,9 @@ gs_plugins_flatpak_ref_func (GsPluginLoader *plugin_loader)
g_assert (app != NULL);
g_assert_cmpint (gs_app_get_kind (app), ==, AS_APP_KIND_DESKTOP);
g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_AVAILABLE_LOCAL);
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron.desktop");
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
g_assert (as_utils_unique_id_equal (gs_app_get_unique_id (app),
"user/flatpak/org.test.Chiron-origin/desktop/org.test.Chiron.desktop/master"));
"user/flatpak/org.test.Chiron-origin/desktop/org.test.Chiron/master"));
g_assert_cmpstr (gs_app_get_url (app, AS_URL_KIND_HOMEPAGE), ==, "http://127.0.0.1/");
g_assert_cmpstr (gs_app_get_name (app), ==, "Chiron");
g_assert_cmpstr (gs_app_get_summary (app), ==, "Single line synopsis");
......@@ -1140,7 +1158,7 @@ gs_plugins_flatpak_ref_func (GsPluginLoader *plugin_loader)
g_assert (search1 != NULL);
g_assert_cmpint (gs_app_list_length (search1), ==, 1);
app_tmp = gs_app_list_index (search1, 0);
g_assert_cmpstr (gs_app_get_id (app_tmp), ==, "org.test.Chiron.desktop");
g_assert_cmpstr (gs_app_get_id (app_tmp), ==, "org.test.Chiron");
/* convert it to a GsApp again, and get the installed thing */
g_object_unref (plugin_job);
......@@ -1154,7 +1172,7 @@ gs_plugins_flatpak_ref_func (GsPluginLoader *plugin_loader)
g_assert (app2 != NULL);
g_assert_cmpint (gs_app_get_state (app2), ==, AS_APP_STATE_INSTALLED);
g_assert (as_utils_unique_id_equal (gs_app_get_unique_id (app2),
"user/flatpak/org.test.Chiron-origin/desktop/org.test.Chiron.desktop/master"));
"user/flatpak/org.test.Chiron-origin/desktop/org.test.Chiron/master"));
/* remove app */
g_object_unref (plugin_job);
......@@ -1237,6 +1255,8 @@ gs_plugins_flatpak_app_update_func (GsPluginLoader *plugin_loader)
g_autoptr(GMainLoop) loop = g_main_loop_new (NULL, FALSE);
/* drop all caches */
g_unlink ("/var/tmp/self-test/flatpak-user/components.xmlb");
g_unlink ("/var/tmp/self-test/appstream/components.xmlb");
gs_plugin_loader_setup_again (plugin_loader);
/* no flatpak, abort */
......@@ -1301,7 +1321,7 @@ gs_plugins_flatpak_app_update_func (GsPluginLoader *plugin_loader)
/* make sure there is one entry, the flatpak app */
g_assert_cmpint (gs_app_list_length (list), ==, 1);
app = gs_app_list_index (list, 0);
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron.desktop");
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_AVAILABLE);
/* install, also installing runtime */
......@@ -1351,7 +1371,7 @@ gs_plugins_flatpak_app_update_func (GsPluginLoader *plugin_loader)
}
/* check they are the same GObject */
app_tmp = gs_app_list_lookup (list_updates, "*/flatpak/test/*/org.test.Chiron.desktop/*");
app_tmp = gs_app_list_lookup (list_updates, "*/flatpak/test/*/org.test.Chiron/*");
g_assert (app_tmp == app);
g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_UPDATABLE_LIVE);
g_assert_cmpstr (gs_app_get_update_details (app), ==, "Version 1.2.4:\nThis is best.\n\nVersion 1.2.3:\nThis is better.");
......@@ -1484,6 +1504,8 @@ gs_plugins_flatpak_runtime_extension_func (GsPluginLoader *plugin_loader)
g_autoptr(GMainLoop) loop = g_main_loop_new (NULL, FALSE);
/* drop all caches */
g_unlink ("/var/tmp/self-test/flatpak-user/components.xmlb");
g_unlink ("/var/tmp/self-test/appstream/components.xmlb");
gs_plugin_loader_setup_again (plugin_loader);
/* no flatpak, abort */
......@@ -1545,7 +1567,7 @@ gs_plugins_flatpak_runtime_extension_func (GsPluginLoader *plugin_loader)
/* make sure there is one entry, the flatpak app */
g_assert_cmpint (gs_app_list_length (list), ==, 1);
app = gs_app_list_index (list, 0);
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron.desktop");
g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_AVAILABLE);
/* install, also installing runtime and suggested extensions */
......@@ -1601,7 +1623,7 @@ gs_plugins_flatpak_runtime_extension_func (GsPluginLoader *plugin_loader)
g_assert_null (app_tmp);
/* check that the app has an update (it's affected by the extension's update) */
app_tmp = gs_app_list_lookup (list_updates, "*/flatpak/test/*/org.test.Chiron.desktop/*");
app_tmp = gs_app_list_lookup (list_updates, "*/flatpak/test/*/org.test.Chiron/*");
g_assert (app_tmp == app);
g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_UPDATABLE_LIVE);
......@@ -1703,6 +1725,8 @@ main (int argc, char **argv)
g_test_init (&argc, &argv, NULL);
g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
g_setenv ("GS_XMLB_VERBOSE", "1", TRUE);
g_setenv ("GS_SELF_TEST_CACHEDIR", tmp_root, TRUE);
g_setenv ("GS_SELF_TEST_FLATPAK_DATADIR", tmp_root, TRUE);
g_setenv ("GS_SELF_TEST_PLUGIN_ERROR_FAIL_HARD", "1", TRUE);
......
......@@ -19,7 +19,11 @@ shared_module(
install : true,
install_dir: plugin_dir,
c_args : cargs,
dependencies : [ plugin_libs, flatpak ]
dependencies : [
plugin_libs,
flatpak,
libxmlb,
],
)
metainfo = 'org.gnome.Software.Plugin.Flatpak.metainfo.xml'
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2016 Richard Hughes <richard@hughsie.com> -->
<component type="desktop">
<id>org.test.Chiron.desktop</id>
<id>org.test.Chiron</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0+</project_license>
<name>Chiron</name>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2016 Richard Hughes <richard@hughsie.com> -->
<component type="desktop">
<id>org.test.Chiron.desktop</id>
<id>org.test.Chiron</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0+</project_license>
<name>Chiron</name>
......
......@@ -56,6 +56,7 @@ gs_plugins_modalias_func (GsPluginLoader *plugin_loader)
int
main (int argc, char **argv)
{
const gchar *tmp_root = "/var/tmp/self-test";
gboolean ret;
g_autofree gchar *xml = NULL;
g_autoptr(GError) error = NULL;
......@@ -77,12 +78,14 @@ main (int argc, char **argv)
" <id>com.hughski.ColorHug2.driver</id>\n"
" <name>ColorHug2</name>\n"
" <summary>ColorHug2 Colorimeter Driver</summary>\n"
" <pkgname>colorhug-client</pkgname>\n"
" <provides>\n"
" <modalias>pci:*</modalias>\n"
" </provides>\n"
" </component>\n"
"</components>\n");
g_setenv ("GS_SELF_TEST_APPSTREAM_XML", xml, TRUE);
g_setenv ("GS_SELF_TEST_CACHEDIR", tmp_root, TRUE);
/* only critical and error are fatal */
g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment