aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-22 12:56:12 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-22 12:56:36 +0000
commit1107ba9193a7f42af55c208f1fce35a231b1fd59 (patch)
tree322a90ca28dafa1e6ec4fc0c09f886aa4a8790d1
parentd44bbc7dc3aedaf9b3afe8605c98e8222d780823 (diff)
downloadpaludis-1107ba9193a7f42af55c208f1fce35a231b1fd59.tar.gz
paludis-1107ba9193a7f42af55c208f1fce35a231b1fd59.tar.xz
Require confirmation for downgrades and not best
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.cc7
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.hh3
-rw-r--r--src/clients/cave/resolve_common.cc115
3 files changed, 89 insertions, 36 deletions
diff --git a/src/clients/cave/cmd_resolve_cmdline.cc b/src/clients/cave/cmd_resolve_cmdline.cc
index b965322..af0e31d 100644
--- a/src/clients/cave/cmd_resolve_cmdline.cc
+++ b/src/clients/cave/cmd_resolve_cmdline.cc
@@ -61,8 +61,11 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
"blockers. May be specified multiple times. Use '*/*' to allow all uninstalls, but note "
"that the resolver will sometimes come up with extremely bad solutions to fixing blocks "
"and may suggest stupid and dangerous uninstalls."),
-// a_permit_downgrade(&g_resolution_options, "permit-downgrade", 'd', "Permit downgrades matching the supplied "
-// "specification. Use '*/*' to allow all downgrades."),
+ a_permit_downgrade(&g_resolution_options, "permit-downgrade", 'd', "Permit downgrades matching the supplied "
+ "specification. Use '*/*' to allow all downgrades."),
+ 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."),
diff --git a/src/clients/cave/cmd_resolve_cmdline.hh b/src/clients/cave/cmd_resolve_cmdline.hh
index a59fdc2..d0fd84e 100644
--- a/src/clients/cave/cmd_resolve_cmdline.hh
+++ b/src/clients/cave/cmd_resolve_cmdline.hh
@@ -44,7 +44,8 @@ namespace paludis
args::ArgsGroup g_resolution_options;
// args::SwitchArg a_permit_older_slot_uninstalls;
args::StringSetArg a_permit_uninstall;
-// args::StringSetArg a_permit_downgrade;
+ args::StringSetArg a_permit_downgrade;
+ args::StringSetArg a_permit_any_version;
// args::StringSetArg a_permit_unsafe_uninstall;
// args::StringSetArg a_purge;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index ea01c6d..3a7bac4 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -51,6 +51,7 @@
#include <paludis/resolver/sanitised_dependencies.hh>
#include <paludis/resolver/resolutions.hh>
#include <paludis/resolver/resolver_lists.hh>
+#include <paludis/resolver/required_confirmations.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/notifier_callback.hh>
#include <paludis/generator.hh>
@@ -1080,14 +1081,90 @@ namespace
return indeterminate;
}
+ struct ChosenIDVisitor
+ {
+ const std::tr1::shared_ptr<const PackageID> visit(const ChangesToMakeDecision & decision) const
+ {
+ return decision.origin_id();
+ }
+
+ const std::tr1::shared_ptr<const PackageID> visit(const ExistingNoChangeDecision & decision) const
+ {
+ return decision.existing_id();
+ }
+
+ const std::tr1::shared_ptr<const PackageID> visit(const NothingNoChangeDecision &) const
+ {
+ return make_null_shared_ptr();
+ }
+
+ const std::tr1::shared_ptr<const PackageID> visit(const RemoveDecision &) const
+ {
+ return make_null_shared_ptr();
+ }
+
+ const std::tr1::shared_ptr<const PackageID> visit(const UnableToMakeDecision &) const
+ {
+ return make_null_shared_ptr();
+ }
+ };
+
+ struct ConfirmFnVisitor
+ {
+ const Environment * const env;
+ const ResolveCommandLineResolutionOptions & resolution_options;
+ const std::tr1::shared_ptr<const PackageID> id;
+
+ ConfirmFnVisitor(const Environment * const e,
+ const ResolveCommandLineResolutionOptions & r,
+ const std::tr1::shared_ptr<const PackageID> & i) :
+ env(e),
+ resolution_options(r),
+ id(i)
+ {
+ }
+
+ bool visit(const DowngradeConfirmation &) const
+ {
+ if (id)
+ for (args::StringSetArg::ConstIterator a(resolution_options.a_permit_downgrade.begin_args()),
+ a_end(resolution_options.a_permit_downgrade.end_args()) ;
+ a != a_end ; ++a)
+ {
+ PackageDepSpec spec(parse_user_package_dep_spec(*a, env, UserPackageDepSpecOptions() + updso_allow_wildcards));
+ if (match_package(*env, spec, *id, MatchPackageOptions()))
+ return true;
+ }
+
+ return false;
+ }
+
+ bool visit(const NotBestConfirmation &) const
+ {
+ if (id)
+ for (args::StringSetArg::ConstIterator a(resolution_options.a_permit_any_version.begin_args()),
+ a_end(resolution_options.a_permit_any_version.end_args()) ;
+ a != a_end ; ++a)
+ {
+ PackageDepSpec spec(parse_user_package_dep_spec(*a, env, UserPackageDepSpecOptions() + updso_allow_wildcards));
+ if (match_package(*env, spec, *id, MatchPackageOptions()))
+ return true;
+ }
+
+ return false;
+ }
+ };
+
bool confirm_fn(
- const Environment * const,
- const ResolveCommandLineResolutionOptions &,
+ const Environment * const env,
+ const ResolveCommandLineResolutionOptions & resolution_options,
const Resolvent &,
- const std::tr1::shared_ptr<const Resolution> &,
- const std::tr1::shared_ptr<const RequiredConfirmation> &)
+ const std::tr1::shared_ptr<const Resolution> & r,
+ const std::tr1::shared_ptr<const RequiredConfirmation> & c)
{
- return false;
+ return c->accept_returning<bool>(ConfirmFnVisitor(env, resolution_options,
+ r->decision()->accept_returning<std::tr1::shared_ptr<const PackageID> >(ChosenIDVisitor())
+ ));
}
void ser_thread_func(StringListStream & ser_stream, const ResolverLists & resolution_lists)
@@ -1246,34 +1323,6 @@ namespace
return ExecuteResolutionCommand().run(env, args, resolution_lists);
}
- struct ChosenIDVisitor
- {
- const std::tr1::shared_ptr<const PackageID> visit(const ChangesToMakeDecision & decision) const
- {
- return decision.origin_id();
- }
-
- const std::tr1::shared_ptr<const PackageID> visit(const ExistingNoChangeDecision & decision) const
- {
- return decision.existing_id();
- }
-
- const std::tr1::shared_ptr<const PackageID> visit(const NothingNoChangeDecision &) const
- {
- return make_null_shared_ptr();
- }
-
- const std::tr1::shared_ptr<const PackageID> visit(const RemoveDecision &) const
- {
- return make_null_shared_ptr();
- }
-
- const std::tr1::shared_ptr<const PackageID> visit(const UnableToMakeDecision &) const
- {
- return make_null_shared_ptr();
- }
- };
-
struct KindNameVisitor
{
const std::string visit(const RemoveDecision &) const