aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-20 14:40:25 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-20 14:40:25 +0000
commit1f936074e41630e9ef74da29983ea78a259d5a9d (patch)
tree7bf1efc464cdadb83522cbd09f3b1aa341307a49
parent880aa65f4cdc0d583e54225ae3d1d6b52ebe79b6 (diff)
downloadpaludis-1f936074e41630e9ef74da29983ea78a259d5a9d.tar.gz
paludis-1f936074e41630e9ef74da29983ea78a259d5a9d.tar.xz
resolve --with/--without
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.cc6
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.hh2
-rw-r--r--src/clients/cave/resolve_common.cc52
3 files changed, 56 insertions, 4 deletions
diff --git a/src/clients/cave/cmd_resolve_cmdline.cc b/src/clients/cave/cmd_resolve_cmdline.cc
index be65e04..b965322 100644
--- a/src/clients/cave/cmd_resolve_cmdline.cc
+++ b/src/clients/cave/cmd_resolve_cmdline.cc
@@ -108,6 +108,12 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
),
// a_reinstall_for_removals(&g_keep_options, "reinstall-for-removals", '\0',
// "Select whether to rebuild packages if rebuilding would avoid an unsafe removal", true),
+ a_with(&g_keep_options, "with", 'w',
+ "Never keep installed packages with the supplied package name. May be specified "
+ "multiple times."),
+ a_without(&g_keep_options, "without", 'W',
+ "Keep installed packages with the supplied package name if possible. May be specified "
+ "multiple times."),
g_slot_options(this, "Slot Options", "Control which slots are considered."),
a_target_slots(&g_slot_options, "target-slots", 'S',
diff --git a/src/clients/cave/cmd_resolve_cmdline.hh b/src/clients/cave/cmd_resolve_cmdline.hh
index 5bcbd76..a59fdc2 100644
--- a/src/clients/cave/cmd_resolve_cmdline.hh
+++ b/src/clients/cave/cmd_resolve_cmdline.hh
@@ -53,6 +53,8 @@ namespace paludis
args::EnumArg a_keep;
args::EnumArg a_reinstall_scm;
// args::SwitchArg a_reinstall_for_removals;
+ args::StringSetArg a_with;
+ args::StringSetArg a_without;
args::ArgsGroup g_slot_options;
args::EnumArg a_target_slots;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 9ff647d..6f96b52 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -521,11 +521,53 @@ namespace
}
};
- UseExisting use_existing_fn(const ResolveCommandLineResolutionOptions & resolution_options,
+ bool use_existing_from_withish(
+ const Environment * const env,
+ const QualifiedPackageName & name,
+ const args::StringSetArg & option)
+ {
+ for (args::StringSetArg::ConstIterator a(option.begin_args()), a_end(option.end_args()) ;
+ a != a_end ; ++a)
+ {
+ PackageDepSpec spec(parse_user_package_dep_spec(*a, env, UserPackageDepSpecOptions() + updso_allow_wildcards));
+ if (! package_dep_spec_has_properties(spec, make_named_values<PackageDepSpecProperties>(
+ value_for<n::has_additional_requirements>(false),
+ value_for<n::has_category_name_part>(false),
+ value_for<n::has_from_repository>(false),
+ value_for<n::has_in_repository>(false),
+ value_for<n::has_installable_to_path>(false),
+ value_for<n::has_installable_to_repository>(false),
+ value_for<n::has_installed_at_path>(false),
+ value_for<n::has_package>(true),
+ value_for<n::has_package_name_part>(false),
+ value_for<n::has_slot_requirement>(false),
+ value_for<n::has_tag>(indeterminate),
+ value_for<n::has_version_requirements>(false)
+ )))
+ throw args::DoHelp("'" + stringify(*a) + "' is not a simple cat/pkg");
+
+ if (name == *spec.package_ptr())
+ return true;
+ }
+
+ return false;
+ }
+
+ UseExisting use_existing_fn(
+ const Environment * const env,
+ const ResolveCommandLineResolutionOptions & resolution_options,
const Resolvent &,
- const PackageDepSpec &,
+ const PackageDepSpec & spec,
const std::tr1::shared_ptr<const Reason> & reason)
{
+ if (spec.package_ptr())
+ {
+ if (use_existing_from_withish(env, *spec.package_ptr(), resolution_options.a_without))
+ return ue_if_possible;
+ if (use_existing_from_withish(env, *spec.package_ptr(), resolution_options.a_with))
+ return ue_never;
+ }
+
UseExistingVisitor v(resolution_options, false);
return reason->accept_returning<UseExisting>(v);
}
@@ -616,7 +658,8 @@ namespace
const std::tr1::shared_ptr<Constraints> result(new Constraints);
int n(reinstall_scm_days(resolution_options));
- if ((-1 != n) && installed_is_scm_older_than(env, resolution_options, resolvent, n))
+ if ((-1 != n) && installed_is_scm_older_than(env, resolution_options, resolvent, n)
+ && ! use_existing_from_withish(env, resolvent.package(), resolution_options.a_without))
{
result->add(make_shared_ptr(new Constraint(make_named_values<Constraint>(
value_for<n::destination_type>(resolvent.destination_type()),
@@ -1352,7 +1395,8 @@ paludis::cave::resolve_common(
env.get(), std::tr1::cref(resolution_options), std::tr1::placeholders::_1, std::tr1::placeholders::_2,
std::tr1::placeholders::_3)),
value_for<n::get_use_existing_fn>(std::tr1::bind(&use_existing_fn,
- std::tr1::cref(resolution_options), std::tr1::placeholders::_1, std::tr1::placeholders::_2, std::tr1::placeholders::_3)),
+ env.get(), std::tr1::cref(resolution_options), std::tr1::placeholders::_1, std::tr1::placeholders::_2,
+ std::tr1::placeholders::_3)),
value_for<n::make_destination_filtered_generator_fn>(std::tr1::bind(&make_destination_filtered_generator,
env.get(), std::tr1::cref(resolution_options), std::tr1::placeholders::_1, std::tr1::placeholders::_2)),
value_for<n::prefer_or_avoid_fn>(std::tr1::bind(&prefer_or_avoid_fn,