aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-07 19:42:58 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-07 20:32:39 +0000
commit9902ccae43ee3c54fd7c05154f5d41fb8392c69c (patch)
tree96c00304dfd1bf54cc8df89dd1bd14fe31a49382
parentdcdf18dbadfd9ab32a0b44173650ad877b1f2185 (diff)
downloadpaludis-9902ccae43ee3c54fd7c05154f5d41fb8392c69c.tar.gz
paludis-9902ccae43ee3c54fd7c05154f5d41fb8392c69c.tar.xz
Allow unsafe uninstalls
-rw-r--r--paludis/resolver/decider.cc11
-rw-r--r--paludis/resolver/decider.hh2
-rw-r--r--paludis/resolver/resolver_functions.hh6
-rw-r--r--paludis/resolver/resolver_test.cc11
-rw-r--r--paludis/resolver/resolver_test.hh5
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.cc10
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.hh3
-rw-r--r--src/clients/cave/resolve_common.cc25
8 files changed, 68 insertions, 5 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 6147adb..09fc9af 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -160,6 +160,11 @@ Decider::_resolve_dependents()
for (PackageIDSequence::ConstIterator s(staying->begin()), s_end(staying->end()) ;
s != s_end ; ++s)
{
+ _imp->env->trigger_notifier_callback(NotifierCallbackResolverStepEvent());
+
+ if (_allowed_to_break(*s))
+ continue;
+
if (! _dependent(*s, changing.first, changing.second))
continue;
@@ -1548,6 +1553,12 @@ Decider::_allowed_to_remove(const std::tr1::shared_ptr<const PackageID> & id) co
return id->supports_action(SupportsActionTest<UninstallAction>()) && _imp->fns.allowed_to_remove_fn()(id);
}
+bool
+Decider::_allowed_to_break(const std::tr1::shared_ptr<const PackageID> & id) const
+{
+ return _imp->fns.allowed_to_break_fn()(id);
+}
+
const std::tr1::shared_ptr<const PackageIDSequence>
Decider::_installed_ids(const Resolvent & resolvent) const
{
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index f19cfcc..e509d52 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -191,6 +191,8 @@ namespace paludis
bool _allowed_to_remove(const std::tr1::shared_ptr<const PackageID> &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ bool _allowed_to_break(const std::tr1::shared_ptr<const PackageID> &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
const std::pair<
std::tr1::shared_ptr<const PackageIDSequence>,
std::tr1::shared_ptr<const PackageIDSequence> > _collect_changing() const PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/resolver/resolver_functions.hh b/paludis/resolver/resolver_functions.hh
index e0028c3..7ef054b 100644
--- a/paludis/resolver/resolver_functions.hh
+++ b/paludis/resolver/resolver_functions.hh
@@ -40,6 +40,7 @@ namespace paludis
{
namespace n
{
+ struct allowed_to_break_fn;
struct allowed_to_remove_fn;
struct care_about_dep_fn;
struct confirm_fn;
@@ -57,6 +58,10 @@ namespace paludis
{
typedef std::tr1::function<bool (
const std::tr1::shared_ptr<const PackageID> &
+ )> AllowedToBreakFunction;
+
+ typedef std::tr1::function<bool (
+ const std::tr1::shared_ptr<const PackageID> &
)> AllowedToRemoveFunction;
typedef std::tr1::function<bool (
@@ -116,6 +121,7 @@ namespace paludis
struct ResolverFunctions
{
+ NamedValue<n::allowed_to_break_fn, AllowedToBreakFunction> allowed_to_break_fn;
NamedValue<n::allowed_to_remove_fn, AllowedToRemoveFunction> allowed_to_remove_fn;
NamedValue<n::care_about_dep_fn, CareAboutDepFunction> care_about_dep_fn;
NamedValue<n::confirm_fn, ConfirmFunction> confirm_fn;
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index d82eb95..506b2a5 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -246,6 +246,14 @@ paludis::resolver::resolver_test::find_repository_for_fn(
}
bool
+paludis::resolver::resolver_test::allowed_to_break_fn(
+ const std::tr1::shared_ptr<const QualifiedPackageNameSet> & s,
+ const std::tr1::shared_ptr<const PackageID> & i)
+{
+ return s->end() != s->find(i->name());
+}
+
+bool
paludis::resolver::resolver_test::allowed_to_remove_fn(
const std::tr1::shared_ptr<const QualifiedPackageNameSet> & s,
const std::tr1::shared_ptr<const PackageID> & i)
@@ -277,6 +285,7 @@ paludis::resolver::resolver_test::confirm_fn(
ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s, const std::string & e,
const std::string & l) :
TestCase(s),
+ allowed_to_break_names(new QualifiedPackageNameSet),
allowed_to_remove_names(new QualifiedPackageNameSet),
prefer_or_avoid_names(new Map<QualifiedPackageName, bool>)
{
@@ -324,6 +333,8 @@ ResolverFunctions
ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraints)
{
return make_named_values<ResolverFunctions>(
+ value_for<n::allowed_to_break_fn>(std::tr1::bind(&allowed_to_break_fn,
+ allowed_to_break_names, std::tr1::placeholders::_1)),
value_for<n::allowed_to_remove_fn>(std::tr1::bind(&allowed_to_remove_fn,
allowed_to_remove_names, std::tr1::placeholders::_1)),
value_for<n::care_about_dep_fn>(&care_about_dep_fn),
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 7e19693..a1c7c6e 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -91,6 +91,10 @@ namespace paludis
const std::tr1::shared_ptr<const PackageID> &,
const std::tr1::shared_ptr<const Reason> &);
+ bool allowed_to_break_fn(
+ const std::tr1::shared_ptr<const QualifiedPackageNameSet> &,
+ const std::tr1::shared_ptr<const PackageID> &);
+
bool allowed_to_remove_fn(
const std::tr1::shared_ptr<const QualifiedPackageNameSet> &,
const std::tr1::shared_ptr<const PackageID> &);
@@ -109,6 +113,7 @@ namespace paludis
TestEnvironment env;
std::tr1::shared_ptr<Repository> repo, inst_repo;
std::tr1::shared_ptr<FakeInstalledRepository> fake_inst_repo;
+ std::tr1::shared_ptr<QualifiedPackageNameSet> allowed_to_break_names;
std::tr1::shared_ptr<QualifiedPackageNameSet> allowed_to_remove_names;
std::tr1::shared_ptr<Map<QualifiedPackageName, bool> > prefer_or_avoid_names;
diff --git a/src/clients/cave/cmd_resolve_cmdline.cc b/src/clients/cave/cmd_resolve_cmdline.cc
index af0e31d..97385b3 100644
--- a/src/clients/cave/cmd_resolve_cmdline.cc
+++ b/src/clients/cave/cmd_resolve_cmdline.cc
@@ -66,9 +66,13 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
a_permit_any_version(&g_resolution_options, "permit-any-version", 'a', "Permit installs of versions matching the supplied "
"specification even if those versions are worse than the best visible version in the slot. Use '*/*' "
"to allow all worse versions to be installed."),
-// a_permit_unsafe_uninstall(&g_resolution_options, "permit-unsafe-uninstall", 'u',
-// "Permit uninstalls matching the given specification even if the uninstall isn't known to be safe. Use "
-// "'*/*' to allow all unsafe uninstalls. Note that this does not imply --permit-uninstall."),
+ a_uninstalls_may_break(&g_resolution_options, "uninstalls-may-break", 'u',
+ "Permit uninstalls that might break packages matching the specified specification. May be "
+ "specified multiple times. Use '*/*' to allow all packages to be broken."),
+// a_remove_if_dependent(&g_resolution_options, "remove-if-dependent", 'r',
+// "Remove dependent packages that might be broken by other changes if those packages match "
+// "the specified specification. May be specified multiple times. Use '*/*' to remove all "
+// "dependent packages that might be broken, recursively. Does not imply --permit-uninstall."),
// a_purge(&g_resolution_options, "purge", 'P',
// "Purge packages matching the given specification, if they will no longer be used after "
// "a resolution. Use '*/*' to accept all purges, but note that by doing so you are putting "
diff --git a/src/clients/cave/cmd_resolve_cmdline.hh b/src/clients/cave/cmd_resolve_cmdline.hh
index d0fd84e..eb85936 100644
--- a/src/clients/cave/cmd_resolve_cmdline.hh
+++ b/src/clients/cave/cmd_resolve_cmdline.hh
@@ -46,7 +46,8 @@ namespace paludis
args::StringSetArg a_permit_uninstall;
args::StringSetArg a_permit_downgrade;
args::StringSetArg a_permit_any_version;
-// args::StringSetArg a_permit_unsafe_uninstall;
+ args::StringSetArg a_uninstalls_may_break;
+// args::StringSetArg a_remove_if_dependent;
// args::StringSetArg a_purge;
args::ArgsGroup g_keep_options;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 3a7bac4..89d6b79 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -1031,6 +1031,19 @@ namespace
throw InternalError(PALUDIS_HERE, "unhandled dt");
}
+ bool allowed_to_break_fn(
+ const Environment * const env,
+ const PackageDepSpecList & list,
+ const std::tr1::shared_ptr<const PackageID> & i)
+ {
+ for (PackageDepSpecList::const_iterator l(list.begin()), l_end(list.end()) ;
+ l != l_end ; ++l)
+ if (match_package(*env, *l, *i, MatchPackageOptions()))
+ return true;
+
+ return false;
+ }
+
bool allowed_to_remove_fn(
const Environment * const env,
const PackageDepSpecList & list,
@@ -1397,7 +1410,7 @@ paludis::cave::resolve_common(
int retcode(0);
InitialConstraints initial_constraints;
- PackageDepSpecList allowed_to_remove_specs;
+ PackageDepSpecList allowed_to_remove_specs, allowed_to_break_specs;
for (args::StringSetArg::ConstIterator i(resolution_options.a_permit_uninstall.begin_args()),
i_end(resolution_options.a_permit_uninstall.end_args()) ;
@@ -1405,6 +1418,12 @@ paludis::cave::resolve_common(
allowed_to_remove_specs.push_back(parse_user_package_dep_spec(*i, env.get(),
UserPackageDepSpecOptions() + updso_allow_wildcards));
+ for (args::StringSetArg::ConstIterator i(resolution_options.a_uninstalls_may_break.begin_args()),
+ i_end(resolution_options.a_uninstalls_may_break.end_args()) ;
+ i != i_end ; ++i)
+ allowed_to_break_specs.push_back(parse_user_package_dep_spec(*i, env.get(),
+ UserPackageDepSpecOptions() + updso_allow_wildcards));
+
for (args::StringSetArg::ConstIterator i(resolution_options.a_preset.begin_args()),
i_end(resolution_options.a_preset.end_args()) ;
i != i_end ; ++i)
@@ -1435,6 +1454,10 @@ paludis::cave::resolve_common(
}
ResolverFunctions resolver_functions(make_named_values<ResolverFunctions>(
+ value_for<n::allowed_to_break_fn>(std::tr1::bind(&allowed_to_break_fn,
+ env.get(),
+ std::tr1::cref(allowed_to_break_specs),
+ std::tr1::placeholders::_1)),
value_for<n::allowed_to_remove_fn>(std::tr1::bind(&allowed_to_remove_fn,
env.get(),
std::tr1::cref(allowed_to_remove_specs),