aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-27 17:06:24 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-27 17:06:24 +0100
commit4ebece82902e70596afeb7f5a94ae813bc0ea2c6 (patch)
tree09b380e717ff9583c5da415d276a8894b59fb903
parent3ace323255a056bca23028af8fad91fcc1640a49 (diff)
downloadpaludis-4ebece82902e70596afeb7f5a94ae813bc0ea2c6.tar.gz
paludis-4ebece82902e70596afeb7f5a94ae813bc0ea2c6.tar.xz
Handle blockers with chroots
Fixes: ticket:963
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/decider.cc16
-rw-r--r--paludis/resolver/decider.hh6
-rw-r--r--paludis/resolver/get_destination_types_for_blocker_helper-fwd.hh31
-rw-r--r--paludis/resolver/get_destination_types_for_blocker_helper.cc127
-rw-r--r--paludis/resolver/get_destination_types_for_blocker_helper.hh55
-rw-r--r--paludis/resolver/resolver_functions.hh7
-rw-r--r--paludis/resolver/resolver_test.cc2
-rw-r--r--paludis/resolver/resolver_test.hh2
-rw-r--r--src/clients/cave/resolve_common.cc5
10 files changed, 244 insertions, 9 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 51ac518..d7034fa 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -54,6 +54,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_purge_helper-fwd.hh \
get_constraints_for_via_binary_helper.hh get_constraints_for_via_binary_helper-fwd.hh \
+ get_destination_types_for_blocker_helper.hh get_destination_types_for_blocker_helper-fwd.hh \
get_destination_types_for_error_helper.hh get_destination_types_for_error_helper-fwd.hh \
get_initial_constraints_for_helper.hh get_initial_constraints_for_helper-fwd.hh \
get_resolvents_for_helper.hh get_resolvents_for_helper-fwd.hh \
@@ -120,6 +121,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_blocker_helper.cc \
get_destination_types_for_error_helper.cc \
get_initial_constraints_for_helper.cc \
get_resolvents_for_helper.cc \
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index f6dd3fb..7c083c3 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -660,7 +660,7 @@ Decider::_make_constraints_from_blocker(
{
const std::shared_ptr<ConstraintSequence> result(std::make_shared<ConstraintSequence>());
- DestinationTypes destination_types(_get_destination_types_for_blocker(spec));
+ DestinationTypes destination_types(_get_destination_types_for_blocker(spec, reason));
for (EnumIterator<DestinationType> t, t_end(last_dt) ; t != t_end ; ++t)
if (destination_types[*t])
result->push_back(std::make_shared<Constraint>(make_named_values<Constraint>(
@@ -1186,7 +1186,7 @@ Decider::_add_dependencies_if_necessary(
if (s->spec().if_package())
resolvents = _get_resolvents_for(*s->spec().if_package(), reason);
else
- resolvents = _get_resolvents_for_blocker(*s->spec().if_block());
+ resolvents = _get_resolvents_for_blocker(*s->spec().if_block(), reason);
if (resolvents->empty())
{
@@ -1419,7 +1419,8 @@ namespace
}
const std::shared_ptr<const Resolvents>
-Decider::_get_resolvents_for_blocker(const BlockDepSpec & spec) const
+Decider::_get_resolvents_for_blocker(const BlockDepSpec & spec,
+ const std::shared_ptr<const Reason> & reason) const
{
Context context("When finding slots for '" + stringify(spec) + "':");
@@ -1430,7 +1431,7 @@ Decider::_get_resolvents_for_blocker(const BlockDepSpec & spec) const
exact_slot = spec.blocking().slot_requirement_ptr()->accept_returning<std::shared_ptr<SlotName> >(f);
}
- DestinationTypes destination_types(_get_destination_types_for_blocker(spec));
+ DestinationTypes destination_types(_get_destination_types_for_blocker(spec, reason));
std::shared_ptr<Resolvents> result(std::make_shared<Resolvents>());
if (exact_slot)
{
@@ -1454,9 +1455,10 @@ Decider::_get_resolvents_for_blocker(const BlockDepSpec & spec) const
}
const DestinationTypes
-Decider::_get_destination_types_for_blocker(const BlockDepSpec &) const
+Decider::_get_destination_types_for_blocker(const BlockDepSpec & spec,
+ const std::shared_ptr<const Reason> & reason) const
{
- return DestinationTypes() + dt_install_to_slash;
+ return _imp->fns.get_destination_types_for_blocker_fn()(spec, reason);
}
const std::shared_ptr<const Resolvents>
@@ -1975,7 +1977,7 @@ Decider::add_target_with_reason(const PackageOrBlockDepSpec & spec, const std::s
if (spec.if_package())
resolvents = _get_resolvents_for(*spec.if_package(), reason);
else
- resolvents = _get_resolvents_for_blocker(*spec.if_block());
+ resolvents = _get_resolvents_for_blocker(*spec.if_block(), reason);
if (resolvents->empty())
{
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index 642428d..d98a706 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -62,9 +62,11 @@ namespace paludis
const std::shared_ptr<Resolution> _create_resolution_for_resolvent(const Resolvent &) const;
const std::shared_ptr<Resolution> _resolution_for_resolvent(const Resolvent &, const Tribool);
- const std::shared_ptr<const Resolvents> _get_resolvents_for_blocker(const BlockDepSpec &) const;
+ const std::shared_ptr<const Resolvents> _get_resolvents_for_blocker(const BlockDepSpec &,
+ const std::shared_ptr<const Reason> & reason) const;
- const DestinationTypes _get_destination_types_for_blocker(const BlockDepSpec &) const;
+ const DestinationTypes _get_destination_types_for_blocker(const BlockDepSpec &,
+ const std::shared_ptr<const Reason> &) const;
const std::shared_ptr<const Resolvents> _get_resolvents_for(
const PackageDepSpec & spec,
diff --git a/paludis/resolver/get_destination_types_for_blocker_helper-fwd.hh b/paludis/resolver/get_destination_types_for_blocker_helper-fwd.hh
new file mode 100644
index 0000000..f6f96ed
--- /dev/null
+++ b/paludis/resolver/get_destination_types_for_blocker_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_BLOCKER_HELPER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_GET_DESTINATION_TYPES_FOR_BLOCKER_HELPER_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct GetDestinationTypesForBlockerHelper;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/get_destination_types_for_blocker_helper.cc b/paludis/resolver/get_destination_types_for_blocker_helper.cc
new file mode 100644
index 0000000..7bd08e3
--- /dev/null
+++ b/paludis/resolver/get_destination_types_for_blocker_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_blocker_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<GetDestinationTypesForBlockerHelper>
+ {
+ const Environment * const env;
+ DestinationType target_destination_type;
+
+ Imp(const Environment * const e) :
+ env(e),
+ target_destination_type(dt_install_to_slash)
+ {
+ }
+ };
+}
+
+GetDestinationTypesForBlockerHelper::GetDestinationTypesForBlockerHelper(const Environment * const e) :
+ Pimp<GetDestinationTypesForBlockerHelper>(e)
+{
+}
+
+GetDestinationTypesForBlockerHelper::~GetDestinationTypesForBlockerHelper() = default;
+
+void
+GetDestinationTypesForBlockerHelper::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
+GetDestinationTypesForBlockerHelper::operator() (
+ const BlockDepSpec &,
+ const std::shared_ptr<const Reason> & reason) const
+{
+ return reason->accept_returning<DestinationTypes>(DestinationTypesFinder{_imp->target_destination_type});
+}
+
+template class Pimp<GetDestinationTypesForBlockerHelper>;
+
diff --git a/paludis/resolver/get_destination_types_for_blocker_helper.hh b/paludis/resolver/get_destination_types_for_blocker_helper.hh
new file mode 100644
index 0000000..cb3104b
--- /dev/null
+++ b/paludis/resolver/get_destination_types_for_blocker_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_BLOCKER_HELPER_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_GET_DESTINATION_TYPES_FOR_BLOCKER_HELPER_HH 1
+
+#include <paludis/resolver/get_destination_types_for_blocker_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 GetDestinationTypesForBlockerHelper :
+ private Pimp<GetDestinationTypesForBlockerHelper>
+ {
+ public:
+ explicit GetDestinationTypesForBlockerHelper(const Environment * const);
+ ~GetDestinationTypesForBlockerHelper();
+
+ void set_target_destination_type(const DestinationType);
+
+ DestinationTypes operator() (
+ const BlockDepSpec &,
+ const std::shared_ptr<const Reason> &) const;
+ };
+ }
+
+ extern template class Pimp<resolver::GetDestinationTypesForBlockerHelper>;
+}
+
+#endif
diff --git a/paludis/resolver/resolver_functions.hh b/paludis/resolver/resolver_functions.hh
index 4c48c48..216ed8c 100644
--- a/paludis/resolver/resolver_functions.hh
+++ b/paludis/resolver/resolver_functions.hh
@@ -55,6 +55,7 @@ namespace paludis
typedef Name<struct get_constraints_for_dependent_fn_name> get_constraints_for_dependent_fn;
typedef Name<struct get_constraints_for_purge_fn_name> get_constraints_for_purge_fn;
typedef Name<struct get_constraints_for_via_binary_fn_name> get_constraints_for_via_binary_fn;
+ typedef Name<struct get_destination_types_for_blocker_fn_name> get_destination_types_for_blocker_fn;
typedef Name<struct get_destination_types_for_error_fn_name> get_destination_types_for_error_fn;
typedef Name<struct get_initial_constraints_for_fn_name> get_initial_constraints_for_fn;
typedef Name<struct get_resolvents_for_fn_name> get_resolvents_for_fn;
@@ -115,6 +116,11 @@ namespace paludis
)> GetConstraintsForViaBinaryFunction;
typedef std::function<DestinationTypes (
+ const BlockDepSpec &,
+ const std::shared_ptr<const Reason> &
+ )> GetDestinationTypesForBlockerFunction;
+
+ typedef std::function<DestinationTypes (
const PackageDepSpec &,
const std::shared_ptr<const Reason> &
)> GetDestinationTypesForErrorFunction;
@@ -177,6 +183,7 @@ namespace paludis
NamedValue<n::get_constraints_for_dependent_fn, GetConstraintsForDependentFunction> get_constraints_for_dependent_fn;
NamedValue<n::get_constraints_for_purge_fn, GetConstraintsForPurgeFunction> get_constraints_for_purge_fn;
NamedValue<n::get_constraints_for_via_binary_fn, GetConstraintsForViaBinaryFunction> get_constraints_for_via_binary_fn;
+ NamedValue<n::get_destination_types_for_blocker_fn, GetDestinationTypesForBlockerFunction> get_destination_types_for_blocker_fn;
NamedValue<n::get_destination_types_for_error_fn, GetDestinationTypesForErrorFunction> get_destination_types_for_error_fn;
NamedValue<n::get_initial_constraints_for_fn, GetInitialConstraintsForFunction> get_initial_constraints_for_fn;
NamedValue<n::get_resolvents_for_fn, GetResolventsForFunction> get_resolvents_for_fn;
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 4724331..4fb08c1 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -110,6 +110,7 @@ ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s,
get_constraints_for_dependent_helper(&env),
get_constraints_for_purge_helper(&env),
get_constraints_for_via_binary_helper(&env),
+ get_destination_types_for_blocker_helper(&env),
get_destination_types_for_error_helper(&env),
get_initial_constraints_for_helper(&env),
get_resolvents_for_helper(&env),
@@ -180,6 +181,7 @@ ResolverTestCase::get_resolver_functions()
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_blocker_fn() = std::cref(get_destination_types_for_blocker_helper),
n::get_destination_types_for_error_fn() = std::cref(get_destination_types_for_error_helper),
n::get_initial_constraints_for_fn() = std::cref(get_initial_constraints_for_helper),
n::get_resolvents_for_fn() = std::cref(get_resolvents_for_helper),
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 04e089d..b1e959a 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_blocker_helper.hh>
#include <paludis/resolver/get_destination_types_for_error_helper.hh>
#include <paludis/resolver/get_initial_constraints_for_helper.hh>
#include <paludis/resolver/get_resolvents_for_helper.hh>
@@ -98,6 +99,7 @@ namespace paludis
GetConstraintsForDependentHelper get_constraints_for_dependent_helper;
GetConstraintsForPurgeHelper get_constraints_for_purge_helper;
GetConstraintsForViaBinaryHelper get_constraints_for_via_binary_helper;
+ GetDestinationTypesForBlockerHelper get_destination_types_for_blocker_helper;
GetDestinationTypesForErrorHelper get_destination_types_for_error_helper;
GetInitialConstraintsForHelper get_initial_constraints_for_helper;
GetResolventsForHelper get_resolvents_for_helper;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 169d61f..3c7b02c 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_blocker_helper.hh>
#include <paludis/resolver/get_destination_types_for_error_helper.hh>
#include <paludis/resolver/get_initial_constraints_for_helper.hh>
#include <paludis/resolver/get_resolvents_for_helper.hh>
@@ -633,6 +634,9 @@ paludis::cave::resolve_common(
GetConstraintsForViaBinaryHelper get_constraints_for_via_binary_helper(env.get());
+ GetDestinationTypesForBlockerHelper get_destination_types_for_blocker_helper(env.get());
+ get_destination_types_for_blocker_helper.set_target_destination_type(destination_type_from_arg(env.get(), resolution_options.a_make));
+
GetDestinationTypesForErrorHelper get_destination_types_for_error_helper(env.get());
get_destination_types_for_error_helper.set_target_destination_type(destination_type_from_arg(env.get(), resolution_options.a_make));
@@ -823,6 +827,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_blocker_fn() = std::cref(get_destination_types_for_blocker_helper),
n::get_destination_types_for_error_fn() = std::cref(get_destination_types_for_error_helper),
n::get_initial_constraints_for_fn() = std::cref(get_initial_constraints_for_helper),
n::get_resolvents_for_fn() = std::cref(get_resolvents_for_helper),