[gnome-software] trivial: Split out dpkg to a new directory
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Split out dpkg to a new directory
- Date: Tue, 7 Mar 2017 17:05:05 +0000 (UTC)
commit e6e647ba65eb3b0ebb748d390c0f4a5ca2d278d9
Author: Richard Hughes <richard hughsie com>
Date: Tue Mar 7 12:19:28 2017 +0000
trivial: Split out dpkg to a new directory
configure.ac | 1 +
data/tests/Makefile.am | 1 -
plugins/Makefile.am | 10 +-
plugins/dpkg/Makefile.am | 23 +++++
plugins/{ => dpkg}/gs-plugin-dpkg.c | 0
plugins/dpkg/gs-self-test.c | 103 ++++++++++++++++++++
{data => plugins/dpkg}/tests/build-deb.sh | 0
{data => plugins/dpkg}/tests/chiron-1.1-1.deb | Bin 806 -> 806 bytes
{data => plugins/dpkg}/tests/debian/DEBIAN/control | 0
{data => plugins/dpkg}/tests/debian/usr/bin/chiron | 0
plugins/gs-self-test.c | 45 +--------
11 files changed, 133 insertions(+), 50 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3c560fb..c67b4c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -506,6 +506,7 @@ doc/api/Makefile
lib/Makefile
lib/gnome-software.pc
plugins/Makefile
+plugins/dpkg/Makefile
plugins/external-appstream/Makefile
plugins/limba/Makefile
plugins/odrs/Makefile
diff --git a/data/tests/Makefile.am b/data/tests/Makefile.am
index 29feb92..aff2f03 100644
--- a/data/tests/Makefile.am
+++ b/data/tests/Makefile.am
@@ -1,7 +1,6 @@
EXTRA_DIST = \
os-release \
chiron-0.2.cab \
- chiron-1.1-1.deb \
chiron-1.1-1.fc24.x86_64.rpm \
yum.repos.d/utopia.repo
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index bb1f8e2..969f0bc 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,8 +1,12 @@
## We require new-style dependency handling.
AUTOMAKE_OPTIONS = 1.7
+# core
SUBDIRS =
+# non-core, but no configure option required
+SUBDIRS += dpkg
+
if HAVE_LIMBA
SUBDIRS += limba
endif
@@ -49,7 +53,6 @@ plugin_LTLIBRARIES = \
libgs_plugin_desktop-categories.la \
libgs_plugin_desktop-menu-path.la \
libgs_plugin_dummy.la \
- libgs_plugin_dpkg.la \
libgs_plugin_generic-updates.la \
libgs_plugin_hardcoded-blacklist.la \
libgs_plugin_hardcoded-popular.la \
@@ -107,11 +110,6 @@ libgs_plugin_dummy_la_LIBADD = $(GS_PLUGIN_LIBS)
libgs_plugin_dummy_la_LDFLAGS = -module -avoid-version
libgs_plugin_dummy_la_CFLAGS = $(GS_PLUGIN_CFLAGS)
-libgs_plugin_dpkg_la_SOURCES = gs-plugin-dpkg.c
-libgs_plugin_dpkg_la_LIBADD = $(GS_PLUGIN_LIBS)
-libgs_plugin_dpkg_la_LDFLAGS = -module -avoid-version
-libgs_plugin_dpkg_la_CFLAGS = $(GS_PLUGIN_CFLAGS)
-
libgs_plugin_generic_updates_la_SOURCES = gs-plugin-generic-updates.c
libgs_plugin_generic_updates_la_LIBADD = $(GS_PLUGIN_LIBS)
libgs_plugin_generic_updates_la_LDFLAGS = -module -avoid-version
diff --git a/plugins/dpkg/Makefile.am b/plugins/dpkg/Makefile.am
new file mode 100644
index 0000000..515b632
--- /dev/null
+++ b/plugins/dpkg/Makefile.am
@@ -0,0 +1,23 @@
+AM_CPPFLAGS = \
+ -DTESTDATADIR=\""$(srcdir)"\" \
+ -DLOCALPLUGINDIR=\""$(builddir)/.libs"\"
+
+plugindir = $(GS_PLUGIN_DIR)
+plugin_LTLIBRARIES = libgs_plugin_dpkg.la
+
+libgs_plugin_dpkg_la_SOURCES = gs-plugin-dpkg.c
+libgs_plugin_dpkg_la_LIBADD = $(GS_PLUGIN_LIBS)
+libgs_plugin_dpkg_la_LDFLAGS = -module -avoid-version
+libgs_plugin_dpkg_la_CFLAGS = $(GS_PLUGIN_CFLAGS)
+
+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-1.1-1.deb
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/gs-plugin-dpkg.c b/plugins/dpkg/gs-plugin-dpkg.c
similarity index 100%
rename from plugins/gs-plugin-dpkg.c
rename to plugins/dpkg/gs-plugin-dpkg.c
diff --git a/plugins/dpkg/gs-self-test.c b/plugins/dpkg/gs-self-test.c
new file mode 100644
index 0000000..35bbcfe
--- /dev/null
+++ b/plugins/dpkg/gs-self-test.c
@@ -0,0 +1,103 @@
+/* -*- 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_dpkg_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 dpkg, abort */
+ if (!gs_plugin_loader_get_enabled (plugin_loader, "dpkg")) {
+ g_test_skip ("not enabled");
+ return;
+ }
+
+ /* load local file */
+ fn = gs_test_get_filename (TESTDATADIR, "tests/chiron-1.1-1.deb");
+ 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");
+ 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 control file.\nThis is the second paragraph.");
+ g_assert (gs_app_get_local_file (app) != NULL);
+}
+
+int
+main (int argc, char **argv)
+{
+ gboolean ret;
+ g_autoptr(GError) error = NULL;
+ g_autoptr(GsPluginLoader) plugin_loader = NULL;
+ const gchar *whitelist[] = {
+ "dpkg",
+ 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{dpkg}",
+ plugin_loader,
+ (GTestDataFunc) gs_plugin_loader_dpkg_func);
+
+ return g_test_run ();
+}
+
+/* vim: set noexpandtab: */
diff --git a/data/tests/build-deb.sh b/plugins/dpkg/tests/build-deb.sh
similarity index 100%
rename from data/tests/build-deb.sh
rename to plugins/dpkg/tests/build-deb.sh
diff --git a/data/tests/debian/DEBIAN/control b/plugins/dpkg/tests/debian/DEBIAN/control
similarity index 100%
rename from data/tests/debian/DEBIAN/control
rename to plugins/dpkg/tests/debian/DEBIAN/control
diff --git a/data/tests/debian/usr/bin/chiron b/plugins/dpkg/tests/debian/usr/bin/chiron
similarity index 100%
rename from data/tests/debian/usr/bin/chiron
rename to plugins/dpkg/tests/debian/usr/bin/chiron
diff --git a/plugins/gs-self-test.c b/plugins/gs-self-test.c
index c2048e1..7b9e75b 100644
--- a/plugins/gs-self-test.c
+++ b/plugins/gs-self-test.c
@@ -627,43 +627,6 @@ gs_plugin_loader_webapps_func (GsPluginLoader *plugin_loader)
}
static void
-gs_plugin_loader_dpkg_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 dpkg, abort */
- if (!gs_plugin_loader_get_enabled (plugin_loader, "dpkg"))
- return;
-
- /* load local file */
- fn = gs_test_get_filename (TESTDATADIR, "tests/chiron-1.1-1.deb");
- 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");
- 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 control file.\nThis is the second paragraph.");
- g_assert (gs_app_get_local_file (app) != NULL);
-}
-
-static void
gs_plugin_loader_packagekit_local_func (GsPluginLoader *plugin_loader)
{
g_autoptr(GsApp) app = NULL;
@@ -671,7 +634,7 @@ gs_plugin_loader_packagekit_local_func (GsPluginLoader *plugin_loader)
g_autofree gchar *fn = NULL;
g_autoptr(GFile) file = NULL;
- /* no dpkg, abort */
+ /* no packagekit, abort */
if (!gs_plugin_loader_get_enabled (plugin_loader, "packagekit-local"))
return;
@@ -707,7 +670,7 @@ gs_plugin_loader_fwupd_func (GsPluginLoader *plugin_loader)
g_autofree gchar *fn = NULL;
g_autoptr(GFile) file = NULL;
- /* no dpkg, abort */
+ /* no fwupd, abort */
if (!gs_plugin_loader_get_enabled (plugin_loader, "fwupd"))
return;
@@ -1995,7 +1958,6 @@ main (int argc, char **argv)
g_autoptr(GsPluginLoader) plugin_loader = NULL;
const gchar *whitelist[] = {
"appstream",
- "dpkg",
"dummy",
"epiphany",
"flatpak",
@@ -2164,9 +2126,6 @@ main (int argc, char **argv)
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{dpkg}",
- plugin_loader,
- (GTestDataFunc) gs_plugin_loader_dpkg_func);
g_test_add_data_func ("/gnome-software/plugin-loader{webapps}",
plugin_loader,
(GTestDataFunc) gs_plugin_loader_webapps_func);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]