[gnome-software] trivial: Split out packagekit to a new directory



commit 147248aca101a2e934bad119343260da92ff8aad
Author: Richard Hughes <richard hughsie com>
Date:   Tue Mar 7 12:53:57 2017 +0000

    trivial: Split out packagekit to a new directory

 configure.ac                                       |    1 +
 data/tests/Makefile.am                             |    1 -
 plugins/Makefile.am                                |   94 +------
 plugins/gs-self-test.c                             |  223 ---------------
 plugins/packagekit/Makefile.am                     |  102 +++++++
 plugins/{ => packagekit}/gs-markdown.c             |    0
 plugins/{ => packagekit}/gs-markdown.h             |    0
 .../gs-plugin-packagekit-history.c                 |    0
 .../{ => packagekit}/gs-plugin-packagekit-local.c  |    0
 .../gs-plugin-packagekit-offline.c                 |    0
 .../{ => packagekit}/gs-plugin-packagekit-origin.c |    0
 .../{ => packagekit}/gs-plugin-packagekit-proxy.c  |    0
 .../{ => packagekit}/gs-plugin-packagekit-refine.c |    0
 .../gs-plugin-packagekit-refresh.c                 |    0
 .../gs-plugin-packagekit-upgrade.c                 |    0
 plugins/{ => packagekit}/gs-plugin-packagekit.c    |    0
 .../{ => packagekit}/gs-plugin-systemd-updates.c   |    0
 plugins/packagekit/gs-self-test.c                  |  286 ++++++++++++++++++++
 plugins/{ => packagekit}/packagekit-common.c       |    0
 plugins/{ => packagekit}/packagekit-common.h       |    0
 {data => plugins/packagekit}/tests/build-rpm.sh    |    0
 .../packagekit}/tests/chiron-1.1-1.fc24.x86_64.rpm |  Bin 6414 -> 6414 bytes
 {data => plugins/packagekit}/tests/chiron.spec     |    0
 23 files changed, 394 insertions(+), 313 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2352531..5eeecf8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -512,6 +512,7 @@ plugins/fwupd/Makefile
 plugins/limba/Makefile
 plugins/odrs/Makefile
 plugins/ostree/Makefile
+plugins/packagekit/Makefile
 plugins/snap/Makefile
 plugins/steam/Makefile
 plugins/ubuntuone/Makefile
diff --git a/data/tests/Makefile.am b/data/tests/Makefile.am
index 00419b1..4863d1b 100644
--- a/data/tests/Makefile.am
+++ b/data/tests/Makefile.am
@@ -1,6 +1,5 @@
 EXTRA_DIST =                                           \
        os-release                                      \
-       chiron-1.1-1.fc24.x86_64.rpm                    \
        yum.repos.d/utopia.repo
 
 -include $(top_srcdir)/git.mk
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 34a8f21..6c13253 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -40,8 +40,11 @@ if HAVE_FIRMWARE
 SUBDIRS += fwupd
 endif
 
+if HAVE_PACKAGEKIT
+SUBDIRS += packagekit
+endif
+
 AM_CPPFLAGS =                                          \
-       -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE  \
        -DDATADIR=\"$(datadir)\"                        \
        -DG_LOG_DOMAIN=\"GsPlugin\"                     \
        -DLIBEXECDIR=\""$(libexecdir)"\"                \
@@ -70,20 +73,6 @@ plugin_LTLIBRARIES =                                 \
 
 appdata_in_files =
 
-if HAVE_PACKAGEKIT
-plugin_LTLIBRARIES +=                                  \
-       libgs_plugin_systemd-updates.la                 \
-       libgs_plugin_packagekit-local.la                \
-       libgs_plugin_packagekit-refine.la               \
-       libgs_plugin_packagekit-refresh.la              \
-       libgs_plugin_packagekit-offline.la              \
-       libgs_plugin_packagekit-origin.la               \
-       libgs_plugin_packagekit-proxy.la                \
-       libgs_plugin_packagekit-history.la              \
-       libgs_plugin_packagekit-upgrade.la              \
-       libgs_plugin_packagekit.la
-endif
-
 if HAVE_WEBAPPS
 plugin_LTLIBRARIES += libgs_plugin_epiphany.la
 endif
@@ -230,79 +219,6 @@ libgs_plugin_hardcoded_featured_la_LIBADD = $(GS_PLUGIN_LIBS)
 libgs_plugin_hardcoded_featured_la_LDFLAGS = -module -avoid-version
 libgs_plugin_hardcoded_featured_la_CFLAGS = $(GS_PLUGIN_CFLAGS)
 
