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



commit 02020a11eb555dc093e9c46dc91c6b4e3506c89a
Author: Richard Hughes <richard hughsie com>
Date:   Tue Mar 7 12:38:41 2017 +0000

    trivial: Split out fwupd to a new directory

 configure.ac                                       |    1 +
 data/tests/Makefile.am                             |    1 -
 plugins/Makefile.am                                |   17 +---
 plugins/fwupd/Makefile.am                          |   33 ++++++
 plugins/{ => fwupd}/gs-plugin-fwupd.c              |    0
 plugins/fwupd/gs-self-test.c                       |  111 ++++++++++++++++++++
 ...org.gnome.Software.Plugin.Fwupd.metainfo.xml.in |    0
 {data => plugins/fwupd}/tests/build-cab.sh         |    0
 {data => plugins/fwupd}/tests/chiron-0.2.cab       |  Bin 34376 -> 34376 bytes
 {data => plugins/fwupd}/tests/firmware.dfu         |  Bin 32784 -> 32784 bytes
 {data => plugins/fwupd}/tests/firmware.dfu.asc     |    0
 .../fwupd}/tests/firmware.metainfo.xml             |    0
 plugins/gs-self-test.c                             |   49 ---------
 po/POTFILES.in                                     |    2 +-
 14 files changed, 150 insertions(+), 64 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c67b4c6..d2ba044 100644
--- a/configure.ac
+++ b/configure.ac
@@ -508,6 +508,7 @@ lib/gnome-software.pc
 plugins/Makefile
 plugins/dpkg/Makefile
 plugins/external-appstream/Makefile
+plugins/fwupd/Makefile
 plugins/limba/Makefile
 plugins/odrs/Makefile
 plugins/ostree/Makefile
diff --git a/data/tests/Makefile.am b/data/tests/Makefile.am
index aff2f03..00419b1 100644
--- a/data/tests/Makefile.am
+++ b/data/tests/Makefile.am
@@ -1,6 +1,5 @@
 EXTRA_DIST =                                           \
        os-release                                      \
-       chiron-0.2.cab                                  \
        chiron-1.1-1.fc24.x86_64.rpm                    \
        yum.repos.d/utopia.repo
 
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 969f0bc..99d76a7 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -35,6 +35,10 @@ if HAVE_SNAP
 SUBDIRS += snap
 endif
 
+if HAVE_FIRMWARE
+SUBDIRS += fwupd
+endif
+
 AM_CPPFLAGS =                                          \
        -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE  \
        -DDATADIR=\"$(datadir)\"                        \
@@ -42,7 +46,6 @@ AM_CPPFLAGS =                                         \
        -DLIBEXECDIR=\""$(libexecdir)"\"                \
        -DLOCALSTATEDIR=\""$(localstatedir)"\"          \
        -DLOCALEDIR=\""$(localedir)"\"                  \
-       -DSYSCONFDIR=\""$(sysconfdir)"\"                \
        -DTESTDATADIR=\""$(top_srcdir)/data"\"          \
        -DLOCALPLUGINDIR=\""$(top_builddir)/src/plugins/.libs"\"
 
@@ -93,10 +96,6 @@ if HAVE_SHELL_EXTENSIONS
 plugin_LTLIBRARIES += libgs_plugin_shell-extensions.la
 endif
 
-if HAVE_FIRMWARE
-plugin_LTLIBRARIES += libgs_plugin_fwupd.la
-endif
-
 if HAVE_FLATPAK
 plugin_LTLIBRARIES += libgs_plugin_flatpak.la
 endif
@@ -273,14 +272,6 @@ 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)
 
-if HAVE_FIRMWARE
-appdata_in_files += org.gnome.Software.Plugin.Fwupd.metainfo.xml.in
-libgs_plugin_fwupd_la_SOURCES = gs-plugin-fwupd.c
-libgs_plugin_fwupd_la_LIBADD = $(GS_PLUGIN_LIBS) $(FWUPD_LIBS)
-libgs_plugin_fwupd_la_LDFLAGS = -module -avoid-version
-libgs_plugin_fwupd_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(FWUPD_CFLAGS)
-endif
-
 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
