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



commit eabeec624bf3c80ef7cf0e906fa6d71443cc5203
Author: Richard Hughes <richard hughsie com>
Date:   Tue Mar 7 13:13:29 2017 +0000

    trivial: Split out repos to a new directory

 configure.ac                                       |    1 +
 data/tests/Makefile.am                             |    3 +-
 plugins/Makefile.am                                |    7 +--
 plugins/gs-self-test.c                             |   30 -------
 plugins/repos/Makefile.am                          |   23 +++++
 plugins/{ => repos}/gs-plugin-repos.c              |    0
 plugins/repos/gs-self-test.c                       |   92 ++++++++++++++++++++
 .../repos}/tests/yum.repos.d/utopia.repo           |    0
 8 files changed, 118 insertions(+), 38 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 974c387..832564b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -491,6 +491,7 @@ plugins/limba/Makefile
 plugins/odrs/Makefile
 plugins/ostree/Makefile
 plugins/packagekit/Makefile
+plugins/repos/Makefile
 plugins/snap/Makefile
 plugins/steam/Makefile
 plugins/ubuntuone/Makefile
diff --git a/data/tests/Makefile.am b/data/tests/Makefile.am
index 4863d1b..8dd9630 100644
--- a/data/tests/Makefile.am
+++ b/data/tests/Makefile.am
@@ -1,5 +1,4 @@
 EXTRA_DIST =                                           \
-       os-release                                      \
-       yum.repos.d/utopia.repo
+       os-release
 
 -include $(top_srcdir)/git.mk
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index fe9fca6..ea9f640 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -7,6 +7,7 @@ SUBDIRS =
 # non-core, but no configure option required
 SUBDIRS += dpkg
 SUBDIRS += ubuntuone
+SUBDIRS += repos
 
 if HAVE_LIMBA
 SUBDIRS += limba
@@ -67,7 +68,6 @@ plugin_LTLIBRARIES =                                  \
        libgs_plugin_fedora-distro-upgrades.la          \
        libgs_plugin_provenance.la                      \
        libgs_plugin_provenance-license.la              \
-       libgs_plugin_repos.la                           \
        libgs_plugin_fedora-tagger-usage.la             \
        libgs_plugin_icons.la
 
@@ -172,11 +172,6 @@ libgs_plugin_flatpak_la_LDFLAGS = -module -avoid-version
 libgs_plugin_flatpak_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(FLATPAK_CFLAGS)
 endif
 
-libgs_plugin_repos_la_SOURCES = gs-plugin-repos.c
-libgs_plugin_repos_la_LIBADD = $(GS_PLUGIN_LIBS) $(RPM_LIBS)
-libgs_plugin_repos_la_LDFLAGS = -module -avoid-version
-libgs_plugin_repos_la_CFLAGS = $(GS_PLUGIN_CFLAGS)
-
 libgs_plugin_desktop_categories_la_SOURCES =           \
        gs-plugin-desktop-categories.c                  \
        gs-desktop-common.c                             \
diff --git a/plugins/gs-self-test.c b/plugins/gs-self-test.c
index 1da7d8e..e4ade25 100644
--- a/plugins/gs-self-test.c
+++ b/plugins/gs-self-test.c
@@ -446,27 +446,6 @@ gs_plugin_loader_webapps_func (GsPluginLoader *plugin_loader)
 }
 
 static void
