aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-10-17 16:42:25 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-10-17 16:42:25 +0100
commit207326c91fa5ad7b74993299eec54608ca1ae93b (patch)
tree21c48151968a760e233170f1918e63ae497b28fb
parent94257d3c2335ce1ccadf5c2d73f42a4bc67e96c3 (diff)
downloadpaludis-207326c91fa5ad7b74993299eec54608ca1ae93b.tar.gz
paludis-207326c91fa5ad7b74993299eec54608ca1ae93b.tar.xz
cave resolve --dependencies-to-slash
Fixes: ticket:994
-rw-r--r--paludis/resolver/decider.cc36
-rw-r--r--paludis/resolver/decider.hh2
-rw-r--r--paludis/resolver/get_resolvents_for_helper.cc68
-rw-r--r--paludis/resolver/get_resolvents_for_helper.hh5
-rw-r--r--paludis/resolver/resolver_functions.hh2
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.cc9
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.hh1
-rw-r--r--src/clients/cave/resolve_common.cc24
8 files changed, 110 insertions, 37 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index d68c3a9..bcbe09c 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -1211,22 +1211,18 @@ Decider::_add_dependencies_if_necessary(
const std::shared_ptr<DependencyReason> reason(std::make_shared<DependencyReason>(
package_id, changed_choices, our_resolution->resolvent(), *s, _already_met(s->spec())));
+ /* empty resolvents is always ok for blockers, since blocking on things
+ * that don't exist is fine */
+ bool empty_is_ok(s->spec().if_block());
std::shared_ptr<const Resolvents> resolvents;
if (s->spec().if_package())
- resolvents = _get_resolvents_for(*s->spec().if_package(), reason);
+ std::tie(resolvents, empty_is_ok) = _get_resolvents_for(*s->spec().if_package(), reason);
else
resolvents = _get_resolvents_for_blocker(*s->spec().if_block(), reason);
- if (resolvents->empty())
- {
- if (s->spec().if_package())
- resolvents = _get_error_resolvents_for(*s->spec().if_package(), reason);
- else
- {
- /* blocking on something that doesn't exist is fine */
- }
- }
+ if ((! empty_is_ok) && resolvents->empty())
+ resolvents = _get_error_resolvents_for(*s->spec().if_package(), reason);
for (Resolvents::ConstIterator r(resolvents->begin()), r_end(resolvents->end()) ;
r != r_end ; ++r)
@@ -1371,7 +1367,7 @@ Decider::find_any_score(
const std::shared_ptr<DependencyReason> reason(std::make_shared<DependencyReason>(
our_id, make_null_shared_ptr(), our_resolution->resolvent(), dep, _already_met(dep.spec())));
- const std::shared_ptr<const Resolvents> resolvents(_get_resolvents_for(spec, reason));
+ const std::shared_ptr<const Resolvents> resolvents(_get_resolvents_for(spec, reason).first);
/* next: will already be installing */
if (! is_block)
@@ -1491,7 +1487,7 @@ Decider::_get_destination_types_for_blocker(const BlockDepSpec & spec,
return _imp->fns.get_destination_types_for_blocker_fn()(spec, reason);
}
-const std::shared_ptr<const Resolvents>
+const std::pair<std::shared_ptr<const Resolvents>, bool>
Decider::_get_resolvents_for(
const PackageDepSpec & spec,
const std::shared_ptr<const Reason> & reason) const
@@ -2005,22 +2001,18 @@ Decider::add_target_with_reason(const PackageOrBlockDepSpec & spec, const std::s
}
else
{
+ /* empty resolvents is always ok for blockers, since blocking on things
+ * that don't exist is fine */
+ bool empty_is_ok(spec.if_block());
std::shared_ptr<const Resolvents> resolvents;
if (spec.if_package())
- resolvents = _get_resolvents_for(*spec.if_package(), reason);
+ std::tie(resolvents, empty_is_ok) = _get_resolvents_for(*spec.if_package(), reason);
else
resolvents = _get_resolvents_for_blocker(*spec.if_block(), reason);
- if (resolvents->empty())
- {
- if (spec.if_package())
- resolvents = _get_error_resolvents_for(*spec.if_package(), reason);
- else
- {
- /* blocking on something that doesn't exist is fine */
- }
- }
+ if ((! empty_is_ok) && resolvents->empty())
+ resolvents = _get_error_resolvents_for(*spec.if_package(), reason);
for (Resolvents::ConstIterator r(resolvents->begin()), r_end(resolvents->end()) ;
r != r_end ; ++r)
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index e1ba60a..93a7a4f 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -68,7 +68,7 @@ namespace paludis
const DestinationTypes _get_destination_types_for_blocker(const BlockDepSpec &,
const std::shared_ptr<const Reason> &) const;
- const std::shared_ptr<const Resolvents> _get_resolvents_for(
+ const std::pair<std::shared_ptr<const Resolvents>, bool> _get_resolvents_for(
const PackageDepSpec & spec,
const std::shared_ptr<const Reason> & reason) const;
diff --git a/paludis/resolver/get_resolvents_for_helper.cc b/paludis/resolver/get_resolvents_for_helper.cc
index e7edcfe..daa85dc 100644
--- a/paludis/resolver/get_resolvents_for_helper.cc
+++ b/paludis/resolver/get_resolvents_for_helper.cc
@@ -53,6 +53,9 @@ namespace paludis
bool want_target_dependencies;
bool want_target_runtime_dependencies;
+ bool want_dependencies_on_slash;
+ bool want_runtime_dependencies_on_slash;
+
bool want_best_slot_for_targets;
bool want_installed_slots_for_targets;
bool fallback_to_other_slots_for_targets;
@@ -66,6 +69,8 @@ namespace paludis
target_destination_type(dt_install_to_slash),
want_target_dependencies(true),
want_target_runtime_dependencies(true),
+ want_dependencies_on_slash(true),
+ want_runtime_dependencies_on_slash(true),
want_best_slot_for_targets(true),
want_installed_slots_for_targets(true),
fallback_to_other_slots_for_targets(false),
@@ -103,6 +108,18 @@ GetResolventsForHelper::set_want_target_runtime_dependencies(const bool b)
}
void
+GetResolventsForHelper::set_want_dependencies_on_slash(const bool b)
+{
+ _imp->want_dependencies_on_slash = b;
+}
+
+void
+GetResolventsForHelper::set_want_runtime_dependencies_on_slash(const bool b)
+{
+ _imp->want_runtime_dependencies_on_slash = b;
+}
+
+void
GetResolventsForHelper::set_slots(const bool best, const bool installed, const bool fallback)
{
_imp->want_best_slot_otherwise = best;
@@ -125,6 +142,8 @@ namespace
const DestinationType target_destination_type;
const bool want_target_dependencies;
const bool want_target_runtime_dependencies;
+ const bool want_dependencies_on_slash;
+ const bool want_runtime_dependencies_on_slash;
const std::shared_ptr<const PackageID> package_id;
DestinationTypes visit(const TargetReason &) const
@@ -149,7 +168,7 @@ namespace
DestinationTypes visit(const DependencyReason & dep) const
{
- DestinationTypes extras;
+ DestinationTypes extras, slash;
switch (target_destination_type)
{
@@ -194,7 +213,17 @@ namespace
throw InternalError(PALUDIS_HERE, "unhandled dt");
}
- return extras + dt_install_to_slash;
+ if (want_runtime_dependencies_on_slash ^ want_dependencies_on_slash)
+ {
+ if (want_dependencies_on_slash && ! is_run_or_post_dep(dep.sanitised_dependency()))
+ slash += dt_install_to_slash;
+ if (want_runtime_dependencies_on_slash && is_run_or_post_dep(dep.sanitised_dependency()))
+ slash += dt_install_to_slash;
+ }
+ else if (want_runtime_dependencies_on_slash || want_dependencies_on_slash)
+ slash += dt_install_to_slash;
+
+ return extras | slash;
}
DestinationTypes visit(const PresetReason &) const
@@ -219,15 +248,18 @@ namespace
const DestinationType target_destination_type,
const bool want_target_dependencies,
const bool want_target_runtime_dependencies,
+ const bool want_dependencies_on_slash,
+ const bool want_runtime_dependencies_on_slash,
const std::shared_ptr<const PackageID> & package_id,
const std::shared_ptr<const Reason> & reason)
{
- DestinationTypesFinder f{target_destination_type, want_target_dependencies, want_target_runtime_dependencies, package_id};
+ DestinationTypesFinder f{target_destination_type, want_target_dependencies, want_target_runtime_dependencies,
+ want_dependencies_on_slash, want_runtime_dependencies_on_slash, package_id};
return reason->accept_returning<DestinationTypes>(f);
}
}
-std::shared_ptr<Resolvents>
+std::pair<std::shared_ptr<Resolvents>, bool>
GetResolventsForHelper::operator() (
const PackageDepSpec & spec,
const std::shared_ptr<const SlotName> & maybe_slot,
@@ -284,15 +316,27 @@ GetResolventsForHelper::operator() (
else if (want_installed)
std::copy(installed_ids->begin(), installed_ids->end(), result_ids->back_inserter());
- std::shared_ptr<Resolvents> result(std::make_shared<Resolvents>());
- for (PackageIDSequence::ConstIterator i(result_ids->begin()), i_end(result_ids->end()) ;
- i != i_end ; ++i)
+ std::pair<std::shared_ptr<Resolvents>, bool> result(std::make_shared<Resolvents>(), false);
+
+ if (! result_ids->empty())
{
- DestinationTypes destination_types(get_destination_types_for_fn(_imp->env, spec,
- _imp->target_destination_type, _imp->want_target_dependencies, _imp->want_target_runtime_dependencies, *i, reason));
- for (EnumIterator<DestinationType> t, t_end(last_dt) ; t != t_end ; ++t)
- if (destination_types[*t])
- result->push_back(Resolvent(*i, *t));
+ result.second = true;
+
+ for (PackageIDSequence::ConstIterator i(result_ids->begin()), i_end(result_ids->end()) ;
+ i != i_end ; ++i)
+ {
+ DestinationTypes destination_types(get_destination_types_for_fn(_imp->env, spec,
+ _imp->target_destination_type, _imp->want_target_dependencies, _imp->want_target_runtime_dependencies,
+ _imp->want_dependencies_on_slash, _imp->want_runtime_dependencies_on_slash, *i, reason));
+
+ if (destination_types.any())
+ {
+ result.second = false;
+ for (EnumIterator<DestinationType> t, t_end(last_dt) ; t != t_end ; ++t)
+ if (destination_types[*t])
+ result.first->push_back(Resolvent(*i, *t));
+ }
+ }
}
return result;
diff --git a/paludis/resolver/get_resolvents_for_helper.hh b/paludis/resolver/get_resolvents_for_helper.hh
index 2ffcfd4..03ebdef 100644
--- a/paludis/resolver/get_resolvents_for_helper.hh
+++ b/paludis/resolver/get_resolvents_for_helper.hh
@@ -49,10 +49,13 @@ namespace paludis
void set_want_target_dependencies(const bool);
void set_want_target_runtime_dependencies(const bool);
+ void set_want_dependencies_on_slash(const bool);
+ void set_want_runtime_dependencies_on_slash(const bool);
+
void set_slots(const bool best, const bool installed, const bool fallback);
void set_target_slots(const bool best, const bool installed, const bool fallback);
- std::shared_ptr<Resolvents> operator() (
+ std::pair<std::shared_ptr<Resolvents>, bool> operator() (
const PackageDepSpec &,
const std::shared_ptr<const SlotName> &,
const std::shared_ptr<const Reason> &) const;
diff --git a/paludis/resolver/resolver_functions.hh b/paludis/resolver/resolver_functions.hh
index 216ed8c..87b655f 100644
--- a/paludis/resolver/resolver_functions.hh
+++ b/paludis/resolver/resolver_functions.hh
@@ -129,7 +129,7 @@ namespace paludis
const Resolvent &
)> GetInitialConstraintsForFunction;
- typedef std::function<std::shared_ptr<Resolvents> (
+ typedef std::function<std::pair<std::shared_ptr<Resolvents>, bool> (
const PackageDepSpec &,
const std::shared_ptr<const SlotName> &,
const std::shared_ptr<const Reason> &
diff --git a/src/clients/cave/cmd_resolve_cmdline.cc b/src/clients/cave/cmd_resolve_cmdline.cc
index e61e88e..8735c4f 100644
--- a/src/clients/cave/cmd_resolve_cmdline.cc
+++ b/src/clients/cave/cmd_resolve_cmdline.cc
@@ -259,6 +259,15 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
"create a binary package and use that for the install. May be specified multiple times. If this option "
"is not specified, a package will be built multiple times for multiple destinations"),
#endif
+ a_dependencies_to_slash(&g_destination_options, "dependencies-to-slash", '/', "Specify what to do with "
+ "dependencies for the / filesystem when not working on /. By default, all dependencies are installed "
+ "to /.",
+ args::EnumArg::EnumArgOptions
+ ("all", 'a', "Send all dependencies to /")
+ ("runtime", 'r', "Send only runtime dependencies to /")
+ ("build", 'b', "Send only build dependencies to /")
+ ("none", 'n', "Don't send dependencies to / at all"),
+ "all"),
// g_query_options(this, "Query Options", "Query the user interactively when making decisions. "
// "If only --query is specified, prompt for everything. Otherwise, prompt only for the specified decisions."),
diff --git a/src/clients/cave/cmd_resolve_cmdline.hh b/src/clients/cave/cmd_resolve_cmdline.hh
index 5728d01..aa6e76f 100644
--- a/src/clients/cave/cmd_resolve_cmdline.hh
+++ b/src/clients/cave/cmd_resolve_cmdline.hh
@@ -99,6 +99,7 @@ namespace paludis
#ifdef ENABLE_PBINS
args::StringSetArg a_via_binary;
#endif
+ args::EnumArg a_dependencies_to_slash;
// args::ArgsGroup g_query_options;
// args::SwitchArg a_query;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index fc902c5..5bc23a5 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -788,6 +788,30 @@ paludis::cave::resolve_common(
throw args::DoHelp("Don't understand argument '" + resolution_options.a_slots.argument() + "' to '--"
+ resolution_options.a_slots.long_name() + "'");
+ if (resolution_options.a_dependencies_to_slash.argument() == "all")
+ {
+ get_resolvents_for_helper.set_want_dependencies_on_slash(true);
+ get_resolvents_for_helper.set_want_runtime_dependencies_on_slash(true);
+ }
+ else if (resolution_options.a_dependencies_to_slash.argument() == "runtime")
+ {
+ get_resolvents_for_helper.set_want_dependencies_on_slash(false);
+ get_resolvents_for_helper.set_want_runtime_dependencies_on_slash(true);
+ }
+ else if (resolution_options.a_dependencies_to_slash.argument() == "build")
+ {
+ get_resolvents_for_helper.set_want_dependencies_on_slash(true);
+ get_resolvents_for_helper.set_want_runtime_dependencies_on_slash(false);
+ }
+ else if (resolution_options.a_dependencies_to_slash.argument() == "none")
+ {
+ get_resolvents_for_helper.set_want_dependencies_on_slash(false);
+ get_resolvents_for_helper.set_want_runtime_dependencies_on_slash(false);
+ }
+ else
+ throw args::DoHelp("Don't understand argument '" + resolution_options.a_dependencies_to_slash.argument() + "' to '--"
+ + resolution_options.a_dependencies_to_slash.long_name() + "'");
+
if (resolution_options.a_target_slots.argument() == "best-or-installed")
get_resolvents_for_helper.set_target_slots(true, false, true);
else if (resolution_options.a_target_slots.argument() == "installed-or-best")