aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-07 19:42:59 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-08 10:53:07 +0100
commit7d86f4823402c6bb65a28a81a435bd21a2b259f3 (patch)
treecad9c0288144c8e23e556c43a11d64f897084b1d
parent490687fe881a3d2f9ba194a5675d522adff20e96 (diff)
downloadpaludis-7d86f4823402c6bb65a28a81a435bd21a2b259f3.tar.gz
paludis-7d86f4823402c6bb65a28a81a435bd21a2b259f3.tar.xz
MakeDestinationFilteredGeneratorHelper
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/make_destination_filtered_generator_helper-fwd.hh31
-rw-r--r--paludis/resolver/make_destination_filtered_generator_helper.cc122
-rw-r--r--paludis/resolver/make_destination_filtered_generator_helper.hh52
-rw-r--r--paludis/resolver/resolver_test.cc25
-rw-r--r--paludis/resolver/resolver_test.hh5
-rw-r--r--src/clients/cave/resolve_common.cc16
7 files changed, 215 insertions, 38 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 4233610..5670247 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -55,6 +55,7 @@ noinst_HEADERS = \
job_requirements.hh job_requirements-fwd.hh \
job_state.hh job_state-fwd.hh \
labels_classifier.hh labels_classifier-fwd.hh \
+ make_destination_filtered_generator_helper.hh make_destination_filtered_generator_helper-fwd.hh \
make_origin_filtered_generator_helper.hh make_origin_filtered_generator_helper-fwd.hh \
make_unmaskable_filter_helper.hh make_unmaskable_filter_helper-fwd.hh \
nag.hh nag-fwd.hh \
@@ -108,6 +109,7 @@ libpaludisresolver_a_SOURCES = \
job_requirements.cc \
job_state.cc \
labels_classifier.cc \
+ make_destination_filtered_generator_helper.cc \
make_origin_filtered_generator_helper.cc \
make_unmaskable_filter_helper.cc \
nag.cc \
diff --git a/paludis/resolver/make_destination_filtered_generator_helper-fwd.hh b/paludis/resolver/make_destination_filtered_generator_helper-fwd.hh
new file mode 100644
index 0000000..47d9dfc
--- /dev/null
+++ b/paludis/resolver/make_destination_filtered_generator_helper-fwd.hh
@@ -0,0 +1,31 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_MAKE_DESTINATION_FILTERED_GENERATOR_HELPER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_MAKE_DESTINATION_FILTERED_GENERATOR_HELPER_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct MakeDestinationFilteredGeneratorHelper;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/make_destination_filtered_generator_helper.cc b/paludis/resolver/make_destination_filtered_generator_helper.cc
new file mode 100644
index 0000000..2436eb8
--- /dev/null
+++ b/paludis/resolver/make_destination_filtered_generator_helper.cc
@@ -0,0 +1,122 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 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/resolver/make_destination_filtered_generator_helper.hh>
+#include <paludis/resolver/reason.hh>
+#include <paludis/resolver/constraint.hh>
+#include <paludis/resolver/resolvent.hh>
+#include <paludis/resolver/resolution.hh>
+#include <paludis/util/pimp-impl.hh>
+#include <paludis/util/set.hh>
+#include <paludis/filter.hh>
+#include <paludis/filter_handler.hh>
+#include <paludis/filtered_generator.hh>
+#include <paludis/generator.hh>
+#include <paludis/generator_handler.hh>
+#include <paludis/package_database.hh>
+#include <paludis/repository.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/environment.hh>
+#include <paludis/package_database.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace paludis
+{
+ template <>
+ struct Imp<MakeDestinationFilteredGeneratorHelper>
+ {
+ const Environment * const env;
+
+ Imp(const Environment * const e) :
+ env(e)
+ {
+ }
+ };
+}
+
+MakeDestinationFilteredGeneratorHelper::MakeDestinationFilteredGeneratorHelper(const Environment * const e) :
+ Pimp<MakeDestinationFilteredGeneratorHelper>(e)
+{
+}
+
+MakeDestinationFilteredGeneratorHelper::~MakeDestinationFilteredGeneratorHelper() = default;
+
+namespace
+{
+ struct BinaryDestinationGeneratorHandler :
+ AllGeneratorHandlerBase
+ {
+ virtual std::shared_ptr<const RepositoryNameSet> repositories(
+ const Environment * const env) const
+ {
+ using namespace std::placeholders;
+ std::shared_ptr<RepositoryNameSet> result(std::make_shared<RepositoryNameSet>());
+ for (auto r(env->package_database()->begin_repositories()),
+ r_end(env->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ if (! (*r)->installed_root_key())
+ if ((*r)->destination_interface())
+ result->insert((*r)->name());
+
+ return result;
+ }
+
+ virtual std::string as_string() const
+ {
+ return "binary destination repositories";
+ }
+ };
+
+ struct BinaryDestinationGenerator :
+ Generator
+ {
+ BinaryDestinationGenerator() :
+ Generator(std::make_shared<BinaryDestinationGeneratorHandler>())
+ {
+ }
+ };
+}
+
+FilteredGenerator
+MakeDestinationFilteredGeneratorHelper::operator() (
+ const Generator & g,
+ const std::shared_ptr<const Resolution> & r) const
+{
+ switch (r->resolvent().destination_type())
+ {
+ case dt_install_to_slash:
+ return g | filter::InstalledAtSlash();
+
+ case dt_install_to_chroot:
+ return g | filter::InstalledAtNotSlash();
+
+ case dt_create_binary:
+ return g & BinaryDestinationGenerator();
+
+ case last_dt:
+ break;
+ }
+
+ throw InternalError(PALUDIS_HERE, "unhandled dt");
+}
+
+template class Pimp<MakeDestinationFilteredGeneratorHelper>;
+
diff --git a/paludis/resolver/make_destination_filtered_generator_helper.hh b/paludis/resolver/make_destination_filtered_generator_helper.hh
new file mode 100644
index 0000000..3f65efa
--- /dev/null
+++ b/paludis/resolver/make_destination_filtered_generator_helper.hh
@@ -0,0 +1,52 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_MAKE_DESTINATION_FILTERED_GENERATOR_HELPER_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_MAKE_DESTINATION_FILTERED_GENERATOR_HELPER_HH 1
+
+#include <paludis/resolver/make_destination_filtered_generator_helper-fwd.hh>
+#include <paludis/resolver/resolution-fwd.hh>
+#include <paludis/util/pimp.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/generator-fwd.hh>
+#include <paludis/filtered_generator-fwd.hh>
+#include <memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE MakeDestinationFilteredGeneratorHelper :
+ private Pimp<MakeDestinationFilteredGeneratorHelper>
+ {
+ public:
+ explicit MakeDestinationFilteredGeneratorHelper(const Environment * const);
+ ~MakeDestinationFilteredGeneratorHelper();
+
+ FilteredGenerator operator() (
+ const Generator &,
+ const std::shared_ptr<const Resolution> &) const;
+ };
+ }
+
+ extern template class Pimp<resolver::MakeDestinationFilteredGeneratorHelper>;
+}
+
+#endif
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 76e4b9f..5cfcd2b 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -108,28 +108,6 @@ paludis::resolver::resolver_test::get_resolvents_for_fn(
return result;
}
-FilteredGenerator
-paludis::resolver::resolver_test::make_destination_filtered_generator_fn(const Generator & g,
- const std::shared_ptr<const Resolution> & resolution)
-{
- switch (resolution->resolvent().destination_type())
- {
- case dt_install_to_slash:
- return g | filter::InstalledAtSlash();
-
- case dt_install_to_chroot:
- return g | filter::InstalledAtNotSlash();
-
- case dt_create_binary:
- throw InternalError(PALUDIS_HERE, "no dt_create_binary yet");
-
- case last_dt:
- break;
- }
-
- throw InternalError(PALUDIS_HERE, "unhandled dt");
-}
-
namespace
{
#ifdef ENABLE_VIRTUALS_REPOSITORY
@@ -187,6 +165,7 @@ ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s,
get_constraints_for_purge_helper(&env),
get_constraints_for_via_binary_helper(&env),
get_destination_types_for_error_helper(&env),
+ make_destination_filtered_generator_helper(&env),
make_origin_filtered_generator_helper(&env),
make_unmaskable_filter_helper(&env),
order_early_helper(&env),
@@ -256,7 +235,7 @@ ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraint
std::placeholders::_2, std::placeholders::_3),
n::get_use_existing_nothing_fn() = &get_use_existing_nothing_fn,
n::interest_in_spec_fn() = &interest_in_spec_fn,
- n::make_destination_filtered_generator_fn() = &make_destination_filtered_generator_fn,
+ n::make_destination_filtered_generator_fn() = std::cref(make_destination_filtered_generator_helper),
n::make_origin_filtered_generator_fn() = std::cref(make_origin_filtered_generator_helper),
n::make_unmaskable_filter_fn() = std::cref(make_unmaskable_filter_helper),
n::order_early_fn() = std::cref(order_early_helper),
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index f842036..e2a8a10 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -45,6 +45,7 @@
#include <paludis/resolver/get_constraints_for_purge_helper.hh>
#include <paludis/resolver/get_constraints_for_via_binary_helper.hh>
#include <paludis/resolver/get_destination_types_for_error_helper.hh>
+#include <paludis/resolver/make_destination_filtered_generator_helper.hh>
#include <paludis/resolver/make_origin_filtered_generator_helper.hh>
#include <paludis/resolver/make_unmaskable_filter_helper.hh>
#include <paludis/resolver/order_early_helper.hh>
@@ -99,9 +100,6 @@ namespace paludis
const PackageDepSpec &,
const std::shared_ptr<const Reason> &);
- FilteredGenerator make_destination_filtered_generator_fn(const Generator &,
- const std::shared_ptr<const Resolution> &);
-
struct ResolverTestCase : test::TestCase
{
TestEnvironment env;
@@ -118,6 +116,7 @@ namespace paludis
GetConstraintsForPurgeHelper get_constraints_for_purge_helper;
GetConstraintsForViaBinaryHelper get_constraints_for_via_binary_helper;
GetDestinationTypesForErrorHelper get_destination_types_for_error_helper;
+ MakeDestinationFilteredGeneratorHelper make_destination_filtered_generator_helper;
MakeOriginFilteredGeneratorHelper make_origin_filtered_generator_helper;
MakeUnmaskableFilterHelper make_unmaskable_filter_helper;
OrderEarlyHelper order_early_helper;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 6fb3d04..c7e9885 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -74,6 +74,7 @@
#include <paludis/resolver/get_constraints_for_purge_helper.hh>
#include <paludis/resolver/get_constraints_for_via_binary_helper.hh>
#include <paludis/resolver/get_destination_types_for_error_helper.hh>
+#include <paludis/resolver/make_destination_filtered_generator_helper.hh>
#include <paludis/resolver/make_origin_filtered_generator_helper.hh>
#include <paludis/resolver/make_unmaskable_filter_helper.hh>
#include <paludis/resolver/order_early_helper.hh>
@@ -273,16 +274,6 @@ namespace
throw InternalError(PALUDIS_HERE, stringify(r.destination_type()));
}
- FilteredGenerator make_destination_filtered_generator_with_resolution(
- const Environment * const env,
- const ResolveCommandLineResolutionOptions & resolution_options,
- const std::shared_ptr<const Generator> & binary_destinations,
- const Generator & g,
- const std::shared_ptr<const Resolution> & r)
- {
- return make_destination_filtered_generator(env, resolution_options, binary_destinations, g, r->resolvent());
- }
-
const std::shared_ptr<const Sequence<std::string> > add_resolver_targets(
const std::shared_ptr<Environment> & env,
const std::shared_ptr<Resolver> & resolver,
@@ -1508,6 +1499,8 @@ paludis::cave::resolve_common(
throw args::DoHelp("Don't understand argument '" + resolution_options.a_make.argument() + "' to '--"
+ resolution_options.a_make.long_name() + "'");
+ MakeDestinationFilteredGeneratorHelper make_destination_filtered_generator_helper(env.get());
+
MakeOriginFilteredGeneratorHelper make_origin_filtered_generator_helper(env.get());
make_origin_filtered_generator_helper.set_making_binaries("binaries" == resolution_options.a_make.argument());
@@ -1563,8 +1556,7 @@ paludis::cave::resolve_common(
env.get(), std::cref(resolution_options), std::cref(take), std::cref(take_from),
std::cref(ignore), std::cref(ignore_from), std::cref(no_blockers_from),
std::cref(no_dependencies_from), _1, _2),
- n::make_destination_filtered_generator_fn() = std::bind(&make_destination_filtered_generator_with_resolution,
- env.get(), std::cref(resolution_options), binary_destinations, _1, _2),
+ n::make_destination_filtered_generator_fn() = std::cref(make_destination_filtered_generator_helper),
n::make_origin_filtered_generator_fn() = std::cref(make_origin_filtered_generator_helper),
n::make_unmaskable_filter_fn() = std::cref(make_unmaskable_filter_helper),
n::order_early_fn() = std::cref(order_early_helper),