aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2015-04-04 16:56:59 -0700
committerAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2015-04-19 14:21:48 -0700
commitcaf42043361d1e08ca5fa280b64c4542543239ac (patch)
tree9d442469535028429ac89bc7ae4a8c3d1235b17f
parent0349ecbb25833b419aee327bdf00de2d0103f8c2 (diff)
downloadpaludis-caf42043361d1e08ca5fa280b64c4542543239ac.tar.gz
paludis-caf42043361d1e08ca5fa280b64c4542543239ac.tar.xz
resolver: pull out some logic into a helper filter
Create a helper function to construct the installed id filter. This makes the code a bit easier to read since due to better wrapping.
-rw-r--r--paludis/resolver/get_resolvents_for_helper.cc28
1 files changed, 23 insertions, 5 deletions
diff --git a/paludis/resolver/get_resolvents_for_helper.cc b/paludis/resolver/get_resolvents_for_helper.cc
index f9e4319..226a1f1 100644
--- a/paludis/resolver/get_resolvents_for_helper.cc
+++ b/paludis/resolver/get_resolvents_for_helper.cc
@@ -261,6 +261,25 @@ namespace
n::has_version_requirements() = indeterminate
));
}
+
+ Filter generate_filter_for_destination(const Environment * const env,
+ const DestinationType & destination)
+ {
+ switch (destination)
+ {
+ case dt_install_to_chroot:
+ return filter::InstalledNotAtRoot(env->system_root_key()->parse_value());
+
+ case dt_create_binary:
+ case dt_install_to_slash:
+ return filter::InstalledAtRoot(env->system_root_key()->parse_value());
+
+ case last_dt:
+ break;
+ }
+
+ throw InternalError(PALUDIS_HERE, "unhandled dt");
+ }
}
std::pair<std::shared_ptr<const Resolvents>, bool>
@@ -300,11 +319,10 @@ GetResolventsForHelper::operator() (
if (! ids->empty())
best = *ids->begin();
- auto installed_ids(_imp->remove_hidden((*_imp->env)[selection::BestVersionInEachSlot(
- generator::Matches(spec, from_id, { }) |
- (_imp->target_destination_type == dt_install_to_chroot ?
- Filter(filter::InstalledNotAtRoot(_imp->env->system_root_key()->parse_value())) :
- Filter(filter::InstalledAtRoot(_imp->env->system_root_key()->parse_value()))))]));
+ auto matches = generator::Matches(spec, from_id, { });
+ auto filter = generate_filter_for_destination(_imp->env,
+ _imp->target_destination_type);
+ auto installed_ids(_imp->remove_hidden((*_imp->env)[selection::BestVersionInEachSlot(matches | filter)]));
if (! best)
std::copy(installed_ids->begin(), installed_ids->end(), result_ids->back_inserter());