aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-14 15:24:28 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-14 15:24:28 +0000
commit96f7b4bd29618d66f346fc18e38c3c53ecfe6210 (patch)
tree2f5f964b468322b425651be4d5e27a1ca9bc837c
parent978a2a4bbe25b12f4e6e7baa8632ca7c586b5452 (diff)
downloadpaludis-96f7b4bd29618d66f346fc18e38c3c53ecfe6210.tar.gz
paludis-96f7b4bd29618d66f346fc18e38c3c53ecfe6210.tar.xz
cave resolve --reinstall-dependents-of
-rw-r--r--src/clients/cave/resolve_cmdline.cc5
-rw-r--r--src/clients/cave/resolve_cmdline.hh1
-rw-r--r--src/clients/cave/resolve_common.cc35
3 files changed, 40 insertions, 1 deletions
diff --git a/src/clients/cave/resolve_cmdline.cc b/src/clients/cave/resolve_cmdline.cc
index 025a31d..2a107d7 100644
--- a/src/clients/cave/resolve_cmdline.cc
+++ b/src/clients/cave/resolve_cmdline.cc
@@ -105,6 +105,11 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
"matched by this option, the block will instead only block the installed dependent "
"package, so if reinstalling or upgrading the package will make it no longer be dependent "
"then this will be done instead."),
+ a_reinstall_dependents_of(&g_dependent_options, "reinstall-dependents-of", '\0', /* todo: 'D' */
+ "Force any installed package that is dependent upon any installed package matching the "
+ "supplied spec to be reinstalled. May be specified multiple times. May be combined with "
+ "--not-usable to obtain a particular ordering. Note that a target must still be specified "
+ "if this option is used, so the 'nothing' set may be helpful."),
g_keep_options(this, "Reinstall Options", "Control whether installed packages are kept."),
a_keep_targets(&g_keep_options, "keep-targets", 'K',
diff --git a/src/clients/cave/resolve_cmdline.hh b/src/clients/cave/resolve_cmdline.hh
index 6d06bc4..8ee7b02 100644
--- a/src/clients/cave/resolve_cmdline.hh
+++ b/src/clients/cave/resolve_cmdline.hh
@@ -56,6 +56,7 @@ namespace paludis
args::StringSetArg a_uninstalls_may_break;
args::StringSetArg a_remove_if_dependent;
args::StringSetArg a_less_restrictive_remove_blockers;
+ args::StringSetArg a_reinstall_dependents_of;
args::ArgsGroup g_keep_options;
args::EnumArg a_keep_targets;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 00d2e43..df6193d 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -68,6 +68,7 @@
#include <paludis/resolver/resolutions_by_resolvent.hh>
#include <paludis/resolver/required_confirmations.hh>
#include <paludis/resolver/make_uninstall_blocker.hh>
+#include <paludis/resolver/collect_depped_upon.hh>
#include <paludis/resolver/allow_choice_changes_helper.hh>
#include <paludis/resolver/allowed_to_remove_helper.hh>
@@ -102,6 +103,9 @@
#include <paludis/filtered_generator.hh>
#include <paludis/metadata_key.hh>
#include <paludis/package_database.hh>
+#include <paludis/filter.hh>
+#include <paludis/generator.hh>
+#include <paludis/selection.hh>
#include <algorithm>
#include <iostream>
@@ -123,7 +127,7 @@ namespace
const std::shared_ptr<const Sequence<std::string> > add_resolver_targets(
const std::shared_ptr<Environment> & env,
const std::shared_ptr<Resolver> & resolver,
- const ResolveCommandLineResolutionOptions &,
+ const ResolveCommandLineResolutionOptions & resolution_options,
const std::shared_ptr<const Sequence<std::pair<std::string, std::string> > > & targets,
bool & is_set)
{
@@ -178,6 +182,35 @@ namespace
if (seen_sets)
is_set = true;
+ if (resolution_options.a_reinstall_dependents_of.specified())
+ {
+ auto installed_filter(filter::InstalledAtRoot(env->system_root_key()->value()));
+ auto installed_ids((*env)[selection::AllVersionsSorted(
+ generator::All() |
+ installed_filter)]);
+
+ for (auto p(resolution_options.a_reinstall_dependents_of.begin_args()), p_end(resolution_options.a_reinstall_dependents_of.end_args()) ;
+ p != p_end ; ++p)
+ {
+ PackageDepSpec s(parse_spec_with_nice_error(*p, env.get(), { }, installed_filter));
+ auto ids((*env)[selection::AllVersionsSorted(generator::Matches(s, make_null_shared_ptr(), { }) | installed_filter)]);
+ if (ids->empty())
+ throw args::DoHelp("Found nothing installed matching '" + *p + "' for --" + resolution_options.a_reinstall_dependents_of.long_name());
+
+ for (auto i(ids->begin()), i_end(ids->end()) ;
+ i != i_end ; ++i)
+ {
+ auto dependents(collect_depped_upon(env.get(), *i, installed_ids, make_null_shared_ptr()));
+ for (auto d(dependents->begin()), d_end(dependents->end()) ;
+ d != d_end ; ++d)
+ {
+ BlockDepSpec bs(make_uninstall_blocker((*d)->uniquely_identifying_spec()));
+ resolver->add_target(bs, "reinstalling dependents of " + stringify(s));
+ }
+ }
+ }
+ }
+
return result;
}