diff --git a/plugins/fwupd/Makefile.am b/plugins/fwupd/Makefile.am
new file mode 100644
index 0000000..744dd03
--- /dev/null
+++ b/plugins/fwupd/Makefile.am
@@ -0,0 +1,33 @@
+AM_CPPFLAGS =                                          \
+       -DSYSCONFDIR=\""$(sysconfdir)"\"                \
+       -DTESTDATADIR=\""$(srcdir)"\"                   \
+       -DLOCALPLUGINDIR=\""$(builddir)/.libs"\"
+
+plugindir = $(GS_PLUGIN_DIR)
+plugin_LTLIBRARIES = libgs_plugin_fwupd.la
+
+libgs_plugin_fwupd_la_SOURCES = gs-plugin-fwupd.c
+libgs_plugin_fwupd_la_LIBADD = $(GS_PLUGIN_LIBS) $(FWUPD_LIBS)
+libgs_plugin_fwupd_la_LDFLAGS = -module -avoid-version
+libgs_plugin_fwupd_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(FWUPD_CFLAGS)
+
+%.metainfo.xml: %.metainfo.xml.in
+       $(AM_V_GEN) msgfmt --xml -d $(top_srcdir)/po --template $< -o $@
+
+appdata_in_files = org.gnome.Software.Plugin.Fwupd.metainfo.xml.in
+appdatadir = $(datadir)/appdata
+appdata_DATA = $(appdata_in_files:.xml.in=.xml)
+EXTRA_DIST = $(appdata_in_files)
+CLEANFILES = $(appdata_DATA)
+
+if ENABLE_TESTS
+check_PROGRAMS = gs-self-test
+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
+endif
+
+EXTRA_DIST += tests/chiron-0.2.cab
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/gs-plugin-fwupd.c b/plugins/fwupd/gs-plugin-fwupd.c
similarity index 100%
rename from plugins/gs-plugin-fwupd.c
rename to plugins/fwupd/gs-plugin-fwupd.c
diff --git a/plugins/fwupd/gs-self-test.c b/plugins/fwupd/gs-self-test.c
new file mode 100644
index 0000000..2e1b231
--- /dev/null
+++ b/plugins/fwupd/gs-self-test.c
@@ -0,0 +1,111 @@
+/* -*- 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-test.h"
+
+static void
+gs_plugin_loader_fwupd_func (GsPluginLoader *plugin_loader)
+{
+       g_autofree gchar *fn = NULL;
+       g_autoptr(GError) error = NULL;
+       g_autoptr(GFile) file = NULL;
+       g_autoptr(GsApp) app = NULL;
+
+       /* no fwupd, abort */
+       if (!gs_plugin_loader_get_enabled (plugin_loader, "fwupd")) {
+               g_test_skip ("not enabled");
+               return;
+       }
+
+       /* load local file */
+       fn = gs_test_get_filename (TESTDATADIR, "tests/chiron-0.2.cab");
+       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_cmpint (gs_app_get_kind (app), ==, AS_APP_KIND_FIRMWARE);
+       g_assert (gs_app_get_license (app) != NULL);
+       g_assert (gs_app_has_category (app, "System"));
+       g_assert_cmpstr (gs_app_get_id (app), ==, "com.test.chiron.firmware");
+       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");
+       g_assert_cmpstr (gs_app_get_version (app), ==, "0.2");
+       g_assert_cmpint ((gint64) gs_app_get_size_download (app), ==, 32784);
+       g_assert_cmpstr (gs_app_get_description (app), ==,
+                        "This is the first paragraph in the example "
+                        "cab file.\n\nThis is the second paragraph.");
+       g_assert_cmpstr (gs_app_get_update_details (app), ==,
+                        "Latest firmware release.");
+
+       /* seems wrong, but this is only set if the update is available */
+       g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_UNKNOWN);
+}
+
+int
+main (int argc, char **argv)
+{
+       gboolean ret;
+       g_autoptr(GError) error = NULL;
+       g_autoptr(GsPluginLoader) plugin_loader = NULL;
+       const gchar *whitelist[] = {
+               "fwupd",
+               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);
+
+       /* 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{fwupd}",
+                             plugin_loader,
+                             (GTestDataFunc) gs_plugin_loader_fwupd_func);
+
+       return g_test_run ();
+}
+
+/* vim: set noexpandtab: */
diff --git a/plugins/org.gnome.Software.Plugin.Fwupd.metainfo.xml.in 
b/plugins/fwupd/org.gnome.Software.Plugin.Fwupd.metainfo.xml.in
similarity index 100%
rename from plugins/org.gnome.Software.Plugin.Fwupd.metainfo.xml.in
rename to plugins/fwupd/org.gnome.Software.Plugin.Fwupd.metainfo.xml.in
diff --git a/data/tests/build-cab.sh b/plugins/fwupd/tests/build-cab.sh
similarity index 100%
rename from data/tests/build-cab.sh
rename to plugins/fwupd/tests/build-cab.sh
diff --git a/data/tests/firmware.dfu.asc b/plugins/fwupd/tests/firmware.dfu.asc
similarity index 100%
rename from data/tests/firmware.dfu.asc
rename to plugins/fwupd/tests/firmware.dfu.asc
diff --git a/data/tests/firmware.metainfo.xml b/plugins/fwupd/tests/firmware.metainfo.xml
similarity index 100%
rename from data/tests/firmware.metainfo.xml
rename to plugins/fwupd/tests/firmware.metainfo.xml
diff --git a/plugins/gs-self-test.c b/plugins/gs-self-test.c
index 7b9e75b..a071063 100644
--- a/plugins/gs-self-test.c
+++ b/plugins/gs-self-test.c
@@ -663,51 +663,6 @@ gs_plugin_loader_packagekit_local_func (GsPluginLoader *plugin_loader)
 }
 
 static void
