aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-07 10:07:58 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-08 10:53:07 +0100
commitb7d4756232923e0c4c97f8d56f3c47a3b950d62b (patch)
tree9dca847fd9ba20215e2fbb2b8c0d5ec338e7a9b4
parenteace2183970d97a52b5e6b1b07b3fab8bd7fd839 (diff)
downloadpaludis-b7d4756232923e0c4c97f8d56f3c47a3b950d62b.tar.gz
paludis-b7d4756232923e0c4c97f8d56f3c47a3b950d62b.tar.xz
GetDestinationTypesForErrorHelper
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/get_destination_types_for_error_helper-fwd.hh31
-rw-r--r--paludis/resolver/get_destination_types_for_error_helper.cc127
-rw-r--r--paludis/resolver/get_destination_types_for_error_helper.hh55
-rw-r--r--paludis/resolver/resolver_test.cc12
-rw-r--r--paludis/resolver/resolver_test.hh5
-rw-r--r--src/clients/cave/resolve_common.cc15
7 files changed, 233 insertions, 14 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index a06bd0e..4fedc61 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -46,6 +46,7 @@ noinst_HEADERS = \
get_constraints_for_dependent_helper.hh get_constraints_for_dependent_helper-fwd.hh \
get_constraints_for_purge_helper.hh get_constraints_for_dependent_helper-fwd.hh \
get_constraints_for_via_binary_helper.hh get_constraints_for_via_binary_helper-fwd.hh \
+ get_destination_types_for_error_helper.hh get_destination_types_for_error_helper-fwd.hh \
job.hh job-fwd.hh \
job_list.hh job_list-fwd.hh \
job_lists.hh job_lists-fwd.hh \
@@ -91,6 +92,7 @@ libpaludisresolver_a_SOURCES = \
get_constraints_for_dependent_helper.cc \
get_constraints_for_purge_helper.cc \
get_constraints_for_via_binary_helper.cc \
+ get_destination_types_for_error_helper.cc \
job.cc \
job_list.cc \
job_lists.cc \
diff --git a/paludis/resolver/get_destination_types_for_error_helper-fwd.hh b/paludis/resolver/get_destination_types_for_error_helper-fwd.hh
new file mode 100644
index 0000000..5df117e
--- /dev/null
+++ b/paludis/resolver/get_destination_types_for_error_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_GET_DESTINATION_TYPES_FOR_ERROR_HELPER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_GET_DESTINATION_TYPES_FOR_ERROR_HELPER_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct GetDestinationTypesForErrorHelper;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/get_destination_types_for_error_helper.cc b/paludis/resolver/get_destination_types_for_error_helper.cc
new file mode 100644
index 0000000..40f7bec
--- /dev/null
+++ b/paludis/resolver/get_destination_types_for_error_helper.cc
@@ -0,0 +1,127 @@
+/* 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/get_destination_types_for_error_helper.hh>
+#include <paludis/resolver/reason.hh>
+#include <paludis/resolver/constraint.hh>
+#include <paludis/resolver/resolvent.hh>
+#include <paludis/resolver/resolution.hh>
+#include <paludis/resolver/decision.hh>
+#include <paludis/util/pimp-impl.hh>
+#include <paludis/util/simple_visitor_cast.hh>
+#include <paludis/util/make_shared_copy.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/package_id.hh>
+#include <paludis/package_dep_spec_collection.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
+#include <paludis/elike_slot_requirement.hh>
+#include <paludis/metadata_key.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace paludis
+{
+ template <>
+ struct Imp<GetDestinationTypesForErrorHelper>
+ {
+ const Environment * const env;
+ DestinationType target_destination_type;
+
+ Imp(const Environment * const e) :
+ env(e),
+ target_destination_type(dt_install_to_slash)
+ {
+ }
+ };
+}
+
+GetDestinationTypesForErrorHelper::GetDestinationTypesForErrorHelper(const Environment * const e) :
+ Pimp<GetDestinationTypesForErrorHelper>(e)
+{
+}
+
+GetDestinationTypesForErrorHelper::~GetDestinationTypesForErrorHelper() = default;
+
+void
+GetDestinationTypesForErrorHelper::set_target_destination_type(const DestinationType d)
+{
+ _imp->target_destination_type = d;
+}
+
+namespace
+{
+ struct DestinationTypesFinder
+ {
+ const DestinationType target_destination_type;
+
+ DestinationTypes visit(const TargetReason &) const
+ {
+ return { target_destination_type };
+ }
+
+ DestinationTypes visit(const DependentReason &) const
+ {
+ return { dt_install_to_slash };
+ }
+
+ DestinationTypes visit(const ViaBinaryReason &) const
+ {
+ return { };
+ }
+
+ DestinationTypes visit(const WasUsedByReason &) const
+ {
+ return { dt_install_to_slash };
+ }
+
+ DestinationTypes visit(const DependencyReason &) const
+ {
+ return { dt_install_to_slash };
+ }
+
+ DestinationTypes visit(const PresetReason &) const
+ {
+ return { };
+ }
+
+ DestinationTypes visit(const LikeOtherDestinationTypeReason & r) const
+ {
+ return r.reason_for_other()->accept_returning<DestinationTypes>(*this);
+ }
+
+ DestinationTypes visit(const SetReason & r) const
+ {
+ return r.reason_for_set()->accept_returning<DestinationTypes>(*this);
+ }
+ };
+}
+
+DestinationTypes
+GetDestinationTypesForErrorHelper::operator() (
+ const PackageDepSpec &,
+ const std::shared_ptr<const Reason> & reason) const
+{
+ return reason->accept_returning<DestinationTypes>(DestinationTypesFinder{_imp->target_destination_type});
+}
+
+template class Pimp<GetDestinationTypesForErrorHelper>;
+
diff --git a/paludis/resolver/get_destination_types_for_error_helper.hh b/paludis/resolver/get_destination_types_for_error_helper.hh
new file mode 100644
index 0000000..7cf2dee
--- /dev/null
+++ b/paludis/resolver/get_destination_types_for_error_helper.hh
@@ -0,0 +1,55 @@
+/* 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_GET_DESTINATION_TYPES_FOR_ERROR_HELPER_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_GET_DESTINATION_TYPES_FOR_ERROR_HELPER_HH 1
+
+#include <paludis/resolver/get_destination_types_for_error_helper-fwd.hh>
+#include <paludis/resolver/resolution-fwd.hh>
+#include <paludis/resolver/reason-fwd.hh>
+#include <paludis/resolver/destination_types-fwd.hh>
+#include <paludis/util/pimp.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE GetDestinationTypesForErrorHelper :
+ private Pimp<GetDestinationTypesForErrorHelper>
+ {
+ public:
+ explicit GetDestinationTypesForErrorHelper(const Environment * const);
+ ~GetDestinationTypesForErrorHelper();
+
+ void set_target_destination_type(const DestinationType);
+
+ DestinationTypes operator() (
+ const PackageDepSpec &,
+ const std::shared_ptr<const Reason> &) const;
+ };
+ }
+
+ extern template class Pimp<resolver::GetDestinationTypesForErrorHelper>;
+}
+
+#endif
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 2c8d7a3..45b7318 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -144,13 +144,6 @@ paludis::resolver::resolver_test::make_unmaskable_filter_fn(
return filter::NotMasked();
}
-DestinationTypes
-paludis::resolver::resolver_test::get_destination_types_for_error_fn(const PackageDepSpec &,
- const std::shared_ptr<const Reason> &)
-{
- return DestinationTypes() + dt_install_to_slash;
-}
-
namespace
{
#ifdef ENABLE_VIRTUALS_REPOSITORY
@@ -235,7 +228,8 @@ ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s,
find_repository_for_helper(&env),
get_constraints_for_dependent_helper(&env),
get_constraints_for_purge_helper(&env),
- get_constraints_for_via_binary_helper(&env)
+ get_constraints_for_via_binary_helper(&env),
+ get_destination_types_for_error_helper(&env)
{
std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
keys->insert("format", "e");
@@ -290,7 +284,7 @@ ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraint
n::get_constraints_for_dependent_fn() = std::cref(get_constraints_for_dependent_helper),
n::get_constraints_for_purge_fn() = std::cref(get_constraints_for_purge_helper),
n::get_constraints_for_via_binary_fn() = std::cref(get_constraints_for_via_binary_helper),
- n::get_destination_types_for_error_fn() = &get_destination_types_for_error_fn,
+ n::get_destination_types_for_error_fn() = std::cref(get_destination_types_for_error_helper),
n::get_initial_constraints_for_fn() =
std::bind(&initial_constraints_for_fn, std::ref(initial_constraints),
std::placeholders::_1),
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 1568640..537e0f7 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -44,6 +44,7 @@
#include <paludis/resolver/get_constraints_for_dependent_helper.hh>
#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/repositories/fake/fake_installed_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
@@ -102,9 +103,6 @@ namespace paludis
Filter make_unmaskable_filter_fn(
const std::shared_ptr<const Resolution> &);
- DestinationTypes get_destination_types_for_error_fn(const PackageDepSpec &,
- const std::shared_ptr<const Reason> &);
-
bool remove_if_dependent_fn(
const std::shared_ptr<const QualifiedPackageNameSet> &,
const std::shared_ptr<const PackageID> &);
@@ -133,6 +131,7 @@ namespace paludis
GetConstraintsForDependentHelper get_constraints_for_dependent_helper;
GetConstraintsForPurgeHelper get_constraints_for_purge_helper;
GetConstraintsForViaBinaryHelper get_constraints_for_via_binary_helper;
+ GetDestinationTypesForErrorHelper get_destination_types_for_error_helper;
ResolverTestCase(const std::string & group, const std::string & test_name, const std::string & eapi,
const std::string & layout);
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index bb59142..d8cb260 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_dependent_helper.hh>
#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/user_dep_spec.hh>
#include <paludis/notifier_callback.hh>
@@ -1677,6 +1678,17 @@ paludis::cave::resolve_common(
GetConstraintsForViaBinaryHelper get_constraints_for_via_binary_helper(env.get());
+ GetDestinationTypesForErrorHelper get_destination_types_for_error_helper(env.get());
+ if (resolution_options.a_make.argument() == "binaries")
+ get_destination_types_for_error_helper.set_target_destination_type(dt_create_binary);
+ else if (resolution_options.a_make.argument() == "install")
+ get_destination_types_for_error_helper.set_target_destination_type(dt_install_to_slash);
+ else if (resolution_options.a_make.argument() == "chroot")
+ get_destination_types_for_error_helper.set_target_destination_type(dt_install_to_chroot);
+ else
+ throw args::DoHelp("Don't understand argument '" + resolution_options.a_make.argument() + "' to '--"
+ + resolution_options.a_make.long_name() + "'");
+
ResolverFunctions resolver_functions(make_named_values<ResolverFunctions>(
n::allow_choice_changes_fn() = std::cref(allow_choice_changes_helper),
n::allowed_to_remove_fn() = std::cref(allowed_to_remove_helper),
@@ -1687,8 +1699,7 @@ paludis::cave::resolve_common(
n::get_constraints_for_dependent_fn() = std::cref(get_constraints_for_dependent_helper),
n::get_constraints_for_purge_fn() = std::cref(get_constraints_for_purge_helper),
n::get_constraints_for_via_binary_fn() = std::cref(get_constraints_for_via_binary_helper),
- n::get_destination_types_for_error_fn() = std::bind(&get_destination_types_for_fn,
- env.get(), std::cref(resolution_options), _1, make_null_shared_ptr(), _2),
+ n::get_destination_types_for_error_fn() = std::cref(get_destination_types_for_error_helper),
n::get_initial_constraints_for_fn() = std::bind(&initial_constraints_for_fn,
env.get(), std::cref(resolution_options), std::cref(without),
std::cref(initial_constraints), binary_destinations, _1),