-libgs_plugin_packagekit_la_SOURCES =                   \
-       gs-plugin-packagekit.c                          \
-       packagekit-common.c                             \
-       packagekit-common.h
-libgs_plugin_packagekit_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
-libgs_plugin_packagekit_la_LDFLAGS = -module -avoid-version
-libgs_plugin_packagekit_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
-
-libgs_plugin_packagekit_refine_la_SOURCES =            \
-       gs-plugin-packagekit-refine.c                   \
-       gs-markdown.c                                   \
-       gs-markdown.h                                   \
-       packagekit-common.c                             \
-       packagekit-common.h
-libgs_plugin_packagekit_refine_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
-libgs_plugin_packagekit_refine_la_LDFLAGS = -module -avoid-version
-libgs_plugin_packagekit_refine_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
-
-libgs_plugin_packagekit_refresh_la_SOURCES =           \
-       gs-plugin-packagekit-refresh.c                  \
-       packagekit-common.c                             \
-       packagekit-common.h
-libgs_plugin_packagekit_refresh_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
-libgs_plugin_packagekit_refresh_la_LDFLAGS = -module -avoid-version
-libgs_plugin_packagekit_refresh_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
-
-libgs_plugin_packagekit_local_la_SOURCES =             \
-       gs-plugin-packagekit-local.c                    \
-       packagekit-common.c                             \
-       packagekit-common.h
-libgs_plugin_packagekit_local_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
-libgs_plugin_packagekit_local_la_LDFLAGS = -module -avoid-version
-libgs_plugin_packagekit_local_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
-
-libgs_plugin_systemd_updates_la_SOURCES =              \
-       gs-plugin-systemd-updates.c                     \
-       packagekit-common.c                             \
-       packagekit-common.h
-libgs_plugin_systemd_updates_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
-libgs_plugin_systemd_updates_la_LDFLAGS = -module -avoid-version
-libgs_plugin_systemd_updates_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
-
-libgs_plugin_packagekit_history_la_SOURCES = gs-plugin-packagekit-history.c
-libgs_plugin_packagekit_history_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
-libgs_plugin_packagekit_history_la_LDFLAGS = -module -avoid-version
-libgs_plugin_packagekit_history_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
-
-libgs_plugin_packagekit_upgrade_la_SOURCES =           \
-       gs-plugin-packagekit-upgrade.c                  \
-       packagekit-common.c                             \
-       packagekit-common.h
-libgs_plugin_packagekit_upgrade_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
-libgs_plugin_packagekit_upgrade_la_LDFLAGS = -module -avoid-version
-libgs_plugin_packagekit_upgrade_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
-
-libgs_plugin_packagekit_offline_la_SOURCES = gs-plugin-packagekit-offline.c
-libgs_plugin_packagekit_offline_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
-libgs_plugin_packagekit_offline_la_LDFLAGS = -module -avoid-version
-libgs_plugin_packagekit_offline_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
-
-libgs_plugin_packagekit_origin_la_SOURCES =            \
-       gs-plugin-packagekit-origin.c                   \
-       packagekit-common.c                             \
-       packagekit-common.h
-libgs_plugin_packagekit_origin_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
-libgs_plugin_packagekit_origin_la_LDFLAGS = -module -avoid-version
-libgs_plugin_packagekit_origin_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
-
-libgs_plugin_packagekit_proxy_la_SOURCES = gs-plugin-packagekit-proxy.c
-libgs_plugin_packagekit_proxy_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
-libgs_plugin_packagekit_proxy_la_LDFLAGS = -module -avoid-version
-libgs_plugin_packagekit_proxy_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
-
 # MetaInfo files
 %.metainfo.xml: %.metainfo.xml.in
        $(AM_V_GEN) msgfmt --xml -d $(top_srcdir)/po --template $< -o $@
@@ -314,7 +230,7 @@ CLEANFILES = $(appdata_DATA)
 
 if ENABLE_TESTS
 check_PROGRAMS = gs-self-test
-gs_self_test_SOURCES = gs-self-test.c gs-markdown.c
+gs_self_test_SOURCES = gs-self-test.c
 gs_self_test_LDADD = $(GS_PRIVATE_LIBS)
 gs_self_test_CFLAGS = $(GS_PRIVATE_CFLAGS)
 TESTS = gs-self-test
diff --git a/plugins/gs-self-test.c b/plugins/gs-self-test.c
index a071063..1da7d8e 100644
--- a/plugins/gs-self-test.c
+++ b/plugins/gs-self-test.c
@@ -23,189 +23,8 @@
 
 #include "gnome-software-private.h"
 
-#include "gs-markdown.h"
 #include "gs-test.h"
 