-gs_plugin_loader_repos_func (GsPluginLoader *plugin_loader)
-{
-       gboolean ret;
-       g_autoptr(GsApp) app = NULL;
-       g_autoptr(GError) error = NULL;
-
-       /* get the extra bits */
-       app = gs_app_new ("testrepos.desktop");
-       gs_app_set_origin (app, "utopia");
-       ret = gs_plugin_loader_app_refine (plugin_loader, app,
-                                          GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_HOSTNAME,
-                                          GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
-                                          NULL,
-                                          &error);
-       gs_test_flush_main_context ();
-       g_assert_no_error (error);
-       g_assert (ret);
-       g_assert_cmpstr (gs_app_get_origin_hostname (app), ==, "people.freedesktop.org");
-}
-
-static void
 gs_plugin_loader_flatpak_repo_func (GsPluginLoader *plugin_loader)
 {
        const gchar *group_name = "remote \"example\"";
@@ -1691,7 +1670,6 @@ main (int argc, char **argv)
        gboolean ret;
        g_autofree gchar *fn = NULL;
        g_autofree gchar *xml = NULL;
-       g_autofree gchar *reposdir = NULL;
        g_autoptr(GError) error = NULL;
        g_autoptr(GsPluginLoader) plugin_loader = NULL;
        const gchar *whitelist[] = {
@@ -1732,11 +1710,6 @@ main (int argc, char **argv)
                g_assert (!g_file_test (tmp_root, G_FILE_TEST_EXISTS));
        }
 
-       /* dummy data */
-       reposdir = gs_test_get_filename (TESTDATADIR, "tests/yum.repos.d");
-       g_assert (reposdir != NULL);
-       g_setenv ("GS_SELF_TEST_REPOS_DIR", reposdir, TRUE);
-
        fn = gs_test_get_filename (TESTDATADIR, "icons/hicolor/48x48/org.gnome.Software.png");
        g_assert (fn != NULL);
        xml = g_strdup_printf ("<?xml version=\"1.0\"?>\n"
@@ -1833,9 +1806,6 @@ main (int argc, char **argv)
        g_test_add_data_func ("/gnome-software/plugin-loader{plugin-cache}",
                              plugin_loader,
                              (GTestDataFunc) gs_plugin_loader_plugin_cache_func);
-       g_test_add_data_func ("/gnome-software/plugin-loader{repos}",
-                             plugin_loader,
-                             (GTestDataFunc) gs_plugin_loader_repos_func);
        g_test_add_data_func ("/gnome-software/plugin-loader{flatpak-app-with-runtime}",
                              plugin_loader,
                              (GTestDataFunc) gs_plugin_loader_flatpak_app_with_runtime_func);
diff --git a/plugins/repos/Makefile.am b/plugins/repos/Makefile.am
new file mode 100644
index 0000000..0ecfaeb
--- /dev/null
+++ b/plugins/repos/Makefile.am
@@ -0,0 +1,23 @@
+AM_CPPFLAGS =                                          \
+       -DTESTDATADIR=\""$(srcdir)"\"                   \
+       -DLOCALPLUGINDIR=\""$(builddir)/.libs"\"
+
+plugindir = $(GS_PLUGIN_DIR)
+plugin_LTLIBRARIES = libgs_plugin_repos.la
+
+libgs_plugin_repos_la_SOURCES = gs-plugin-repos.c
+libgs_plugin_repos_la_LIBADD = $(GS_PLUGIN_LIBS)
+libgs_plugin_repos_la_LDFLAGS = -module -avoid-version
+libgs_plugin_repos_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/yum.repos.d/utopia.repo
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/gs-plugin-repos.c b/plugins/repos/gs-plugin-repos.c
similarity index 100%
rename from plugins/gs-plugin-repos.c
rename to plugins/repos/gs-plugin-repos.c
diff --git a/plugins/repos/gs-self-test.c b/plugins/repos/gs-self-test.c
new file mode 100644
index 0000000..8b855fa
--- /dev/null
+++ b/plugins/repos/gs-self-test.c
@@ -0,0 +1,92 @@
+/* -*- 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_repos_func (GsPluginLoader *plugin_loader)
+{
+       gboolean ret;
+       g_autoptr(GsApp) app = NULL;
+       g_autoptr(GError) error = NULL;
+
+       /* get the extra bits */
+       app = gs_app_new ("testrepos.desktop");
+       gs_app_set_origin (app, "utopia");
+       ret = gs_plugin_loader_app_refine (plugin_loader, app,
+                                          GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_HOSTNAME,
+                                          GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
+                                          NULL,
+                                          &error);
+       gs_test_flush_main_context ();
+       g_assert_no_error (error);
+       g_assert (ret);
+       g_assert_cmpstr (gs_app_get_origin_hostname (app), ==, "people.freedesktop.org");
+}
+
+int
+main (int argc, char **argv)
+{
+       gboolean ret;
+       g_autofree gchar *reposdir = NULL;
+       g_autoptr(GError) error = NULL;
+       g_autoptr(GsPluginLoader) plugin_loader = NULL;
+       const gchar *whitelist[] = {
+               "repos",
+               NULL
+       };
+
+       g_test_init (&argc, &argv, NULL);
+       g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
+
+       /* dummy data */
+       reposdir = gs_test_get_filename (TESTDATADIR, "tests/yum.repos.d");
+       g_assert (reposdir != NULL);
+       g_setenv ("GS_SELF_TEST_REPOS_DIR", reposdir, 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{repos}",
+                             plugin_loader,
+                             (GTestDataFunc) gs_plugin_loader_repos_func);
+
+       return g_test_run ();
+}
+
+/* vim: set noexpandtab: */
diff --git a/data/tests/yum.repos.d/utopia.repo b/plugins/repos/tests/yum.repos.d/utopia.repo
similarity index 100%
rename from data/tests/yum.repos.d/utopia.repo
rename to plugins/repos/tests/yum.repos.d/utopia.repo


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