aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-08 18:58:23 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-08 20:45:40 +0100
commit164c5ff7ba0e7aae7695e4a287700b89b147b47e (patch)
tree715ca8d241a744b3245fea0d5e163d7778493f42
parent1602699213ff08c19d47fc1eaf18ce791d724ef7 (diff)
downloadpaludis-164c5ff7ba0e7aae7695e4a287700b89b147b47e.tar.gz
paludis-164c5ff7ba0e7aae7695e4a287700b89b147b47e.tar.xz
Be able to track more about deps
-rw-r--r--paludis/resolver/sanitised_dependencies.cc37
-rw-r--r--paludis/resolver/sanitised_dependencies.hh4
-rw-r--r--paludis/resolver/serialise-impl.hh10
-rw-r--r--src/clients/cave/cmd_display_resolution.cc110
4 files changed, 115 insertions, 46 deletions
diff --git a/paludis/resolver/sanitised_dependencies.cc b/paludis/resolver/sanitised_dependencies.cc
index 229f66a..04a494b 100644
--- a/paludis/resolver/sanitised_dependencies.cc
+++ b/paludis/resolver/sanitised_dependencies.cc
@@ -260,8 +260,31 @@ namespace
SanitisedDependency make_sanitised(const PackageOrBlockDepSpec & spec)
{
+ std::stringstream adl;
+ for (DependencySystemLabelSequence::ConstIterator i((*labels_stack.begin())->system_labels()->begin()),
+ i_end((*labels_stack.begin())->system_labels()->end()) ;
+ i != i_end ; ++i)
+ adl << (adl.str().empty() ? "" : ", ") << stringify(**i);
+
+ for (DependencyTypeLabelSequence::ConstIterator i((*labels_stack.begin())->type_labels()->begin()),
+ i_end((*labels_stack.begin())->type_labels()->end()) ;
+ i != i_end ; ++i)
+ adl << (adl.str().empty() ? "" : ", ") << stringify(**i);
+
+ for (DependencyABIsLabelSequence::ConstIterator i((*labels_stack.begin())->abi_labels()->begin()),
+ i_end((*labels_stack.begin())->abi_labels()->end()) ;
+ i != i_end ; ++i)
+ adl << (adl.str().empty() ? "" : ", ") << stringify(**i);
+
+ for (DependencySuggestLabelSequence::ConstIterator i((*labels_stack.begin())->suggest_labels()->begin()),
+ i_end((*labels_stack.begin())->suggest_labels()->end()) ;
+ i != i_end ; ++i)
+ adl << (adl.str().empty() ? "" : ", ") << stringify(**i);
+
return make_named_values<SanitisedDependency>(
value_for<n::active_dependency_labels>(*labels_stack.begin()),
+ value_for<n::active_dependency_labels_as_string>(adl.str()),
+ value_for<n::any_of_alternatives>(make_null_shared_ptr()),
value_for<n::metadata_key_human_name>(human_name),
value_for<n::metadata_key_raw_name>(raw_name),
value_for<n::spec>(spec)
@@ -454,6 +477,8 @@ void
SanitisedDependency::serialise(Serialiser & s) const
{
s.object("SanitisedDependency")
+ .member(SerialiserFlags<>(), "active_dependency_labels_as_string", active_dependency_labels_as_string())
+ .member(SerialiserFlags<serialise::might_be_null, serialise::container>(), "any_of_alternatives", any_of_alternatives())
.member(SerialiserFlags<>(), "metadata_key_human_name", metadata_key_human_name())
.member(SerialiserFlags<>(), "metadata_key_raw_name", metadata_key_raw_name())
.member(SerialiserFlags<>(), "spec", spec())
@@ -467,8 +492,20 @@ SanitisedDependency::deserialise(Deserialisation & d, const std::tr1::shared_ptr
Deserialisator v(d, "SanitisedDependency");
+ std::tr1::shared_ptr<Sequence<std::string> > any_of_alternatives;;
+ const std::tr1::shared_ptr<Deserialisation> vvd(v.find_remove_member("any_of_alternatives"));
+ if (! vvd->null())
+ {
+ any_of_alternatives.reset(new Sequence<std::string>);
+ Deserialisator vv(*vvd, "c");
+ for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
+ any_of_alternatives->push_back(vv.member<std::string>(stringify(n)));
+ }
+
return make_named_values<SanitisedDependency>(
value_for<n::active_dependency_labels>(make_null_shared_ptr()),
+ value_for<n::active_dependency_labels_as_string>(v.member<std::string>("active_dependency_labels_as_string")),
+ value_for<n::any_of_alternatives>(any_of_alternatives),
value_for<n::metadata_key_human_name>(v.member<std::string>("metadata_key_human_name")),
value_for<n::metadata_key_raw_name>(v.member<std::string>("metadata_key_raw_name")),
value_for<n::spec>(PackageOrBlockDepSpec::deserialise(*v.find_remove_member("spec"),
diff --git a/paludis/resolver/sanitised_dependencies.hh b/paludis/resolver/sanitised_dependencies.hh
index 5e40669..cfe8744 100644
--- a/paludis/resolver/sanitised_dependencies.hh
+++ b/paludis/resolver/sanitised_dependencies.hh
@@ -34,6 +34,8 @@ namespace paludis
namespace n
{
struct active_dependency_labels;
+ struct active_dependency_labels_as_string;
+ struct any_of_alternatives;
struct if_package;
struct if_block;
struct metadata_key_human_name;
@@ -61,6 +63,8 @@ namespace paludis
struct SanitisedDependency
{
NamedValue<n::active_dependency_labels, std::tr1::shared_ptr<const ActiveDependencyLabels> > active_dependency_labels;
+ NamedValue<n::active_dependency_labels_as_string, std::string> active_dependency_labels_as_string;
+ NamedValue<n::any_of_alternatives, std::tr1::shared_ptr<Sequence<std::string> > > any_of_alternatives;
NamedValue<n::metadata_key_human_name, std::string> metadata_key_human_name;
NamedValue<n::metadata_key_raw_name, std::string> metadata_key_raw_name;
NamedValue<n::spec, PackageOrBlockDepSpec> spec;
diff --git a/paludis/resolver/serialise-impl.hh b/paludis/resolver/serialise-impl.hh
index 19d7aea..81b6941 100644
--- a/paludis/resolver/serialise-impl.hh
+++ b/paludis/resolver/serialise-impl.hh
@@ -86,6 +86,16 @@ namespace paludis
};
template <
+ typename T_>
+ struct SerialiserObjectWriterHandler<false, false, const T_>
+ {
+ static void write(Serialiser & s, const T_ & t)
+ {
+ SerialiserObjectWriterHandler<false, false, T_>::write(s, t);
+ }
+ };
+
+ template <
bool is_container_,
typename T_>
struct SerialiserObjectWriterHandler<is_container_, true, T_>
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index 696e998..636398c 100644
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -33,6 +33,7 @@
#include <paludis/util/iterator_funcs.hh>
#include <paludis/util/options.hh>
#include <paludis/util/set.hh>
+#include <paludis/util/make_named_values.hh>
#include <paludis/resolver/resolutions.hh>
#include <paludis/resolver/serialise.hh>
#include <paludis/resolver/reason.hh>
@@ -50,6 +51,7 @@
#include <paludis/user_dep_spec.hh>
#include <paludis/match_package.hh>
#include <paludis/repository.hh>
+#include <paludis/package_dep_spec_properties.hh>
#include <set>
#include <iterator>
@@ -112,9 +114,20 @@ namespace
else
{
if (verbose)
+ {
+ std::string as;
+ if (r.sanitised_dependency().any_of_alternatives())
+ as = " (chosen from || ( " + join(r.sanitised_dependency().any_of_alternatives()->begin(),
+ r.sanitised_dependency().any_of_alternatives()->end(), " ") + " ) )";
+
return std::make_pair(stringify(*r.sanitised_dependency().spec().if_package())
- + " from " + stringify(*r.from_id()) + " key "
- + r.sanitised_dependency().metadata_key_human_name(), false);
+ + " from " + stringify(*r.from_id()) + ", key '"
+ + r.sanitised_dependency().metadata_key_human_name() + "'"
+ + (r.sanitised_dependency().active_dependency_labels_as_string().empty() ? "" :
+ ", labelled '" + r.sanitised_dependency().active_dependency_labels_as_string() + "'")
+ + as,
+ false);
+ }
else
return std::make_pair(stringify(r.from_id()->name()), false);
}
@@ -443,31 +456,6 @@ namespace
cout << endl;
}
- struct ReasonDisplayer
- {
- void visit(const TargetReason &)
- {
- std::cout << "it is a target";
- }
-
- void visit(const DependencyReason & reason)
- {
- std::cout << "of dependency " << reason.sanitised_dependency().spec()
- << " from " << *reason.from_id();
- }
-
- void visit(const PresetReason &)
- {
- std::cout << "of a preset";
- }
-
- void visit(const SetReason & reason)
- {
- std::cout << "of set " << reason.set_name() << ", which is because ";
- reason.reason_for_set()->accept(*this);
- }
- };
-
void display_explanations(
const std::tr1::shared_ptr<Environment> & env,
const ResolutionLists & lists,
@@ -491,13 +479,37 @@ namespace
{
if (! (*r)->decision()->if_package_id())
{
- /* really we want this to work for simple cat/pkg and
- * cat/pkg:slot specs anyway, even if we chose nothing */
- continue;
- }
+ /* decided nothing, so we can only work for cat/pkg, where
+ * either can be wildcards (we could work for :slot too,
+ * but we're lazy) */
+ 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>(indeterminate),
+ 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>(indeterminate),
+ value_for<n::has_package_name_part>(indeterminate),
+ value_for<n::has_slot_requirement>(false),
+ value_for<n::has_tag>(false),
+ value_for<n::has_version_requirements>(false)
+ )))
+ continue;
- if (! match_package(*env, spec, *(*r)->decision()->if_package_id(), MatchPackageOptions()))
- continue;
+ if (spec.package_ptr() && *spec.package_ptr() != (*r)->qpn_s().package())
+ continue;
+ if (spec.package_name_part_ptr() && *spec.package_name_part_ptr() != (*r)->qpn_s().package().package())
+ continue;
+ if (spec.category_name_part_ptr() && *spec.category_name_part_ptr() != (*r)->qpn_s().package().category())
+ continue;
+ }
+ else
+ {
+ if (! match_package(*env, spec, *(*r)->decision()->if_package_id(), MatchPackageOptions()))
+ continue;
+ }
any = true;
@@ -535,23 +547,29 @@ namespace
std::cout << ", installing to /";
std::cout << std::endl;
- std::cout << " because ";
- ReasonDisplayer v;
- (*c)->reason()->accept(v);
+ std::cout << " Because of ";
+ ReasonNameGetter v(true);
+ std::cout << (*c)->reason()->accept_returning<std::pair<std::string, bool> >(v).first;
std::cout << std::endl;
}
- std::cout << " The decision made was:" << std::endl;
- std::cout << " Use " << *(*r)->decision()->if_package_id() << std::endl;
- if ((*r)->destinations()->slash())
+
+ if ((*r)->decision()->if_package_id())
{
- std::cout << " Install to / using repository " << (*r)->destinations()->slash()->repository() << std::endl;
- if (! (*r)->destinations()->slash()->replacing()->empty())
- for (PackageIDSequence::ConstIterator x((*r)->destinations()->slash()->replacing()->begin()),
- x_end((*r)->destinations()->slash()->replacing()->end()) ;
- x != x_end ; ++x)
- std::cout << " Replacing " << **x << std::endl;
+ std::cout << " The decision made was:" << std::endl;
+ std::cout << " Use " << *(*r)->decision()->if_package_id() << std::endl;
+ if ((*r)->destinations()->slash())
+ {
+ std::cout << " Install to / using repository " << (*r)->destinations()->slash()->repository() << std::endl;
+ if (! (*r)->destinations()->slash()->replacing()->empty())
+ for (PackageIDSequence::ConstIterator x((*r)->destinations()->slash()->replacing()->begin()),
+ x_end((*r)->destinations()->slash()->replacing()->end()) ;
+ x != x_end ; ++x)
+ std::cout << " Replacing " << **x << std::endl;
+ }
+ std::cout << std::endl;
}
- std::cout << std::endl;
+ else
+ std::cout << " No decision could be made" << std::endl << std::endl;
}
if (! any)