aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-02-11 16:08:01 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-02-12 17:51:32 +0000
commit87f29afaa3af247218b283c721bb7a2aeb4bbc07 (patch)
tree1e21159fd82ba57fc815e6667aac9612fbc0e3fd
parent7704ad228a1249b4a92961ccca117f0d68f4f36e (diff)
downloadpaludis-87f29afaa3af247218b283c721bb7a2aeb4bbc07.tar.gz
paludis-87f29afaa3af247218b283c721bb7a2aeb4bbc07.tar.xz
cave resolve --no-restarts-for
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/allowed_to_restart_helper-fwd.hh31
-rw-r--r--paludis/resolver/allowed_to_restart_helper.cc78
-rw-r--r--paludis/resolver/allowed_to_restart_helper.hh50
-rw-r--r--paludis/resolver/decider.cc24
-rw-r--r--paludis/resolver/decider.hh3
-rw-r--r--paludis/resolver/resolver_functions.hh6
-rw-r--r--paludis/resolver/resolver_test.cc2
-rw-r--r--paludis/resolver/resolver_test.hh2
-rw-r--r--src/clients/cave/resolve_cmdline.cc3
-rw-r--r--src/clients/cave/resolve_cmdline.hh3
-rw-r--r--src/clients/cave/resolve_common.cc8
12 files changed, 205 insertions, 7 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 4e1d6ef..2ff0082 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -31,6 +31,7 @@ noinst_HEADERS = \
accumulate_deps_and_provides.hh accumulate_deps_and_provides-fwd.hh \
allow_choice_changes_helper.hh allow_choice_changes_helper-fwd.hh \
allowed_to_remove_helper.hh allowed_to_remove_helper-fwd.hh \
+ allowed_to_restart_helper.hh allowed_to_restart_helper-fwd.hh \
always_via_binary_helper.hh always_via_binary_helper-fwd.hh \
any_child_score.hh any_child_score-fwd.hh any_child_score-se.hh \
can_use_helper.hh can_use_helper-fwd.hh \
@@ -101,6 +102,7 @@ libpaludisresolver_a_SOURCES = \
accumulate_deps_and_provides.cc \
allow_choice_changes_helper.cc \
allowed_to_remove_helper.cc \
+ allowed_to_restart_helper.cc \
always_via_binary_helper.cc \
any_child_score.cc \
can_use_helper.cc \
diff --git a/paludis/resolver/allowed_to_restart_helper-fwd.hh b/paludis/resolver/allowed_to_restart_helper-fwd.hh
new file mode 100644
index 0000000..9dfd442
--- /dev/null
+++ b/paludis/resolver/allowed_to_restart_helper-fwd.hh
@@ -0,0 +1,31 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_ALLOWED_TO_RESTART_HELPER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_ALLOWED_TO_RESTART_HELPER_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct AllowedToRestartHelper;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/allowed_to_restart_helper.cc b/paludis/resolver/allowed_to_restart_helper.cc
new file mode 100644
index 0000000..80b6d59
--- /dev/null
+++ b/paludis/resolver/allowed_to_restart_helper.cc
@@ -0,0 +1,78 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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/resolver/allowed_to_restart_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_utils-fwd.hh>
+#include <paludis/util/pimp-impl.hh>
+#include <paludis/util/make_null_shared_ptr.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/package_dep_spec_collection.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace paludis
+{
+ template <>
+ struct Imp<AllowedToRestartHelper>
+ {
+ const Environment * const env;
+ PackageDepSpecCollection no_restarts_for_specs;
+
+ Imp(const Environment * const e) :
+ env(e),
+ no_restarts_for_specs(make_null_shared_ptr())
+ {
+ }
+ };
+}
+
+AllowedToRestartHelper::AllowedToRestartHelper(const Environment * const e) :
+ _imp(e)
+{
+}
+
+AllowedToRestartHelper::~AllowedToRestartHelper() = default;
+
+void
+AllowedToRestartHelper::add_no_restarts_for_spec(const PackageDepSpec & spec)
+{
+ _imp->no_restarts_for_specs.insert(spec);
+}
+
+bool
+AllowedToRestartHelper::operator() (
+ const std::shared_ptr<const Resolution> & resolution) const
+{
+ if (! resolution->decision())
+ return true;
+
+ auto id(get_decided_id_or_null(resolution->decision()));
+ if (! id)
+ return true;
+
+ return ! _imp->no_restarts_for_specs.match_any(_imp->env, id, { });
+}
+
+template class Pimp<AllowedToRestartHelper>;
+
diff --git a/paludis/resolver/allowed_to_restart_helper.hh b/paludis/resolver/allowed_to_restart_helper.hh
new file mode 100644
index 0000000..8226e5a
--- /dev/null
+++ b/paludis/resolver/allowed_to_restart_helper.hh
@@ -0,0 +1,50 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_ALLOWED_TO_RESTART_HELPER_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_ALLOWED_TO_RESTART_HELPER_HH 1
+
+#include <paludis/resolver/allowed_to_restart_helper-fwd.hh>
+#include <paludis/resolver/resolution-fwd.hh>
+#include <paludis/util/pimp.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/dep_spec-fwd.hh>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE AllowedToRestartHelper
+ {
+ private:
+ Pimp<AllowedToRestartHelper> _imp;
+
+ public:
+ explicit AllowedToRestartHelper(const Environment * const);
+ ~AllowedToRestartHelper();
+
+ void add_no_restarts_for_spec(const PackageDepSpec &);
+
+ bool operator() (
+ const std::shared_ptr<const Resolution> &) const;
+ };
+ }
+}
+
+#endif
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 1c0d17c..afc9907 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -998,13 +998,18 @@ Decider::_made_wrong_decision(
std::shared_ptr<Resolution> adapted_resolution(std::make_shared<Resolution>(*resolution));
adapted_resolution->constraints()->add(constraint);
- const std::shared_ptr<Decision> decision(_try_to_find_decision_for(
- adapted_resolution, _allow_choice_changes_for(resolution), false, true, false, true));
- if (decision)
+ if (_allowed_to_restart(adapted_resolution))
{
- resolution->decision()->accept(WrongDecisionVisitor(std::bind(
- &Decider::_suggest_restart_with, this, resolution, constraint, decision)));
- resolution->decision() = decision;
+ const std::shared_ptr<Decision> decision(_try_to_find_decision_for(
+ adapted_resolution, _allow_choice_changes_for(resolution), false, true, false, true));
+ if (decision)
+ {
+ resolution->decision()->accept(WrongDecisionVisitor(std::bind(
+ &Decider::_suggest_restart_with, this, resolution, constraint, decision)));
+ resolution->decision() = decision;
+ }
+ else
+ resolution->decision() = _cannot_decide_for(adapted_resolution);
}
else
resolution->decision() = _cannot_decide_for(adapted_resolution);
@@ -1020,6 +1025,13 @@ Decider::_suggest_restart_with(
_make_constraint_for_preloading(decision, constraint));
}
+bool
+Decider::_allowed_to_restart(
+ const std::shared_ptr<const Resolution> & resolution) const
+{
+ return _imp->fns.allowed_to_restart_fn()(resolution);
+}
+
const std::shared_ptr<const Constraint>
Decider::_make_constraint_for_preloading(
const std::shared_ptr<const Decision> & decision,
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index d7d9e09..cef1f3a 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -141,6 +141,9 @@ namespace paludis
const std::shared_ptr<Resolution> & resolution,
const std::shared_ptr<const Constraint> & constraint);
+ bool _allowed_to_restart(
+ const std::shared_ptr<const Resolution> &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
void _suggest_restart_with(
const std::shared_ptr<const Resolution> & resolution,
const std::shared_ptr<const Constraint> & constraint,
diff --git a/paludis/resolver/resolver_functions.hh b/paludis/resolver/resolver_functions.hh
index 4a286e0..4a835b6 100644
--- a/paludis/resolver/resolver_functions.hh
+++ b/paludis/resolver/resolver_functions.hh
@@ -48,6 +48,7 @@ namespace paludis
{
typedef Name<struct name_allow_choice_changes_fn> allow_choice_changes_fn;
typedef Name<struct name_allowed_to_remove_fn> allowed_to_remove_fn;
+ typedef Name<struct name_allowed_to_restart_fn> allowed_to_restart_fn;
typedef Name<struct name_always_via_binary_fn> always_via_binary_fn;
typedef Name<struct name_can_use_fn> can_use_fn;
typedef Name<struct name_confirm_fn> confirm_fn;
@@ -83,6 +84,10 @@ namespace paludis
typedef std::function<bool (
const std::shared_ptr<const Resolution> &
+ )> AllowedToRestartFunction;
+
+ typedef std::function<bool (
+ const std::shared_ptr<const Resolution> &
)> AlwaysViaBinaryFunction;
typedef std::function<bool (
@@ -183,6 +188,7 @@ namespace paludis
{
NamedValue<n::allow_choice_changes_fn, AllowChoiceChangesFunction> allow_choice_changes_fn;
NamedValue<n::allowed_to_remove_fn, AllowedToRemoveFunction> allowed_to_remove_fn;
+ NamedValue<n::allowed_to_restart_fn, AllowedToRestartFunction> allowed_to_restart_fn;
NamedValue<n::always_via_binary_fn, AlwaysViaBinaryFunction> always_via_binary_fn;
NamedValue<n::can_use_fn, CanUseFunction> can_use_fn;
NamedValue<n::confirm_fn, ConfirmFunction> confirm_fn;
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 7af43d3..d6811f7 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -103,6 +103,7 @@ ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s,
TestCase(s),
allow_choice_changes_helper(&env),
allowed_to_remove_helper(&env),
+ allowed_to_restart_helper(&env),
always_via_binary_helper(&env),
can_use_helper(&env),
confirm_helper(&env),
@@ -175,6 +176,7 @@ ResolverTestCase::get_resolver_functions()
return 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),
+ n::allowed_to_restart_fn() = std::cref(allowed_to_restart_helper),
n::always_via_binary_fn() = std::cref(always_via_binary_helper),
n::can_use_fn() = std::cref(can_use_helper),
n::confirm_fn() = std::cref(confirm_helper),
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index c34dd79..8fc380d 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -37,6 +37,7 @@
#include <paludis/resolver/allow_choice_changes_helper.hh>
#include <paludis/resolver/allowed_to_remove_helper.hh>
+#include <paludis/resolver/allowed_to_restart_helper.hh>
#include <paludis/resolver/always_via_binary_helper.hh>
#include <paludis/resolver/can_use_helper.hh>
#include <paludis/resolver/confirm_helper.hh>
@@ -93,6 +94,7 @@ namespace paludis
AllowChoiceChangesHelper allow_choice_changes_helper;
AllowedToRemoveHelper allowed_to_remove_helper;
+ AllowedToRestartHelper allowed_to_restart_helper;
AlwaysViaBinaryHelper always_via_binary_helper;
CanUseHelper can_use_helper;
ConfirmHelper confirm_helper;
diff --git a/src/clients/cave/resolve_cmdline.cc b/src/clients/cave/resolve_cmdline.cc
index c255b57..8a5ae04 100644
--- a/src/clients/cave/resolve_cmdline.cc
+++ b/src/clients/cave/resolve_cmdline.cc
@@ -82,6 +82,9 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
"If otherwise unable to make a decision, unless this option is specified the resolver "
"will try selecting packages using different options to the ones specified in the user's "
"configuration.", true),
+ a_no_restarts_for(&g_resolution_options, "no-restarts-for", '\0',
+ "Do not restart if the problematic package has the specified package name. May be specified "
+ "multiple times. Use '*/*' to avoid all restarts."),
g_dependent_options(this, "Dependent Options", "Dependent options. A package is dependent if it "
"requires (or looks like it might require) a package which is being removed. By default, "
diff --git a/src/clients/cave/resolve_cmdline.hh b/src/clients/cave/resolve_cmdline.hh
index a25b447..082e561 100644
--- a/src/clients/cave/resolve_cmdline.hh
+++ b/src/clients/cave/resolve_cmdline.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009, 2010 Ciaran McCreesh
+ * Copyright (c) 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
@@ -50,6 +50,7 @@ namespace paludis
args::StringSetArg a_purge;
args::SwitchArg a_no_override_masks;
args::SwitchArg a_no_override_flags;
+ args::StringSetArg a_no_restarts_for;
args::ArgsGroup g_dependent_options;
args::StringSetArg a_uninstalls_may_break;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 37257b3..747305b 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -70,6 +70,7 @@
#include <paludis/resolver/allow_choice_changes_helper.hh>
#include <paludis/resolver/allowed_to_remove_helper.hh>
+#include <paludis/resolver/allowed_to_restart_helper.hh>
#include <paludis/resolver/always_via_binary_helper.hh>
#include <paludis/resolver/can_use_helper.hh>
#include <paludis/resolver/confirm_helper.hh>
@@ -723,6 +724,12 @@ paludis::cave::resolve_common(
i != i_end ; ++i)
allowed_to_remove_helper.add_allowed_to_remove_spec(parse_spec_with_nice_error(*i, env.get(), { updso_allow_wildcards }, filter::All()));
+ AllowedToRestartHelper allowed_to_restart_helper(env.get());
+ for (args::StringSetArg::ConstIterator i(resolution_options.a_no_restarts_for.begin_args()),
+ i_end(resolution_options.a_no_restarts_for.end_args()) ;
+ i != i_end ; ++i)
+ allowed_to_restart_helper.add_no_restarts_for_spec(parse_spec_with_nice_error(*i, env.get(), { updso_allow_wildcards }, filter::All()));
+
AlwaysViaBinaryHelper always_via_binary_helper(env.get());
for (args::StringSetArg::ConstIterator i(resolution_options.a_via_binary.begin_args()),
i_end(resolution_options.a_via_binary.end_args()) ;
@@ -1020,6 +1027,7 @@ paludis::cave::resolve_common(
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),
+ n::allowed_to_restart_fn() = std::cref(allowed_to_restart_helper),
n::always_via_binary_fn() = std::cref(always_via_binary_helper),
n::can_use_fn() = std::cref(can_use_helper),
n::confirm_fn() = std::cref(confirm_helper),