aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2012-08-06 19:23:28 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2012-08-07 14:51:14 +0100
commit25215485622ceb2992cc3f831eafba5744770f33 (patch)
tree58b4593edd3aa8edc7c4a20d40f18a3cf681ca63
parente68ba8a3313e0d14ad9a978a57fd29c472b4953e (diff)
downloadpaludis-25215485622ceb2992cc3f831eafba5744770f33.tar.gz
paludis-25215485622ceb2992cc3f831eafba5744770f33.tar.xz
Explicit choices
-rw-r--r--paludis/additional_package_dep_spec_requirement.hh2
-rw-r--r--paludis/elike_use_requirement-fwd.hh3
-rw-r--r--paludis/elike_use_requirement.cc59
-rw-r--r--paludis/repositories/e/dep_parser.cc17
-rw-r--r--paludis/repositories/e/e_choice_value.cc3
-rw-r--r--paludis/repositories/e/e_choice_value.hh2
-rw-r--r--paludis/repositories/e/e_choices_key.cc23
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc3
-rw-r--r--paludis/repositories/e/e_installed_repository_id.hh2
-rw-r--r--paludis/repositories/e/e_repository_id.hh2
-rw-r--r--paludis/repositories/e/ebuild_id.cc4
-rw-r--r--paludis/repositories/e/ebuild_id.hh2
12 files changed, 98 insertions, 24 deletions
diff --git a/paludis/additional_package_dep_spec_requirement.hh b/paludis/additional_package_dep_spec_requirement.hh
index a04ef0b..7a86e41 100644
--- a/paludis/additional_package_dep_spec_requirement.hh
+++ b/paludis/additional_package_dep_spec_requirement.hh
@@ -52,7 +52,7 @@ namespace paludis
* The string in the return type might be a description of why the
* requirement was not met. Sometimes better messages can be given
* than simply the return value of as_human_string() when the ID to
- * be matched is known. If the bool is false, the string is
+ * be matched is known. If the bool is true, the string is
* meaningless.
*
* \param spec_id The PackageID the spec comes from. May be null. Used for
diff --git a/paludis/elike_use_requirement-fwd.hh b/paludis/elike_use_requirement-fwd.hh
index abc7f7a..89c8f1c 100644
--- a/paludis/elike_use_requirement-fwd.hh
+++ b/paludis/elike_use_requirement-fwd.hh
@@ -40,6 +40,9 @@ namespace paludis
std::shared_ptr<const AdditionalPackageDepSpecRequirement> parse_elike_use_requirement(
const std::string &, const ELikeUseRequirementOptions &)
PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> make_elike_presumed_choices_requirement()
+ PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
}
#endif
diff --git a/paludis/elike_use_requirement.cc b/paludis/elike_use_requirement.cc
index 1d2c305..61a7d9b 100644
--- a/paludis/elike_use_requirement.cc
+++ b/paludis/elike_use_requirement.cc
@@ -848,3 +848,62 @@ paludis::parse_elike_use_requirement(const std::string & s,
return result;
}
+namespace
+{
+ class ELikePresumedChoicesRequirement :
+ public AdditionalPackageDepSpecRequirement
+ {
+ public:
+ virtual const std::pair<bool, std::string> requirement_met(
+ const Environment * const,
+ const ChangedChoices * const,
+ const std::shared_ptr<const PackageID> & id,
+ const std::shared_ptr<const PackageID> &,
+ const ChangedChoices * const) const PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ if (! id->choices_key())
+ return std::make_pair(true, "");
+
+ auto choices(id->choices_key()->parse_value());
+ for (auto c(choices->begin()), c_end(choices->end()) ; c != c_end ; ++c)
+ for (auto v((*c)->begin()), v_end((*c)->end()) ; v != v_end ; ++v)
+ if ((*v)->presumed())
+ {
+ return std::make_pair(false, as_human_string(id));
+ }
+
+ return std::make_pair(true, as_human_string(id));
+ }
+
+ virtual Tribool accumulate_changes_to_make_met(
+ const Environment * const env,
+ const ChangedChoices * const maybe_changes_to_owner,
+ const std::shared_ptr<const PackageID> & id,
+ const std::shared_ptr<const PackageID> & spec_id,
+ ChangedChoices &) const PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ if (requirement_met(env, maybe_changes_to_owner, id, spec_id, 0).first)
+ return indeterminate;
+ else
+ return false;
+ }
+
+ virtual const std::string as_human_string(
+ const std::shared_ptr<const PackageID> &) const PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ return "Remaining explicit flags enabled";
+ }
+
+ virtual const std::string as_raw_string() const PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ return "";
+ }
+ };
+}
+
+std::shared_ptr<const AdditionalPackageDepSpecRequirement>
+paludis::make_elike_presumed_choices_requirement()
+{
+ return std::make_shared<ELikePresumedChoicesRequirement>();
+}
+
diff --git a/paludis/repositories/e/dep_parser.cc b/paludis/repositories/e/dep_parser.cc
index 2688821..d423c9a 100644
--- a/paludis/repositories/e/dep_parser.cc
+++ b/paludis/repositories/e/dep_parser.cc
@@ -48,6 +48,8 @@
#include <paludis/metadata_key.hh>
#include <paludis/always_enabled_dependency_label.hh>
#include <paludis/elike_blocker.hh>
+#include <paludis/elike_use_requirement.hh>
+#include <paludis/partially_made_package_dep_spec.hh>
#include <map>
#include <list>
#include <set>
@@ -106,11 +108,14 @@ namespace
typename ParseStackTypes<T_>::Stack & h,
const typename ParseStackTypes<T_>::AnnotationsGoHere & annotations_go_here,
const std::string & s,
- const EAPI & eapi)
+ const EAPI & eapi,
+ bool add_explicit_choices_requirement)
{
- std::shared_ptr<PackageDepSpec> spec(std::make_shared<PackageDepSpec>(
- parse_elike_package_dep_spec(s, eapi.supported()->package_dep_spec_parse_options(),
- eapi.supported()->version_spec_options())));
+ auto data(partial_parse_elike_package_dep_spec(s, eapi.supported()->package_dep_spec_parse_options(),
+ eapi.supported()->version_spec_options()));
+ if (add_explicit_choices_requirement)
+ data.additional_requirement(make_elike_presumed_choices_requirement());
+ std::shared_ptr<PackageDepSpec> spec(std::make_shared<PackageDepSpec>(data));
h.begin()->item()->append(spec);
h.begin()->children().push_back(spec);
annotations_go_here(spec);
@@ -128,7 +133,7 @@ namespace
switch (std::get<0>(p))
{
case ebk_no_block:
- package_dep_spec_string_handler<T_>(h, annotations_go_here, s, eapi);
+ package_dep_spec_string_handler<T_>(h, annotations_go_here, s, eapi, true);
break;
case ebk_bang_question:
@@ -593,7 +598,7 @@ paludis::erepository::parse_commented_set(const std::string & s, const Environme
n::on_should_be_empty() = std::bind(&should_be_empty_handler<SetSpecTree>, std::ref(stack), s),
n::on_string() = std::bind(&package_dep_spec_string_handler<SetSpecTree>, std::ref(stack),
ParseStackTypes<SetSpecTree>::AnnotationsGoHere(std::bind(
- &set_thing_to_annotate, std::ref(thing_to_annotate), _1)), _1, eapi),
+ &set_thing_to_annotate, std::ref(thing_to_annotate), _1)), _1, eapi, false),
n::on_use() = std::bind(&use_not_allowed_handler, s, _1),
n::on_use_under_any() = std::bind(&use_under_any_handler, s, std::cref(eapi))
));
diff --git a/paludis/repositories/e/e_choice_value.cc b/paludis/repositories/e/e_choice_value.cc
index 8252b34..e381ac3 100644
--- a/paludis/repositories/e/e_choice_value.cc
+++ b/paludis/repositories/e/e_choice_value.cc
@@ -113,7 +113,7 @@ EChoiceValue::permitted_parameter_values() const
bool
EChoiceValue::presumed() const
{
- return false;
+ return _params.presumed();
}
namespace paludis
@@ -155,6 +155,7 @@ namespace paludis
&& (a.enabled_by_default() == b.enabled_by_default())
&& (a.origin() == b.origin())
&& (a.locked() == b.locked())
+ && (a.presumed() == b.presumed())
&& (a.unprefixed_choice_name() == b.unprefixed_choice_name())
;
}
diff --git a/paludis/repositories/e/e_choice_value.hh b/paludis/repositories/e/e_choice_value.hh
index 9480ee4..cf3e4d4 100644
--- a/paludis/repositories/e/e_choice_value.hh
+++ b/paludis/repositories/e/e_choice_value.hh
@@ -37,6 +37,7 @@ namespace paludis
typedef Name<struct name_enabled> enabled;
typedef Name<struct name_enabled_by_default> enabled_by_default;
typedef Name<struct name_locked> locked;
+ typedef Name<struct name_presumed> presumed;
typedef Name<struct name_origin> origin;
typedef Name<struct name_unprefixed_choice_name> unprefixed_choice_name;
}
@@ -51,6 +52,7 @@ namespace paludis
NamedValue<n::enabled, bool> enabled;
NamedValue<n::enabled_by_default, bool> enabled_by_default;
NamedValue<n::locked, bool> locked;
+ NamedValue<n::presumed, bool> presumed;
NamedValue<n::origin, ChoiceOrigin> origin;
NamedValue<n::unprefixed_choice_name, UnprefixedChoiceName> unprefixed_choice_name;
};
diff --git a/paludis/repositories/e/e_choices_key.cc b/paludis/repositories/e/e_choices_key.cc
index 9f75658..8ec98e1 100644
--- a/paludis/repositories/e/e_choices_key.cc
+++ b/paludis/repositories/e/e_choices_key.cc
@@ -191,9 +191,10 @@ namespace
const UnprefixedChoiceName & unprefixed,
const std::string & description,
const Tribool s,
- const ChoiceOrigin o)
+ const ChoiceOrigin o,
+ const bool presumed)
{
- return id->make_choice_value(choice, unprefixed, s, false, o, description, false);
+ return id->make_choice_value(choice, unprefixed, s, false, o, description, false, presumed);
}
std::string get_maybe_description(const std::shared_ptr<const Map<ChoiceNameWithPrefix, std::string> > & m,
@@ -327,7 +328,7 @@ EChoicesKey::populate_myoptions() const
{
for (MyOptionsFinder::Descriptions::const_iterator v(p->second.begin()), v_end(p->second.end()) ;
v != v_end ; ++v)
- exp->add(make_myoption(_imp->id, exp, v->first, v->second, indeterminate, co_explicit));
+ exp->add(make_myoption(_imp->id, exp, v->first, v->second, indeterminate, co_explicit, false));
myoptions.prefixes.erase(p);
}
}
@@ -339,7 +340,7 @@ EChoicesKey::populate_myoptions() const
Context local_local_context("When using empty prefix to populate choices:");
for (MyOptionsFinder::Descriptions::const_iterator v(p->second.begin()), v_end(p->second.end()) ;
v != v_end ; ++v)
- options->add(make_myoption(_imp->id, options, v->first, v->second, indeterminate, co_explicit));
+ options->add(make_myoption(_imp->id, options, v->first, v->second, indeterminate, co_explicit, false));
myoptions.prefixes.erase(p);
}
@@ -438,7 +439,7 @@ EChoicesKey::populate_iuse(const std::shared_ptr<const Map<ChoiceNameWithPrefix,
{
std::shared_ptr<const ChoiceValue> choice(_imp->id->make_choice_value(
use, UnprefixedChoiceName(stringify(it->first)), it->second.default_value(), false,
- it->second.implicit() ? co_implicit : co_explicit, get_maybe_description(d, it->first), false));
+ it->second.implicit() ? co_implicit : co_explicit, get_maybe_description(d, it->first), false, false));
use->add(choice);
}
@@ -473,7 +474,7 @@ EChoicesKey::populate_iuse(const std::shared_ptr<const Map<ChoiceNameWithPrefix,
}
else
use->add(_imp->id->make_choice_value(use, UnprefixedChoiceName(stringify(flag.first)), flag.second, false, co_implicit,
- get_maybe_description(d, flag.first), false));
+ get_maybe_description(d, flag.first), false, false));
}
}
}
@@ -494,7 +495,7 @@ EChoicesKey::populate_iuse(const std::shared_ptr<const Map<ChoiceNameWithPrefix,
for (Set<UnprefixedChoiceName>::ConstIterator a(_imp->maybe_e_repository->arch_flags()->begin()), a_end(_imp->maybe_e_repository->arch_flags()->end()) ;
a != a_end ; ++a)
- arch->add(_imp->id->make_choice_value(arch, *a, indeterminate, false, co_implicit, "", false));
+ arch->add(_imp->id->make_choice_value(arch, *a, indeterminate, false, co_implicit, "", false, false));
}
if (_imp->id->raw_use_expand_key())
@@ -552,9 +553,9 @@ EChoicesKey::populate_iuse(const std::shared_ptr<const Map<ChoiceNameWithPrefix,
std::map<ChoiceNameWithPrefix, ChoiceOptions>::const_iterator i(i_values.find(ChoiceNameWithPrefix(lower_u + delim + stringify(*v))));
if (i_values.end() != i)
exp->add(_imp->id->make_choice_value(exp, *v, i->second.default_value(), false, i->second.implicit() ? co_implicit : co_explicit,
- get_maybe_description(d, i->first), false));
+ get_maybe_description(d, i->first), false, false));
else
- exp->add(_imp->id->make_choice_value(exp, *v, indeterminate, false, co_implicit, "", false));
+ exp->add(_imp->id->make_choice_value(exp, *v, indeterminate, false, co_implicit, "", false, false));
}
}
}
@@ -570,13 +571,13 @@ EChoicesKey::populate_iuse(const std::shared_ptr<const Map<ChoiceNameWithPrefix,
choice = _imp->value->find_by_name_with_prefix(ELikeOptionalTestsChoiceValue::canonical_name_with_prefix());
if (choice)
use->add(_imp->id->make_choice_value(use, UnprefixedChoiceName(_imp->id->eapi()->supported()->choices_options()->fancy_test_flag()),
- choice->enabled(), true, co_explicit, "", true));
+ choice->enabled(), true, co_explicit, "", true, false));
else
{
std::string name(_imp->id->eapi()->supported()->choices_options()->fancy_test_flag());
choice = _imp->id->make_choice_value(
use, UnprefixedChoiceName(name), indeterminate, true, co_explicit,
- get_maybe_description(d, ChoiceNameWithPrefix(name)), false);
+ get_maybe_description(d, ChoiceNameWithPrefix(name)), false, false);
use->add(choice);
}
}
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index a40981b..5c01d89 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -1021,7 +1021,7 @@ EInstalledRepositoryID::slot_key() const
const std::shared_ptr<const ChoiceValue>
EInstalledRepositoryID::make_choice_value(const std::shared_ptr<const Choice> & c, const UnprefixedChoiceName & v,
- const Tribool, const bool, const ChoiceOrigin origin, const std::string & override_description, const bool) const
+ const Tribool, const bool, const ChoiceOrigin origin, const std::string & override_description, const bool, const bool presumed) const
{
if (! eapi()->supported())
throw InternalError(PALUDIS_HERE, "Unsupported EAPI");
@@ -1051,6 +1051,7 @@ EInstalledRepositoryID::make_choice_value(const std::shared_ptr<const Choice> &
n::enabled() = enabled,
n::enabled_by_default() = enabled,
n::locked() = true,
+ n::presumed() = presumed,
n::origin() = origin,
n::unprefixed_choice_name() = v
));
diff --git a/paludis/repositories/e/e_installed_repository_id.hh b/paludis/repositories/e/e_installed_repository_id.hh
index 3547148..ad6ec31 100644
--- a/paludis/repositories/e/e_installed_repository_id.hh
+++ b/paludis/repositories/e/e_installed_repository_id.hh
@@ -102,7 +102,7 @@ namespace paludis
virtual const std::shared_ptr<const ChoiceValue> make_choice_value(
const std::shared_ptr<const Choice> &, const UnprefixedChoiceName &, const Tribool,
- const bool, const ChoiceOrigin, const std::string &, const bool) const;
+ const bool, const ChoiceOrigin, const std::string &, const bool, const bool) const;
virtual void add_build_options(const std::shared_ptr<Choices> &) const;
diff --git a/paludis/repositories/e/e_repository_id.hh b/paludis/repositories/e/e_repository_id.hh
index 9bdaed3..3d16007 100644
--- a/paludis/repositories/e/e_repository_id.hh
+++ b/paludis/repositories/e/e_repository_id.hh
@@ -61,7 +61,7 @@ namespace paludis
virtual const std::shared_ptr<const ChoiceValue> make_choice_value(
const std::shared_ptr<const Choice> &, const UnprefixedChoiceName &, const Tribool,
- const bool, const ChoiceOrigin, const std::string &, const bool)
+ const bool, const ChoiceOrigin, const std::string &, const bool, const bool)
const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
virtual void add_build_options(const std::shared_ptr<Choices> &) const = 0;
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 4522a4a..2985615 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -1496,7 +1496,8 @@ EbuildID::make_choice_value(
const bool iuse_default_wins,
const ChoiceOrigin origin,
const std::string & override_description,
- const bool force_locked
+ const bool force_locked,
+ const bool presumed
) const
{
if (! eapi()->supported())
@@ -1575,6 +1576,7 @@ EbuildID::make_choice_value(
n::enabled() = enabled,
n::enabled_by_default() = enabled_by_default,
n::locked() = force_locked || locked,
+ n::presumed() = presumed,
n::origin() = origin,
n::unprefixed_choice_name() = value_name
));
diff --git a/paludis/repositories/e/ebuild_id.hh b/paludis/repositories/e/ebuild_id.hh
index 255062b..97036a5 100644
--- a/paludis/repositories/e/ebuild_id.hh
+++ b/paludis/repositories/e/ebuild_id.hh
@@ -162,7 +162,7 @@ namespace paludis
virtual const std::shared_ptr<const ChoiceValue> make_choice_value(
const std::shared_ptr<const Choice> &, const UnprefixedChoiceName &, const Tribool,
- const bool, const ChoiceOrigin, const std::string &, const bool) const;
+ const bool, const ChoiceOrigin, const std::string &, const bool, const bool) const;
virtual void add_build_options(const std::shared_ptr<Choices> &) const;