-gs_plugin_loader_fwupd_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 fwupd, abort */
-       if (!gs_plugin_loader_get_enabled (plugin_loader, "fwupd"))
-               return;
-
-       /* load local file */
-       fn = gs_test_get_filename (TESTDATADIR, "tests/chiron-0.2.cab");
-       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_cmpint (gs_app_get_kind (app), ==, AS_APP_KIND_FIRMWARE);
-       g_assert (gs_app_get_pixbuf (app) != NULL);
-       g_assert (gs_app_get_license (app) != NULL);
-       g_assert (gs_app_has_category (app, "System"));
-       g_assert_cmpstr (gs_app_get_id (app), ==, "com.test.chiron.firmware");
-       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");
-       g_assert_cmpstr (gs_app_get_version (app), ==, "0.2");
-       g_assert_cmpint ((gint64) gs_app_get_size_download (app), ==, 32784);
-       g_assert_cmpstr (gs_app_get_description (app), ==,
-                        "This is the first paragraph in the example "
-                        "cab file.\n\nThis is the second paragraph.");
-       g_assert_cmpstr (gs_app_get_update_details (app), ==,
-                        "Latest firmware release.");
-
-       /* seems wrong, but this is only set if the update is available */
-       g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_UNKNOWN);
-}
-
-static void
 gs_plugin_loader_repos_func (GsPluginLoader *plugin_loader)
 {
        gboolean ret;
@@ -1961,7 +1916,6 @@ main (int argc, char **argv)
                "dummy",
                "epiphany",
                "flatpak",
-               "fwupd",
                "generic-updates",
                "hardcoded-blacklist",
                "desktop-categories",
@@ -2117,9 +2071,6 @@ main (int argc, char **argv)
        g_test_add_data_func ("/gnome-software/plugin-loader{flatpak-app-update-runtime}",
                              plugin_loader,
                              (GTestDataFunc) gs_plugin_loader_flatpak_app_update_func);
-       g_test_add_data_func ("/gnome-software/plugin-loader{fwupd}",
-                             plugin_loader,
-                             (GTestDataFunc) gs_plugin_loader_fwupd_func);
        g_test_add_data_func ("/gnome-software/plugin-loader{key-colors}",
                              plugin_loader,
                              (GTestDataFunc) gs_plugin_loader_key_colors_func);
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b7b5711..f4ef7f7 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -71,7 +71,7 @@ plugins/gs-plugin-fedora-distro-upgrades.c
 plugins/gs-plugin-generic-updates.c
 plugins/org.gnome.Software.Plugin.Epiphany.metainfo.xml.in
 plugins/org.gnome.Software.Plugin.Flatpak.metainfo.xml.in
-plugins/org.gnome.Software.Plugin.Fwupd.metainfo.xml.in
+plugins/fwupd/org.gnome.Software.Plugin.Fwupd.metainfo.xml.in
 plugins/limba/org.gnome.Software.Plugin.Limba.metainfo.xml.in
 plugins/odrs/org.gnome.Software.Plugin.Odrs.metainfo.xml.in
 plugins/snap/org.gnome.Software.Plugin.Snap.metainfo.xml.in


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