-static void
-gs_markdown_func (void)
-{
-       gchar *text;
-       const gchar *markdown;
-       const gchar *markdown_expected;
-       g_autoptr(GsMarkdown) md = NULL;
-
-       /* get GsMarkdown object */
-       md = gs_markdown_new (GS_MARKDOWN_OUTPUT_PANGO);
-       g_assert (md);
-
-       markdown = "OEMs\n"
-                  "====\n"
-                  " - Bullett\n";
-       markdown_expected =
-                  "<big>OEMs</big>\n"
-                  "• Bullett";
-       /* markdown (type2 header) */
-       text = gs_markdown_parse (md, markdown);
-       g_assert_cmpstr (text, ==, markdown_expected);
-       g_free (text);
-
-       /* markdown (autocode) */
-       markdown = "this is http://www.hughsie.com/with_spaces_in_url inline link\n";
-       markdown_expected = "this is <tt>http://www.hughsie.com/with_spaces_in_url</tt> inline link";
-       gs_markdown_set_autocode (md, TRUE);
-       text = gs_markdown_parse (md, markdown);
-       g_assert_cmpstr (text, ==, markdown_expected);
-       g_free (text);
-
-       /* markdown some invalid header */
-       markdown = "*** This software is currently in alpha state ***\n";
-       markdown_expected = "<b><i> This software is currently in alpha state </b></i>";
-       text = gs_markdown_parse (md, markdown);
-       g_assert_cmpstr (text, ==, markdown_expected);
-       g_free (text);
-
-       /* markdown (complex1) */
-       markdown = " - This is a *very*\n"
-                  "   short paragraph\n"
-                  "   that is not usual.\n"
-                  " - Another";
-       markdown_expected =
-                  "• This is a <i>very</i> short paragraph that is not usual.\n"
-                  "• Another";
-       text = gs_markdown_parse (md, markdown);
-       g_assert_cmpstr (text, ==, markdown_expected);
-       g_free (text);
-
-       /* markdown (complex1) */
-       markdown = "*  This is a *very*\n"
-                  "   short paragraph\n"
-                  "   that is not usual.\n"
-                  "*  This is the second\n"
-                  "   bullett point.\n"
-                  "*  And the third.\n"
-                  " \n"
-                  "* * *\n"
-                  " \n"
-                  "Paragraph one\n"
-                  "isn't __very__ long at all.\n"
-                  "\n"
-                  "Paragraph two\n"
-                  "isn't much better.";
-       markdown_expected =
-                  "• This is a <i>very</i> short paragraph that is not usual.\n"
-                  "• This is the second bullett point.\n"
-                  "• And the third.\n"
-                  "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯\n"
-                  "Paragraph one isn&apos;t <b>very</b> long at all.\n"
-                  "Paragraph two isn&apos;t much better.";
-       text = gs_markdown_parse (md, markdown);
-       g_assert_cmpstr (text, ==, markdown_expected);
-       g_free (text);
-
-       markdown = "This is a spec file description or\n"
-                  "an **update** description in bohdi.\n"
-                  "\n"
-                  "* * *\n"
-                  "# Big title #\n"
-                  "\n"
-                  "The *following* things 'were' fixed:\n"
-                  "- Fix `dave`\n"
-                  "* Fubar update because of \"security\"\n";
-       markdown_expected =
-                  "This is a spec file description or an <b>update</b> description in bohdi.\n"
-                  "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯\n"
-                  "<big>Big title</big>\n"
-                  "The <i>following</i> things 'were' fixed:\n"
-                  "• Fix <tt>dave</tt>\n"
-                  "• Fubar update because of \"security\"";
-       /* markdown (complex2) */
-       text = gs_markdown_parse (md, markdown);
-       if (g_strcmp0 (text, markdown_expected) == 0)
-       g_assert_cmpstr (text, ==, markdown_expected);
-       g_free (text);
-
-       /* markdown (list with spaces) */
-       markdown = "* list seporated with spaces -\n"
-                  "  first item\n"
-                  "\n"
-                  "* second item\n"
-                  "\n"
-                  "* third item\n";
-       markdown_expected =
-                  "• list seporated with spaces - first item\n"
-                  "• second item\n"
-                  "• third item";
-       text = gs_markdown_parse (md, markdown);
-       g_assert_cmpstr (text, ==, markdown_expected);
-       g_free (text);
-
-       gs_markdown_set_max_lines (md, 1);
-
-       /* markdown (one line limit) */
-       markdown = "* list seporated with spaces -\n"
-                  "  first item\n"
-                  "* second item\n";
-       markdown_expected =
-                  "• list seporated with spaces - first item";
-       text = gs_markdown_parse (md, markdown);
-       g_assert_cmpstr (text, ==, markdown_expected);
-       g_free (text);
-
-       gs_markdown_set_max_lines (md, 1);
-
-       /* markdown (escaping) */
-       markdown = "* list & <spaces>";
-       markdown_expected =
-                  "• list &amp; &lt;spaces&gt;";
-       text = gs_markdown_parse (md, markdown);
-       g_assert_cmpstr (text, ==, markdown_expected);
-       g_free (text);
-
-       /* markdown (URLs) */
-       markdown = "this is the http://www.hughsie.com/ coolest site";
-       markdown_expected =
-                  "this is the "
-                  "<a href=\"http://www.hughsie.com/\";>http://www.hughsie.com/</a>"
-                  " coolest site";
-       text = gs_markdown_parse (md, markdown);
-       g_assert_cmpstr (text, ==, markdown_expected);
-       g_free (text);
-
-       /* markdown (free text) */
-       gs_markdown_set_escape (md, FALSE);
-       text = gs_markdown_parse (md, "This isn't a present");
-       g_assert_cmpstr (text, ==, "This isn't a present");
-       g_free (text);
-
-       /* markdown (autotext underscore) */
-       text = gs_markdown_parse (md, "This isn't CONFIG_UEVENT_HELPER_PATH present");
-       g_assert_cmpstr (text, ==, "This isn't <tt>CONFIG_UEVENT_HELPER_PATH</tt> present");
-       g_free (text);
-
-       /* markdown (end of bullett) */
-       markdown = "*Thu Mar 12 12:00:00 2009* Dan Walsh <dwalsh redhat com> - 2.0.79-1\n"
-                  "- Update to upstream \n"
-                  " * Netlink socket handoff patch from Adam Jackson.\n"
-                  " * AVC caching of compute_create results by Eric Paris.\n"
-                  "\n"
-                  "*Tue Mar 10 12:00:00 2009* Dan Walsh <dwalsh redhat com> - 2.0.78-5\n"
-                  "- Add patch from ajax to accellerate X SELinux \n"
-                  "- Update eparis patch\n";
-       markdown_expected =
-                  "<i>Thu Mar 12 12:00:00 2009</i> Dan Walsh <tt>&lt;dwalsh redhat com&gt;</tt> - 2.0.79-1\n"
-                  "• Update to upstream\n"
-                  "• Netlink socket handoff patch from Adam Jackson.\n"
-                  "• AVC caching of compute_create results by Eric Paris.\n"
-                  "<i>Tue Mar 10 12:00:00 2009</i> Dan Walsh <tt>&lt;dwalsh redhat com&gt;</tt> - 2.0.78-5\n"
-                  "• Add patch from ajax to accellerate X SELinux\n"
-                  "• Update eparis patch";
-       gs_markdown_set_escape (md, TRUE);
-       gs_markdown_set_max_lines (md, 1024);
-       text = gs_markdown_parse (md, markdown);
-       g_assert_cmpstr (text, ==, markdown_expected);
-       g_free (text);
-}
-
 static guint _status_changed_cnt = 0;
 
 static void
