aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories/virtuals
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-11 22:35:14 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-11 22:35:32 +0100
commitc8c5434b8587ac54c1da2d3510962fe5005db845 (patch)
tree29b174adbebc95a9b527d2aebf2cba963a5acc7f /paludis/repositories/virtuals
parente27dabb7c338116b1f496d09d51c6869e298e043 (diff)
downloadpaludis-c8c5434b8587ac54c1da2d3510962fe5005db845.tar.gz
paludis-c8c5434b8587ac54c1da2d3510962fe5005db845.tar.xz
Remove VirtualsInterface
Diffstat (limited to 'paludis/repositories/virtuals')
-rw-r--r--paludis/repositories/virtuals/Makefile.am28
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc4
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository_TEST.cc33
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc73
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.hh7
-rw-r--r--paludis/repositories/virtuals/virtuals_repository_TEST.cc165
6 files changed, 4 insertions, 306 deletions
diff --git a/paludis/repositories/virtuals/Makefile.am b/paludis/repositories/virtuals/Makefile.am
index af68f0fd1..bd575b845 100644
--- a/paludis/repositories/virtuals/Makefile.am
+++ b/paludis/repositories/virtuals/Makefile.am
@@ -23,34 +23,10 @@ libpaludisvirtualsrepository_la_SOURCES = \
registration.cc \
$(noinst_HEADERS)
-TESTS = virtuals_repository_TEST installed_virtuals_repository_TEST
+TESTS =
check_PROGRAMS = $(TESTS)
check_SCRIPTS =
-EXTRA_DIST = $(virtuals_repository_TEST_SOURCES) $(installed_virtuals_repository_TEST_SOURCES)
-
-virtuals_repository_TEST_LDADD = \
- $(top_builddir)/paludis/util/gtest_runner.o \
- $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
- $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la
-
-virtuals_repository_TEST_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ @GTESTDEPS_CXXFLAGS@
-
-virtuals_repository_TEST_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
-
-installed_virtuals_repository_TEST_LDADD = \
- $(top_builddir)/paludis/util/gtest_runner.o \
- $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
- $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la
-
-installed_virtuals_repository_TEST_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ @GTESTDEPS_CXXFLAGS@
-
-installed_virtuals_repository_TEST_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
-
-virtuals_repository_TEST_SOURCES = \
- virtuals_repository_TEST.cc
-
-installed_virtuals_repository_TEST_SOURCES = \
- installed_virtuals_repository_TEST.cc
+EXTRA_DIST =
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 1a4140724..0ed495f07 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -112,9 +112,7 @@ InstalledVirtualsRepository::InstalledVirtualsRepository(const Environment * con
Repository(env, RepositoryName(make_name(r)), make_named_values<RepositoryCapabilities>(
n::destination_interface() = static_cast<RepositoryDestinationInterface *>(this),
n::environment_variable_interface() = static_cast<RepositoryEnvironmentVariableInterface *>(0),
- n::make_virtuals_interface() = static_cast<RepositoryMakeVirtualsInterface *>(0),
- n::manifest_interface() = static_cast<RepositoryManifestInterface *>(0),
- n::virtuals_interface() = static_cast<RepositoryVirtualsInterface *>(0)
+ n::manifest_interface() = static_cast<RepositoryManifestInterface *>(0)
)),
_imp(env, r)
{
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository_TEST.cc b/paludis/repositories/virtuals/installed_virtuals_repository_TEST.cc
deleted file mode 100644
index aac3eac37..000000000
--- a/paludis/repositories/virtuals/installed_virtuals_repository_TEST.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007, 2008, 2010, 2011 Ciaran McCreesh
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis 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., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/repositories/virtuals/installed_virtuals_repository.hh>
-
-#include <paludis/environments/test/test_environment.hh>
-
-#include <gtest/gtest.h>
-
-using namespace paludis;
-
-TEST(InstalledVirtualsRepository, Workss)
-{
- TestEnvironment env;
- std::shared_ptr<const InstalledVirtualsRepository> r(std::make_shared<InstalledVirtualsRepository>(&env, FSPath("/")));
-}
-
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index d3233e76e..69155cb7a 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -123,9 +123,7 @@ VirtualsRepository::VirtualsRepository(const Environment * const env) :
Repository(env, RepositoryName("virtuals"), make_named_values<RepositoryCapabilities>(
n::destination_interface() = static_cast<RepositoryDestinationInterface *>(0),
n::environment_variable_interface() = static_cast<RepositoryEnvironmentVariableInterface *>(0),
- n::make_virtuals_interface() = this,
- n::manifest_interface() = static_cast<RepositoryManifestInterface *>(0),
- n::virtuals_interface() = static_cast<RepositoryVirtualsInterface *>(0)
+ n::manifest_interface() = static_cast<RepositoryManifestInterface *>(0)
)),
_imp(env)
{
@@ -153,28 +151,6 @@ VirtualsRepository::need_names() const
std::vector<std::pair<QualifiedPackageName, std::shared_ptr<const PackageDepSpec> > > new_names;
- for (auto r(_imp->env->begin_repositories()), r_end(_imp->env->end_repositories()) ; r != r_end ; ++r)
- {
- if (! (**r).virtuals_interface())
- continue;
-
- std::shared_ptr<const RepositoryVirtualsInterface::VirtualsSequence> virtuals(
- (**r).virtuals_interface()->virtual_packages());
- for (RepositoryVirtualsInterface::VirtualsSequence::ConstIterator v(virtuals->begin()),
- v_end(virtuals->end()) ; v != v_end ; ++v)
- {
- std::pair<
- std::vector<std::pair<QualifiedPackageName, std::shared_ptr<const PackageDepSpec> > >::const_iterator,
- std::vector<std::pair<QualifiedPackageName, std::shared_ptr<const PackageDepSpec> > >::const_iterator> p(
- std::equal_range(_imp->names.begin(), _imp->names.end(),
- std::make_pair((*v).virtual_name(), std::shared_ptr<const PackageDepSpec>()),
- NamesNameComparator()));
-
- if (p.first == p.second)
- new_names.push_back(std::make_pair((*v).virtual_name(), (*v).provided_by_spec()));
- }
- }
-
std::copy(new_names.begin(), new_names.end(), std::back_inserter(_imp->names));
std::sort(_imp->names.begin(), _imp->names.end(), NamesSortComparator());
_imp->names.erase(std::unique(_imp->names.begin(), _imp->names.end(), NamesUniqueComparator()), _imp->names.end());
@@ -191,42 +167,6 @@ VirtualsRepository::need_ids() const
return;
_imp->has_ids = true;
-
- Context context("When loading entries for virtuals repository:");
- need_names();
-
- Log::get_instance()->message("virtuals.need_entries", ll_debug, lc_context) << "VirtualsRepository need_entries";
-
- IDMap my_ids;
-
- /* Populate our _imp->entries. */
- for (std::vector<std::pair<QualifiedPackageName, std::shared_ptr<const PackageDepSpec> > >::const_iterator
- v(_imp->names.begin()), v_end(_imp->names.end()) ; v != v_end ; ++v)
- {
- std::shared_ptr<const PackageIDSequence> matches((*_imp->env)[selection::AllVersionsSorted(
- generator::Matches(*v->second, make_null_shared_ptr(), { }) |
- filter::SupportsAction<InstallAction>())]);
-
- if (matches->empty())
- Log::get_instance()->message("virtuals.no_match", ll_warning, lc_context) << "No packages matching '"
- << *v->second << "' for virtual '" << v->first << "'";
-
- for (PackageIDSequence::ConstIterator m(matches->begin()), m_end(matches->end()) ;
- m != m_end ; ++m)
- {
- IDMap::iterator i(my_ids.find(v->first));
- if (my_ids.end() == i)
- i = my_ids.insert(std::make_pair(v->first, std::make_shared<PackageIDSequence>())).first;
-
- std::shared_ptr<const PackageID> id(make_virtual_package_id(QualifiedPackageName(v->first), *m));
- if (stringify(id->name().category()) != "virtual")
- throw InternalError(PALUDIS_HERE, "Got bad id '" + stringify(*id) + "'");
- i->second->push_back(id);
- }
- }
-
- using std::swap;
- swap(my_ids, _imp->ids);
}
std::shared_ptr<const PackageIDSequence>
@@ -298,17 +238,6 @@ VirtualsRepository::invalidate()
_imp.reset(new Imp<VirtualsRepository>(_imp->env, _imp->big_nasty_mutex));
}
-const std::shared_ptr<const PackageID>
-VirtualsRepository::make_virtual_package_id(
- const QualifiedPackageName & virtual_name, const std::shared_ptr<const PackageID> & provider) const
-{
- if (virtual_name.category().value() != "virtual")
- throw InternalError(PALUDIS_HERE, "tried to make a virtual package id using '" + stringify(virtual_name) + "', '"
- + stringify(*provider) + "'");
-
- return std::make_shared<virtuals::VirtualsPackageID>(_imp->env, name(), virtual_name, provider, true);
-}
-
const bool
VirtualsRepository::is_unimportant() const
{
diff --git a/paludis/repositories/virtuals/virtuals_repository.hh b/paludis/repositories/virtuals/virtuals_repository.hh
index 3544ecce1..9b476b61c 100644
--- a/paludis/repositories/virtuals/virtuals_repository.hh
+++ b/paludis/repositories/virtuals/virtuals_repository.hh
@@ -33,7 +33,6 @@ namespace paludis
*/
class PALUDIS_VISIBLE VirtualsRepository :
public Repository,
- public RepositoryMakeVirtualsInterface,
public std::enable_shared_from_this<VirtualsRepository>
{
private:
@@ -106,12 +105,6 @@ namespace paludis
virtual bool sync(const std::string &, const std::string &, const std::shared_ptr<OutputManager> &) const;
- /* RepositoryMakeVirtualsInterface */
-
- virtual const std::shared_ptr<const PackageID> make_virtual_package_id(
- const QualifiedPackageName & virtual_name, const std::shared_ptr<const PackageID> & provider) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
/* Keys */
virtual const std::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
diff --git a/paludis/repositories/virtuals/virtuals_repository_TEST.cc b/paludis/repositories/virtuals/virtuals_repository_TEST.cc
deleted file mode 100644
index 529fb40e8..000000000
--- a/paludis/repositories/virtuals/virtuals_repository_TEST.cc
+++ /dev/null
@@ -1,165 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis 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., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/repositories/fake/fake_repository.hh>
-#include <paludis/repositories/fake/fake_installed_repository.hh>
-#include <paludis/repositories/fake/fake_package_id.hh>
-
-#include <paludis/repositories/virtuals/virtuals_repository.hh>
-
-#include <paludis/environments/test/test_environment.hh>
-
-#include <paludis/generator.hh>
-#include <paludis/filter.hh>
-#include <paludis/filtered_generator.hh>
-#include <paludis/selection.hh>
-#include <paludis/user_dep_spec.hh>
-
-#include <paludis/util/sequence.hh>
-#include <paludis/util/wrapped_forward_iterator.hh>
-#include <paludis/util/indirect_iterator-impl.hh>
-#include <paludis/util/options.hh>
-#include <paludis/util/make_named_values.hh>
-#include <paludis/util/join.hh>
-
-#include <gtest/gtest.h>
-
-using namespace paludis;
-
-TEST(VirtualsRepository, Works)
-{
- TestEnvironment env;
- std::shared_ptr<VirtualsRepository> virtuals(std::make_shared<VirtualsRepository>(&env));
- const std::shared_ptr<FakeRepository> repo(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("repo")
- )));
- std::shared_ptr<FakeInstalledRepository> installed(std::make_shared<FakeInstalledRepository>(
- make_named_values<FakeInstalledRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("installed"),
- n::suitable_destination() = true,
- n::supports_uninstall() = true
- )));
-
- ASSERT_TRUE(repo->virtuals_interface());
-
- env.add_repository(2, virtuals);
- env.add_repository(3, repo);
- env.add_repository(4, installed);
-
- repo->add_version("cat", "pkg", "1")->provide_key()->set_from_string("virtual/pkg");
- repo->add_version("cat", "pkg", "2")->provide_key()->set_from_string("virtual/pkg");
- repo->add_virtual_package(QualifiedPackageName("virtual/pkg"), std::make_shared<PackageDepSpec>(
- parse_user_package_dep_spec(">=cat/pkg-2", &env, { })));
-
- ASSERT_TRUE(bool(repo->virtual_packages()));
- ASSERT_EQ(1, std::distance(repo->virtual_packages()->begin(), repo->virtual_packages()->end()));
-
- EXPECT_TRUE(virtuals->has_category_named(CategoryNamePart("virtual"), { }));
- EXPECT_TRUE(virtuals->has_package_named(QualifiedPackageName("virtual/pkg"), { }));
-
- std::shared_ptr<const PackageIDSequence> r(env[selection::AllVersionsSorted(generator::All())]);
- ASSERT_EQ("cat/pkg-1:0::repo | cat/pkg-2:0::repo | virtual/pkg-2::virtuals (virtual for cat/pkg-2:0::repo)",
- join(indirect_iterator(r->begin()), indirect_iterator(r->end()), " | "));
-}
-
-TEST(VirtualsRepository, Duplicates)
-{
- TestEnvironment env;
- std::shared_ptr<VirtualsRepository> virtuals(std::make_shared<VirtualsRepository>(&env));
- const std::shared_ptr<FakeRepository> repo1(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("repo1")
- )));
- const std::shared_ptr<FakeRepository> repo2(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("repo2")
- )));
- std::shared_ptr<FakeInstalledRepository> installed(std::make_shared<FakeInstalledRepository>(
- make_named_values<FakeInstalledRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("installed"),
- n::suitable_destination() = true,
- n::supports_uninstall() = true
- )));
-
- env.add_repository(2, virtuals);
- env.add_repository(3, repo1);
- env.add_repository(4, repo2);
- env.add_repository(5, installed);
-
- repo1->add_version("cat", "pkg", "1")->provide_key()->set_from_string("virtual/pkg");
- repo1->add_version("cat", "pkg", "2")->provide_key()->set_from_string("virtual/pkg");
- repo1->add_virtual_package(QualifiedPackageName("virtual/pkg"), std::make_shared<PackageDepSpec>(
- parse_user_package_dep_spec(">=cat/pkg-2", &env, { })));
- repo1->add_virtual_package(QualifiedPackageName("virtual/foo"), std::make_shared<PackageDepSpec>(
- parse_user_package_dep_spec(">=cat/pkg-2", &env, { })));
-
- repo2->add_virtual_package(QualifiedPackageName("virtual/pkg"), std::make_shared<PackageDepSpec>(
- parse_user_package_dep_spec(">=cat/pkg-2", &env, { })));
- repo2->add_virtual_package(QualifiedPackageName("virtual/foo"), std::make_shared<PackageDepSpec>(
- parse_user_package_dep_spec("<=cat/pkg-1", &env, { })));
-
- EXPECT_TRUE(virtuals->has_category_named(CategoryNamePart("virtual"), { }));
- EXPECT_TRUE(virtuals->has_package_named(QualifiedPackageName("virtual/pkg"), { }));
-
- std::shared_ptr<const PackageIDSequence> r(env[selection::AllVersionsSorted(generator::All())]);
- ASSERT_EQ("cat/pkg-1:0::repo1 | cat/pkg-2:0::repo1 | "
- "virtual/foo-1::virtuals (virtual for cat/pkg-1:0::repo1) | "
- "virtual/foo-2::virtuals (virtual for cat/pkg-2:0::repo1) | "
- "virtual/pkg-2::virtuals (virtual for cat/pkg-2:0::repo1)",
- join(indirect_iterator(r->begin()), indirect_iterator(r->end()), " | "));
-}
-
-TEST(VirtualsRepository, Recursion)
-{
- TestEnvironment env;
- std::shared_ptr<VirtualsRepository> virtuals(std::make_shared<VirtualsRepository>(&env));
- const std::shared_ptr<FakeRepository> repo1(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("repo1")
- )));
- const std::shared_ptr<FakeRepository> repo2(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("repo2")
- )));
-
- env.add_repository(2, repo1);
- env.add_repository(3, repo2);
- env.add_repository(4, virtuals);
-
- repo1->add_version("virtual", "gkp", "1")->provide_key()->set_from_string("virtual/pkg");
- repo1->add_virtual_package(QualifiedPackageName("virtual/pkg"), std::make_shared<PackageDepSpec>(
- parse_user_package_dep_spec("virtual/gkp", &env, { })));
-
- repo2->add_version("virtual", "pkg", "2")->provide_key()->set_from_string("virtual/pkg");
- repo2->add_virtual_package(QualifiedPackageName("virtual/pkg"), std::make_shared<PackageDepSpec>(
- parse_user_package_dep_spec("virtual/pkg", &env, { })));
-
- EXPECT_TRUE(virtuals->has_category_named(CategoryNamePart("virtual"), { }));
- EXPECT_TRUE(virtuals->has_package_named(QualifiedPackageName("virtual/pkg"), { }));
-
- std::shared_ptr<const PackageIDSequence> r(env[selection::AllVersionsSorted(generator::All())]);
- ASSERT_EQ(
- "virtual/gkp-1:0::repo1 | virtual/pkg-1::virtuals (virtual for virtual/gkp-1:0::repo1) | "
- "virtual/pkg-2:0::repo2 | virtual/pkg-2::virtuals (virtual for virtual/pkg-2:0::repo2)",
- join(indirect_iterator(r->begin()), indirect_iterator(r->end()), " | "));
-}
-