@@ -627,42 +446,6 @@ gs_plugin_loader_webapps_func (GsPluginLoader *plugin_loader)
 }
 
 static void
-gs_plugin_loader_packagekit_local_func (GsPluginLoader *plugin_loader)
-{
-       g_autoptr(GsApp) app = NULL;
-       g_autoptr(GError) error = NULL;
-       g_autofree gchar *fn = NULL;
-       g_autoptr(GFile) file = NULL;
-
-       /* no packagekit, abort */
-       if (!gs_plugin_loader_get_enabled (plugin_loader, "packagekit-local"))
-               return;
-
-       /* load local file */
-       fn = gs_test_get_filename (TESTDATADIR, "tests/chiron-1.1-1.fc24.x86_64.rpm");
-       g_assert (fn != NULL);
-       file = g_file_new_for_path (fn);
-       app = gs_plugin_loader_file_to_app (plugin_loader,
-                                           file,
-                                           GS_PLUGIN_REFINE_FLAGS_DEFAULT,
-                                           GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
-                                           NULL,
-                                           &error);
-       gs_test_flush_main_context ();
-       g_assert_no_error (error);
-       g_assert (app != NULL);
-       g_assert_cmpstr (gs_app_get_id (app), ==, "chiron.desktop");
-       g_assert_cmpstr (gs_app_get_source_default (app), ==, "chiron");
-       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_version (app), ==, "1.1-1.fc24");
-       g_assert_cmpstr (gs_app_get_summary (app), ==, "Single line synopsis");
-       g_assert_cmpstr (gs_app_get_description (app), ==,
-                        "This is the first paragraph in the example "
-                        "package spec file.\n\nThis is the second paragraph.");
-}
-
-static void
 gs_plugin_loader_repos_func (GsPluginLoader *plugin_loader)
 {
        gboolean ret;
@@ -2022,9 +1805,6 @@ main (int argc, char **argv)
        /* only critical and error are fatal */
        g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
 
-       /* generic tests go here */
-       g_test_add_func ("/gnome-software/markdown", gs_markdown_func);
-
        /* we can only load this once per process */
        plugin_loader = gs_plugin_loader_new ();
        g_signal_connect (plugin_loader, "status-changed",
@@ -2074,9 +1854,6 @@ main (int argc, char **argv)
        g_test_add_data_func ("/gnome-software/plugin-loader{key-colors}",
                              plugin_loader,
                              (GTestDataFunc) gs_plugin_loader_key_colors_func);
-       g_test_add_data_func ("/gnome-software/plugin-loader{packagekit-local}",
-                             plugin_loader,
-                             (GTestDataFunc) gs_plugin_loader_packagekit_local_func);
        g_test_add_data_func ("/gnome-software/plugin-loader{webapps}",
                              plugin_loader,
                              (GTestDataFunc) gs_plugin_loader_webapps_func);
diff --git a/plugins/packagekit/Makefile.am b/plugins/packagekit/Makefile.am
new file mode 100644
index 0000000..62d95d0
--- /dev/null
+++ b/plugins/packagekit/Makefile.am
@@ -0,0 +1,102 @@
+AM_CPPFLAGS =                                          \
+       -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE  \
+       -DTESTDATADIR=\""$(srcdir)"\"                   \
+       -DLOCALPLUGINDIR=\""$(builddir)/.libs"\"
+
+plugindir = $(GS_PLUGIN_DIR)
+plugin_LTLIBRARIES =                                   \
+       libgs_plugin_systemd-updates.la                 \
+       libgs_plugin_packagekit-local.la                \
+       libgs_plugin_packagekit-refine.la               \
+       libgs_plugin_packagekit-refresh.la              \
+       libgs_plugin_packagekit-offline.la              \
+       libgs_plugin_packagekit-origin.la               \
+       libgs_plugin_packagekit-proxy.la                \
+       libgs_plugin_packagekit-history.la              \
+       libgs_plugin_packagekit-upgrade.la              \
+       libgs_plugin_packagekit.la
+
+libgs_plugin_packagekit_la_SOURCES =                   \
+       gs-plugin-packagekit.c                          \
+       packagekit-common.c                             \
+       packagekit-common.h
+libgs_plugin_packagekit_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
+libgs_plugin_packagekit_la_LDFLAGS = -module -avoid-version
+libgs_plugin_packagekit_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
+
+libgs_plugin_packagekit_refine_la_SOURCES =            \
+       gs-plugin-packagekit-refine.c                   \
+       gs-markdown.c                                   \
+       gs-markdown.h                                   \
+       packagekit-common.c                             \
+       packagekit-common.h
+libgs_plugin_packagekit_refine_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
+libgs_plugin_packagekit_refine_la_LDFLAGS = -module -avoid-version
+libgs_plugin_packagekit_refine_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
+
+libgs_plugin_packagekit_refresh_la_SOURCES =           \
+       gs-plugin-packagekit-refresh.c                  \
+       packagekit-common.c                             \
+       packagekit-common.h
+libgs_plugin_packagekit_refresh_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
+libgs_plugin_packagekit_refresh_la_LDFLAGS = -module -avoid-version
+libgs_plugin_packagekit_refresh_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
+
+libgs_plugin_packagekit_local_la_SOURCES =             \
+       gs-plugin-packagekit-local.c                    \
+       packagekit-common.c                             \
+       packagekit-common.h
+libgs_plugin_packagekit_local_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
+libgs_plugin_packagekit_local_la_LDFLAGS = -module -avoid-version
+libgs_plugin_packagekit_local_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
+
+libgs_plugin_systemd_updates_la_SOURCES =              \
+       gs-plugin-systemd-updates.c                     \
+       packagekit-common.c                             \
+       packagekit-common.h
+libgs_plugin_systemd_updates_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
+libgs_plugin_systemd_updates_la_LDFLAGS = -module -avoid-version
+libgs_plugin_systemd_updates_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
+
+libgs_plugin_packagekit_history_la_SOURCES = gs-plugin-packagekit-history.c
+libgs_plugin_packagekit_history_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
+libgs_plugin_packagekit_history_la_LDFLAGS = -module -avoid-version
+libgs_plugin_packagekit_history_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
+
+libgs_plugin_packagekit_upgrade_la_SOURCES =           \
+       gs-plugin-packagekit-upgrade.c                  \
+       packagekit-common.c                             \
+       packagekit-common.h
+libgs_plugin_packagekit_upgrade_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
+libgs_plugin_packagekit_upgrade_la_LDFLAGS = -module -avoid-version
+libgs_plugin_packagekit_upgrade_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
+
+libgs_plugin_packagekit_offline_la_SOURCES = gs-plugin-packagekit-offline.c
+libgs_plugin_packagekit_offline_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
+libgs_plugin_packagekit_offline_la_LDFLAGS = -module -avoid-version
+libgs_plugin_packagekit_offline_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
+
+libgs_plugin_packagekit_origin_la_SOURCES =            \
+       gs-plugin-packagekit-origin.c                   \
+       packagekit-common.c                             \
+       packagekit-common.h
+libgs_plugin_packagekit_origin_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
+libgs_plugin_packagekit_origin_la_LDFLAGS = -module -avoid-version
+libgs_plugin_packagekit_origin_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
+
+libgs_plugin_packagekit_proxy_la_SOURCES = gs-plugin-packagekit-proxy.c
+libgs_plugin_packagekit_proxy_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
+libgs_plugin_packagekit_proxy_la_LDFLAGS = -module -avoid-version
+libgs_plugin_packagekit_proxy_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(PACKAGEKIT_CFLAGS)
+
+if ENABLE_TESTS
+check_PROGRAMS = gs-self-test
+gs_self_test_SOURCES = gs-self-test.c gs-markdown.c
+gs_self_test_LDADD = $(GS_PRIVATE_LIBS)
+gs_self_test_CFLAGS = $(GS_PRIVATE_CFLAGS)
+TESTS = gs-self-test
+endif
+
+EXTRA_DIST = tests/chiron-1.1-1.fc24.x86_64.rpm
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/gs-markdown.c b/plugins/packagekit/gs-markdown.c
similarity index 100%
rename from plugins/gs-markdown.c
rename to plugins/packagekit/gs-markdown.c
diff --git a/plugins/gs-markdown.h b/plugins/packagekit/gs-markdown.h
similarity index 100%
rename from plugins/gs-markdown.h
rename to plugins/packagekit/gs-markdown.h
diff --git a/plugins/gs-plugin-packagekit-history.c b/plugins/packagekit/gs-plugin-packagekit-history.c
similarity index 100%
rename from plugins/gs-plugin-packagekit-history.c
rename to plugins/packagekit/gs-plugin-packagekit-history.c
diff --git a/plugins/gs-plugin-packagekit-local.c b/plugins/packagekit/gs-plugin-packagekit-local.c
similarity index 100%
rename from plugins/gs-plugin-packagekit-local.c
rename to plugins/packagekit/gs-plugin-packagekit-local.c
diff --git a/plugins/gs-plugin-packagekit-offline.c b/plugins/packagekit/gs-plugin-packagekit-offline.c
similarity index 100%
rename from plugins/gs-plugin-packagekit-offline.c
rename to plugins/packagekit/gs-plugin-packagekit-offline.c
diff --git a/plugins/gs-plugin-packagekit-origin.c b/plugins/packagekit/gs-plugin-packagekit-origin.c
similarity index 100%
rename from plugins/gs-plugin-packagekit-origin.c
rename to plugins/packagekit/gs-plugin-packagekit-origin.c
diff --git a/plugins/gs-plugin-packagekit-proxy.c b/plugins/packagekit/gs-plugin-packagekit-proxy.c
similarity index 100%
rename from plugins/gs-plugin-packagekit-proxy.c
rename to plugins/packagekit/gs-plugin-packagekit-proxy.c
diff --git a/plugins/gs-plugin-packagekit-refine.c b/plugins/packagekit/gs-plugin-packagekit-refine.c
similarity index 100%
rename from plugins/gs-plugin-packagekit-refine.c
rename to plugins/packagekit/gs-plugin-packagekit-refine.c
diff --git a/plugins/gs-plugin-packagekit-refresh.c b/plugins/packagekit/gs-plugin-packagekit-refresh.c
similarity index 100%
rename from plugins/gs-plugin-packagekit-refresh.c
rename to plugins/packagekit/gs-plugin-packagekit-refresh.c
diff --git a/plugins/gs-plugin-packagekit-upgrade.c b/plugins/packagekit/gs-plugin-packagekit-upgrade.c
similarity index 100%
rename from plugins/gs-plugin-packagekit-upgrade.c
rename to plugins/packagekit/gs-plugin-packagekit-upgrade.c
diff --git a/plugins/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
similarity index 100%
rename from plugins/gs-plugin-packagekit.c
rename to plugins/packagekit/gs-plugin-packagekit.c
diff --git a/plugins/gs-plugin-systemd-updates.c b/plugins/packagekit/gs-plugin-systemd-updates.c
similarity index 100%
rename from plugins/gs-plugin-systemd-updates.c
rename to plugins/packagekit/gs-plugin-systemd-updates.c
diff --git a/plugins/packagekit/gs-self-test.c b/plugins/packagekit/gs-self-test.c
new file mode 100644
index 0000000..8fad75f
--- /dev/null
+++ b/plugins/packagekit/gs-self-test.c
@@ -0,0 +1,286 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2013-2017 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include "gnome-software-private.h"
+
+#include "gs-markdown.h"
+#include "gs-test.h"
+
+static void
+gs_markdown_func (void)
+{
+       gchar *text;
+       const gchar *markdown;
+       const gchar *markdown_expected;
+       g_autoptr(GsMarkdown) md = NULL;
+
+       /* get GsMarkdown object */
+       md = gs_markdown_new (GS_MARKDOWN_OUTPUT_PANGO);
+       g_assert (md);
+
+       markdown = "OEMs\n"
+                  "====\n"
+                  " - Bullett\n";
+       markdown_expected =
+                  "<big>OEMs</big>\n"
+                  "• Bullett";
+       /* markdown (type2 header) */
+       text = gs_markdown_parse (md, markdown);
+       g_assert_cmpstr (text, ==, markdown_expected);
+       g_free (text);
+
+       /* markdown (autocode) */
+       markdown = "this is http://www.hughsie.com/with_spaces_in_url inline link\n";
+       markdown_expected = "this is <tt>http://www.hughsie.com/with_spaces_in_url</tt> inline link";
+       gs_markdown_set_autocode (md, TRUE);
+       text = gs_markdown_parse (md, markdown);
+       g_assert_cmpstr (text, ==, markdown_expected);
+       g_free (text);
+
+       /* markdown some invalid header */
+       markdown = "*** This software is currently in alpha state ***\n";
+       markdown_expected = "<b><i> This software is currently in alpha state </b></i>";
+       text = gs_markdown_parse (md, markdown);
+       g_assert_cmpstr (text, ==, markdown_expected);
+       g_free (text);
+
+       /* markdown (complex1) */
+       markdown = " - This is a *very*\n"
+                  "   short paragraph\n"
+                  "   that is not usual.\n"
+                  " - Another";
+       markdown_expected =
+                  "• This is a <i>very</i> short paragraph that is not usual.\n"
+                  "• Another";
+       text = gs_markdown_parse (md, markdown);
+       g_assert_cmpstr (text, ==, markdown_expected);
+       g_free (text);
+
+       /* markdown (complex1) */
+       markdown = "*  This is a *very*\n"
+                  "   short paragraph\n"
+                  "   that is not usual.\n"
+                  "*  This is the second\n"
+                  "   bullett point.\n"
+                  "*  And the third.\n"
+                  " \n"
+                  "* * *\n"
+                  " \n"
+                  "Paragraph one\n"
+                  "isn't __very__ long at all.\n"
+                  "\n"
+                  "Paragraph two\n"
+                  "isn't much better.";
+       markdown_expected =
+                  "• This is a <i>very</i> short paragraph that is not usual.\n"
+                  "• This is the second bullett point.\n"
+                  "• And the third.\n"
+                  "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯\n"
+                  "Paragraph one isn&apos;t <b>very</b> long at all.\n"
+                  "Paragraph two isn&apos;t much better.";
+       text = gs_markdown_parse (md, markdown);
+       g_assert_cmpstr (text, ==, markdown_expected);
+       g_free (text);
+
+       markdown = "This is a spec file description or\n"
+                  "an **update** description in bohdi.\n"
+                  "\n"
+                  "* * *\n"
+                  "# Big title #\n"
+                  "\n"
+                  "The *following* things 'were' fixed:\n"
+                  "- Fix `dave`\n"
+                  "* Fubar update because of \"security\"\n";
+       markdown_expected =
+                  "This is a spec file description or an <b>update</b> description in bohdi.\n"
+                  "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯\n"
+                  "<big>Big title</big>\n"
+                  "The <i>following</i> things 'were' fixed:\n"
+                  "• Fix <tt>dave</tt>\n"
+                  "• Fubar update because of \"security\"";
+       /* markdown (complex2) */
+       text = gs_markdown_parse (md, markdown);
+       if (g_strcmp0 (text, markdown_expected) == 0)
+       g_assert_cmpstr (text, ==, markdown_expected);
+       g_free (text);
+
+       /* markdown (list with spaces) */
+       markdown = "* list seporated with spaces -\n"
+                  "  first item\n"
+                  "\n"
+                  "* second item\n"
+                  "\n"
+                  "* third item\n";
+       markdown_expected =
+                  "• list seporated with spaces - first item\n"
+                  "• second item\n"
+                  "• third item";
+       text = gs_markdown_parse (md, markdown);
+       g_assert_cmpstr (text, ==, markdown_expected);
+       g_free (text);
+
+       gs_markdown_set_max_lines (md, 1);
+
+       /* markdown (one line limit) */
+       markdown = "* list seporated with spaces -\n"
+                  "  first item\n"
+                  "* second item\n";
+       markdown_expected =
+                  "• list seporated with spaces - first item";
+       text = gs_markdown_parse (md, markdown);
+       g_assert_cmpstr (text, ==, markdown_expected);
+       g_free (text);
+
+       gs_markdown_set_max_lines (md, 1);
+
+       /* markdown (escaping) */
+       markdown = "* list & <spaces>";
+       markdown_expected =
+                  "• list &amp; &lt;spaces&gt;";
+       text = gs_markdown_parse (md, markdown);
+       g_assert_cmpstr (text, ==, markdown_expected);
+       g_free (text);
+
+       /* markdown (URLs) */
+       markdown = "this is the http://www.hughsie.com/ coolest site";
+       markdown_expected =
+                  "this is the "
+                  "<a href=\"http://www.hughsie.com/\";>http://www.hughsie.com/</a>"
+                  " coolest site";
+       text = gs_markdown_parse (md, markdown);
+       g_assert_cmpstr (text, ==, markdown_expected);
+       g_free (text);
+
+       /* markdown (free text) */
+       gs_markdown_set_escape (md, FALSE);
+       text = gs_markdown_parse (md, "This isn't a present");
+       g_assert_cmpstr (text, ==, "This isn't a present");
+       g_free (text);
+
+       /* markdown (autotext underscore) */
+       text = gs_markdown_parse (md, "This isn't CONFIG_UEVENT_HELPER_PATH present");
+       g_assert_cmpstr (text, ==, "This isn't <tt>CONFIG_UEVENT_HELPER_PATH</tt> present");
+       g_free (text);
+
+       /* markdown (end of bullett) */
+       markdown = "*Thu Mar 12 12:00:00 2009* Dan Walsh <dwalsh redhat com> - 2.0.79-1\n"
+                  "- Update to upstream \n"
+                  " * Netlink socket handoff patch from Adam Jackson.\n"
+                  " * AVC caching of compute_create results by Eric Paris.\n"
+                  "\n"
+                  "*Tue Mar 10 12:00:00 2009* Dan Walsh <dwalsh redhat com> - 2.0.78-5\n"
+                  "- Add patch from ajax to accellerate X SELinux \n"
+                  "- Update eparis patch\n";
+       markdown_expected =
+                  "<i>Thu Mar 12 12:00:00 2009</i> Dan Walsh <tt>&lt;dwalsh redhat com&gt;</tt> - 2.0.79-1\n"
+                  "• Update to upstream\n"
+                  "• Netlink socket handoff patch from Adam Jackson.\n"
+                  "• AVC caching of compute_create results by Eric Paris.\n"
+                  "<i>Tue Mar 10 12:00:00 2009</i> Dan Walsh <tt>&lt;dwalsh redhat com&gt;</tt> - 2.0.78-5\n"
+                  "• Add patch from ajax to accellerate X SELinux\n"
+                  "• Update eparis patch";
+       gs_markdown_set_escape (md, TRUE);
+       gs_markdown_set_max_lines (md, 1024);
+       text = gs_markdown_parse (md, markdown);
+       g_assert_cmpstr (text, ==, markdown_expected);
+       g_free (text);
+}
+
+static void
+gs_plugin_loader_packagekit_local_func (GsPluginLoader *plugin_loader)
+{
+       g_autoptr(GsApp) app = NULL;
+       g_autoptr(GError) error = NULL;
+       g_autofree gchar *fn = NULL;
+       g_autoptr(GFile) file = NULL;
+
+       /* no packagekit, abort */
+       if (!gs_plugin_loader_get_enabled (plugin_loader, "packagekit-local")) {
+               g_test_skip ("not enabled");
+               return;
+       }
+
+       /* load local file */
+       fn = gs_test_get_filename (TESTDATADIR, "tests/chiron-1.1-1.fc24.x86_64.rpm");
+       g_assert (fn != NULL);
+       file = g_file_new_for_path (fn);
+       app = gs_plugin_loader_file_to_app (plugin_loader,
+                                           file,
+                                           GS_PLUGIN_REFINE_FLAGS_DEFAULT,
+                                           GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
+                                           NULL,
+                                           &error);
+       gs_test_flush_main_context ();
+       g_assert_no_error (error);
+       g_assert (app != NULL);
+       g_assert_cmpstr (gs_app_get_source_default (app), ==, "chiron");
+       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_version (app), ==, "1.1-1.fc24");
+       g_assert_cmpstr (gs_app_get_summary (app), ==, "Single line synopsis");
+       g_assert_cmpstr (gs_app_get_description (app), ==,
+                        "This is the first paragraph in the example "
+                        "package spec file.\n\nThis is the second paragraph.");
+}
+
+int
+main (int argc, char **argv)
+{
+       gboolean ret;
+       g_autoptr(GError) error = NULL;
+       g_autoptr(GsPluginLoader) plugin_loader = NULL;
+       const gchar *whitelist[] = {
+               "packagekit-local",
+               NULL
+       };
+
+       g_test_init (&argc, &argv, NULL);
+       g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
+
+       /* only critical and error are fatal */
+       g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
+
+       /* generic tests go here */
+       g_test_add_func ("/gnome-software/markdown", gs_markdown_func);
+
+       /* we can only load this once per process */
+       plugin_loader = gs_plugin_loader_new ();
+       gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR);
+       ret = gs_plugin_loader_setup (plugin_loader,
+                                     (gchar**) whitelist,
+                                     NULL,
+                                     GS_PLUGIN_FAILURE_FLAGS_NONE,
+                                     NULL,
+                                     &error);
+       g_assert_no_error (error);
+       g_assert (ret);
+
+       /* plugin tests go here */
+       g_test_add_data_func ("/gnome-software/plugin-loader{packagekit-local}",
+                             plugin_loader,
+                             (GTestDataFunc) gs_plugin_loader_packagekit_local_func);
+
+       return g_test_run ();
+}
+
+/* vim: set noexpandtab: */
diff --git a/plugins/packagekit-common.c b/plugins/packagekit/packagekit-common.c
similarity index 100%
rename from plugins/packagekit-common.c
rename to plugins/packagekit/packagekit-common.c
diff --git a/plugins/packagekit-common.h b/plugins/packagekit/packagekit-common.h
similarity index 100%
rename from plugins/packagekit-common.h
rename to plugins/packagekit/packagekit-common.h
diff --git a/data/tests/build-rpm.sh b/plugins/packagekit/tests/build-rpm.sh
similarity index 100%
rename from data/tests/build-rpm.sh
rename to plugins/packagekit/tests/build-rpm.sh
diff --git a/data/tests/chiron.spec b/plugins/packagekit/tests/chiron.spec
similarity index 100%
rename from data/tests/chiron.spec
rename to plugins/packagekit/tests/chiron.spec


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]