diff options
Diffstat (limited to 'paludis')
-rw-r--r-- | paludis/dep_spec_annotations-fwd.hh | 6 | ||||
-rw-r--r-- | paludis/dep_spec_annotations.cc | 14 | ||||
-rw-r--r-- | paludis/dep_spec_annotations.hh | 3 | ||||
-rw-r--r-- | paludis/dep_spec_annotations.se | 37 | ||||
-rw-r--r-- | paludis/files.m4 | 2 | ||||
-rw-r--r-- | paludis/repositories/e/dep_parser.cc | 139 | ||||
-rw-r--r-- | paludis/repositories/e/e_choices_key.cc | 41 | ||||
-rw-r--r-- | paludis/repositories/e/eapi.cc | 5 | ||||
-rw-r--r-- | paludis/repositories/e/eapi.hh | 10 | ||||
-rw-r--r-- | paludis/repositories/e/eapis/exheres-0.conf | 5 | ||||
-rw-r--r-- | paludis/repositories/e/myoptions_requirements_verifier.cc | 208 | ||||
-rw-r--r-- | paludis/repositories/e/pipe_command_handler.cc | 4 | ||||
-rw-r--r-- | paludis/resolver/package_or_block_dep_spec.cc | 3 |
13 files changed, 303 insertions, 174 deletions
diff --git a/paludis/dep_spec_annotations-fwd.hh b/paludis/dep_spec_annotations-fwd.hh index 63f5ee7e6..a02167234 100644 --- a/paludis/dep_spec_annotations-fwd.hh +++ b/paludis/dep_spec_annotations-fwd.hh @@ -20,10 +20,16 @@ #ifndef PALUDIS_GUARD_PALUDIS_DEP_SPEC_ANNOTATIONS_FWD_HH #define PALUDIS_GUARD_PALUDIS_DEP_SPEC_ANNOTATIONS_FWD_HH 1 +#include <paludis/util/attributes.hh> +#include <iosfwd> + namespace paludis { class DepSpecAnnotation; class DepSpecAnnotations; + +#include <paludis/dep_spec_annotations-se.hh> + } #endif diff --git a/paludis/dep_spec_annotations.cc b/paludis/dep_spec_annotations.cc index 32603a5c9..02eb34aaa 100644 --- a/paludis/dep_spec_annotations.cc +++ b/paludis/dep_spec_annotations.cc @@ -29,6 +29,8 @@ using namespace paludis; +#include <paludis/dep_spec_annotations-se.cc> + typedef std::vector<DepSpecAnnotation> Annotations; namespace paludis @@ -71,6 +73,11 @@ namespace { return a.key() == k; } + + bool role_is(const DepSpecAnnotation & a, const DepSpecAnnotationRole k) + { + return a.role() == k; + } } DepSpecAnnotations::ConstIterator @@ -80,6 +87,13 @@ DepSpecAnnotations::find(const std::string & s) const std::bind(&key_is, std::placeholders::_1, s))); } +DepSpecAnnotations::ConstIterator +DepSpecAnnotations::find(const DepSpecAnnotationRole r) const +{ + return ConstIterator(std::find_if(_imp->annotations.begin(), _imp->annotations.end(), + std::bind(&role_is, std::placeholders::_1, r))); +} + void DepSpecAnnotations::add(const DepSpecAnnotation & a) { diff --git a/paludis/dep_spec_annotations.hh b/paludis/dep_spec_annotations.hh index e28d4ab86..0ff516788 100644 --- a/paludis/dep_spec_annotations.hh +++ b/paludis/dep_spec_annotations.hh @@ -31,12 +31,14 @@ namespace paludis namespace n { typedef Name<struct key_name> key; + typedef Name<struct role_name> role; typedef Name<struct value_name> value; } struct DepSpecAnnotation { NamedValue<n::key, std::string> key; + NamedValue<n::role, DepSpecAnnotationRole> role; NamedValue<n::value, std::string> value; }; @@ -55,6 +57,7 @@ namespace paludis ConstIterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result)); ConstIterator end() const PALUDIS_ATTRIBUTE((warn_unused_result)); ConstIterator find(const std::string &) const PALUDIS_ATTRIBUTE((warn_unused_result)); + ConstIterator find(const DepSpecAnnotationRole) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; extern template class Pimp<DepSpecAnnotations>; diff --git a/paludis/dep_spec_annotations.se b/paludis/dep_spec_annotations.se new file mode 100644 index 000000000..1c5735f6a --- /dev/null +++ b/paludis/dep_spec_annotations.se @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# vim: set sw=4 sts=4 et ft=sh : + +make_enum_DepSpecAnnotationRole() +{ + prefix dsar + + key dsar_none "No particular role" + + key dsar_general_description "A description" + key dsar_general_url "A url" + key dsar_general_note "A note" + key dsar_general_lang "A language" + key dsar_general_defined_in "Defined in" + + key dsar_blocker_manual "Blocker, resolve manually" + key dsar_blocker_uninstall_blocked_after "Blocker, uninstall blocked after" + key dsar_blocker_uninstall_blocked_before "Blocker, uninstall blocked before" + key dsar_blocker_upgrade_blocked_before "Blocker, upgrade blocked before" + + key dsar_myoptions_requires "MYOPTIONS, requires" + key dsar_myoptions_n_at_least_one "MYOPTIONS, at least one" + key dsar_myoptions_n_at_most_one "MYOPTIONS, at most one" + key dsar_myoptions_n_exactly_one "MYOPTIONS, exactly one" + + want_destringify + + doxygen_comment << "END" + /** + * Role for a DepSpecAnnotation. + * + * \ingroup g_dep_spec + * \since 0.58 + */ +END +} + diff --git a/paludis/files.m4 b/paludis/files.m4 index df5c706f8..e2b809a3e 100644 --- a/paludis/files.m4 +++ b/paludis/files.m4 @@ -26,7 +26,7 @@ add(`contents', `hh', `cc', `fwd') add(`create_output_manager_info', `hh', `cc', `fwd', `se') add(`dep_label', `hh', `cc', `fwd') add(`dep_spec', `hh', `cc', `test', `fwd', `se') -add(`dep_spec_annotations', `hh', `cc', `fwd') +add(`dep_spec_annotations', `hh', `cc', `fwd', `se') add(`dep_spec_data', `hh', `cc', `fwd') add(`dep_spec_flattener', `hh', `cc') add(`dep_tag', `hh', `cc', `fwd') diff --git a/paludis/repositories/e/dep_parser.cc b/paludis/repositories/e/dep_parser.cc index ce134b257..da5ea158f 100644 --- a/paludis/repositories/e/dep_parser.cc +++ b/paludis/repositories/e/dep_parser.cc @@ -338,54 +338,115 @@ namespace { } - void set_annotations( + void set_annotations_block( + const EAPI & eapi, std::shared_ptr<DepSpec> & spec, + std::shared_ptr<BlockDepSpec> & if_block_spec, const std::shared_ptr<const Map<std::string, std::string> > & m) { auto annotations(std::make_shared<DepSpecAnnotations>()); for (auto k(m->begin()), k_end(m->end()) ; k != k_end ; ++k) + { + if (k->first.empty()) + continue; + + DepSpecAnnotationRole role(dsar_none); + + /* blocks */ + if (if_block_spec && (! eapi.supported()->annotations()->blocker_resolution().empty())) + { + if (k->first == eapi.supported()->annotations()->blocker_resolution()) + { + if (k->second.empty()) + { + } + else if (k->second == eapi.supported()->annotations()->blocker_resolution_manual()) + { + if_block_spec->set_block_kind(bk_manual); + role = dsar_blocker_manual; + } + else if (k->second == eapi.supported()->annotations()->blocker_resolution_uninstall_blocked_after()) + { + if_block_spec->set_block_kind(bk_uninstall_blocked_after); + role = dsar_blocker_uninstall_blocked_after; + } + else if (k->second == eapi.supported()->annotations()->blocker_resolution_uninstall_blocked_before()) + { + if_block_spec->set_block_kind(bk_uninstall_blocked_before); + role = dsar_blocker_uninstall_blocked_before; + } + else if (k->second == eapi.supported()->annotations()->blocker_resolution_upgrade_blocked_before()) + { + if_block_spec->set_block_kind(bk_upgrade_blocked_before); + role = dsar_blocker_upgrade_blocked_before; + } + else + throw EDepParseError(stringify(*if_block_spec), "Unknown value '" + k->second + "' for annotation '" + k->first + "'"); + } + } + + /* myoptions number-selected */ + if (dsar_none == role) + { + if (k->first == eapi.supported()->annotations()->myoptions_number_selected()) + { + if (k->second.empty()) + { + } + else if (k->second == eapi.supported()->annotations()->myoptions_number_selected_at_least_one()) + role = dsar_myoptions_n_at_least_one; + else if (k->second == eapi.supported()->annotations()->myoptions_number_selected_at_most_one()) + role = dsar_myoptions_n_at_most_one; + else if (k->second == eapi.supported()->annotations()->myoptions_number_selected_exactly_one()) + role = dsar_myoptions_n_exactly_one; + else + throw EDepParseError(k->first, "Unknown value '" + k->second + "' for annotation '" + k->first + "'"); + } + } + + /* myoptions requires */ + if (dsar_none == role) + { + if (k->first == eapi.supported()->annotations()->myoptions_requires()) + role = dsar_myoptions_requires; + } + + /* general */ + if (dsar_none == role) + { + if (k->first == eapi.supported()->annotations()->general_description()) + role = dsar_general_description; + else if (k->first == eapi.supported()->annotations()->general_url()) + role = dsar_general_url; + else if (k->first == eapi.supported()->annotations()->general_note()) + role = dsar_general_note; + else if (k->first == eapi.supported()->annotations()->general_lang()) + role = dsar_general_lang; + else if (k->first == eapi.supported()->ebuild_options()->bracket_merged_variables_annotation()) + role = dsar_general_defined_in; + } + + if (dsar_none == role) + Log::get_instance()->message("e.dep_parser.unknown_annotation", ll_qa, lc_context) + << "Unknown annotation '" << k->first << "' = '" << k->second << "'"; + annotations->add(make_named_values<DepSpecAnnotation>( n::key() = k->first, + n::role() = role, n::value() = k->second)); + } + spec->set_annotations(annotations); } - void set_annotations_block( + void set_annotations( const EAPI & eapi, std::shared_ptr<DepSpec> & spec, - std::shared_ptr<BlockDepSpec> & if_block_spec, const std::shared_ptr<const Map<std::string, std::string> > & m) { - auto annotations(std::make_shared<DepSpecAnnotations>()); - for (auto k(m->begin()), k_end(m->end()) ; - k != k_end ; ++k) - annotations->add(make_named_values<DepSpecAnnotation>( - n::key() = k->first, - n::value() = k->second)); - spec->set_annotations(annotations); - - if (if_block_spec && (! eapi.supported()->annotations()->blocker_resolution().empty()) - && if_block_spec->maybe_annotations()) - { - auto a(if_block_spec->maybe_annotations()->find(eapi.supported()->annotations()->blocker_resolution())); - if (a != if_block_spec->maybe_annotations()->end()) - { - if (a->value().empty()) - { - } - else if (a->value() == eapi.supported()->annotations()->blocker_resolution_manual()) - if_block_spec->set_block_kind(bk_manual); - else if (a->value() == eapi.supported()->annotations()->blocker_resolution_uninstall_blocked_after()) - if_block_spec->set_block_kind(bk_uninstall_blocked_after); - else if (a->value() == eapi.supported()->annotations()->blocker_resolution_uninstall_blocked_before()) - if_block_spec->set_block_kind(bk_uninstall_blocked_before); - else if (a->value() == eapi.supported()->annotations()->blocker_resolution_upgrade_blocked_before()) - if_block_spec->set_block_kind(bk_upgrade_blocked_before); - else - throw EDepParseError(stringify(*if_block_spec), "Unknown value '" + a->value() + "' for annotation '" + a->key() + "'"); - } - } + std::shared_ptr<BlockDepSpec> not_block; + set_annotations_block(eapi, spec, not_block, m); } void set_thing_to_annotate(std::shared_ptr<DepSpec> & spec, const std::shared_ptr<DepSpec> & s) @@ -466,7 +527,7 @@ paludis::erepository::parse_provide(const std::string & s, ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( n::on_all() = std::bind(&any_all_handler<ProvideSpecTree, AllDepSpec>, std::ref(stack)), - n::on_annotations() = std::bind(&set_annotations, std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&set_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), n::on_error() = std::bind(&error_handler, s, _1), @@ -506,7 +567,7 @@ paludis::erepository::parse_fetchable_uri(const std::string & s, ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( n::on_all() = std::bind(&any_all_handler<FetchableURISpecTree, AllDepSpec>, std::ref(stack)), - n::on_annotations() = std::bind(&set_annotations, std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&set_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrow_handler<FetchableURISpecTree>, std::ref(stack), ParseStackTypes<FetchableURISpecTree>::AnnotationsGoHere(std::bind( @@ -550,7 +611,7 @@ paludis::erepository::parse_simple_uri(const std::string & s, ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( n::on_all() = std::bind(&any_all_handler<SimpleURISpecTree, AllDepSpec>, std::ref(stack)), - n::on_annotations() = std::bind(&set_annotations, std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&set_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), n::on_error() = std::bind(&error_handler, s, _1), @@ -590,7 +651,7 @@ paludis::erepository::parse_license(const std::string & s, ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( n::on_all() = std::bind(&any_all_handler<LicenseSpecTree, AllDepSpec>, std::ref(stack)), - n::on_annotations() = std::bind(&set_annotations, std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&set_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_all_handler<LicenseSpecTree, AnyDepSpec>, std::ref(stack)), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), n::on_error() = std::bind(&error_handler, s, _1), @@ -630,7 +691,7 @@ paludis::erepository::parse_plain_text(const std::string & s, ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( n::on_all() = std::bind(&any_all_handler<PlainTextSpecTree, AllDepSpec>, std::ref(stack)), - n::on_annotations() = std::bind(&set_annotations, std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&set_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), n::on_error() = std::bind(&error_handler, s, _1), @@ -670,7 +731,7 @@ paludis::erepository::parse_myoptions(const std::string & s, ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( n::on_all() = std::bind(&any_all_handler<PlainTextSpecTree, AllDepSpec>, std::ref(stack)), - n::on_annotations() = std::bind(&set_annotations, std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&set_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), n::on_error() = std::bind(&error_handler, s, _1), @@ -712,7 +773,7 @@ paludis::erepository::parse_required_use(const std::string & s, ELikeDepParserCallbacks callbacks( make_named_values<ELikeDepParserCallbacks>( n::on_all() = std::bind(&any_all_handler<RequiredUseSpecTree, AllDepSpec>, std::ref(stack)), - n::on_annotations() = std::bind(&set_annotations, std::ref(thing_to_annotate), _1), + n::on_annotations() = std::bind(&set_annotations, std::cref(eapi), std::ref(thing_to_annotate), _1), n::on_any() = std::bind(&any_all_handler<RequiredUseSpecTree, AnyDepSpec>, std::ref(stack)), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), n::on_error() = std::bind(&error_handler, s, _1), diff --git a/paludis/repositories/e/e_choices_key.cc b/paludis/repositories/e/e_choices_key.cc index ccd125873..a9cd8b858 100644 --- a/paludis/repositories/e/e_choices_key.cc +++ b/paludis/repositories/e/e_choices_key.cc @@ -126,9 +126,8 @@ namespace struct MyOptionsFinder { - typedef std::map<std::string, std::string> Annotations; - typedef std::map<UnprefixedChoiceName, Annotations> Values; - typedef std::map<ChoicePrefixName, Values> Prefixes; + typedef std::map<UnprefixedChoiceName, std::string> Descriptions; + typedef std::map<ChoicePrefixName, Descriptions> Prefixes; Prefixes prefixes; std::list<ChoicePrefixName> current_prefix_stack; @@ -147,22 +146,22 @@ namespace Prefixes::iterator p(prefixes.find(*current_prefix_stack.begin())); if (p == prefixes.end()) - p = prefixes.insert(std::make_pair(*current_prefix_stack.begin(), Values())).first; + p = prefixes.insert(std::make_pair(*current_prefix_stack.begin(), Descriptions())).first; UnprefixedChoiceName n(parse_myoption(node.spec()->text()).first); if (std::string::npos != stringify(n).find(':')) throw MyOptionsError("Flag '" + stringify(n) + "' must not contain a ':'"); - Values::iterator v(p->second.find(n)); - if (v == p->second.end()) - v = p->second.insert(std::make_pair(n, Annotations())).first; - if (node.spec()->maybe_annotations()) { - for (auto m(node.spec()->maybe_annotations()->begin()), m_end(node.spec()->maybe_annotations()->end()) ; - m != m_end ; ++m) - v->second.insert(make_pair(m->key(), m->value())); + auto m_role(node.spec()->maybe_annotations()->find(dsar_general_description)); + if (m_role != node.spec()->maybe_annotations()->end()) + p->second.insert(std::make_pair(n, m_role->value())).first->second = m_role->value(); + else + p->second.insert(std::make_pair(n, "")); } + else + p->second.insert(std::make_pair(n, "")); } void visit(const PlainTextSpecTree::NodeType<PlainTextLabelDepSpec>::Type & node) @@ -191,18 +190,12 @@ namespace std::shared_ptr<ChoiceValue> make_myoption( const std::shared_ptr<const ERepositoryID> & id, std::shared_ptr<Choice> & choice, - MyOptionsFinder::Values::const_iterator & v, + const UnprefixedChoiceName & unprefixed, + const std::string & description, const Tribool s, const bool b) { - std::string description; - for (MyOptionsFinder::Annotations::const_iterator a(v->second.begin()), a_end(v->second.end()) ; - a != a_end ; ++a) - { - if (a->first == id->eapi()->supported()->annotations()->myoptions_description()) - description = a->second; - } - return id->make_choice_value(choice, v->first, s, false, b, description, false); + return id->make_choice_value(choice, unprefixed, s, false, b, description, false); } std::string get_maybe_description(const std::shared_ptr<const Map<ChoiceNameWithPrefix, std::string> > & m, @@ -331,9 +324,9 @@ EChoicesKey::populate_myoptions() const MyOptionsFinder::Prefixes::iterator p(myoptions.prefixes.find(ChoicePrefixName(lower_u))); if (myoptions.prefixes.end() != p) { - for (MyOptionsFinder::Values::const_iterator v(p->second.begin()), v_end(p->second.end()) ; + 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, indeterminate, true)); + exp->add(make_myoption(_imp->id, exp, v->first, v->second, indeterminate, true)); myoptions.prefixes.erase(p); } } @@ -342,9 +335,9 @@ EChoicesKey::populate_myoptions() const if (myoptions.prefixes.end() != p) { Context local_local_context("When using empty prefix to populate choices:"); - for (MyOptionsFinder::Values::const_iterator v(p->second.begin()), v_end(p->second.end()) ; + 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, indeterminate, true)); + options->add(make_myoption(_imp->id, options, v->first, v->second, indeterminate, true)); myoptions.prefixes.erase(p); } diff --git a/paludis/repositories/e/eapi.cc b/paludis/repositories/e/eapi.cc index d5dcae89b..defdd837e 100644 --- a/paludis/repositories/e/eapi.cc +++ b/paludis/repositories/e/eapi.cc @@ -251,7 +251,10 @@ namespace n::blocker_resolution_uninstall_blocked_after() = k.get("annotations_blocker_resolution_uninstall_blocked_after"), n::blocker_resolution_uninstall_blocked_before() = k.get("annotations_blocker_resolution_uninstall_blocked_before"), n::blocker_resolution_upgrade_blocked_before() = k.get("annotations_blocker_resolution_upgrade_blocked_before"), - n::myoptions_description() = k.get("annotations_myoptions_description"), + n::general_description() = k.get("annotations_general_description"), + n::general_lang() = k.get("annotations_general_lang"), + n::general_note() = k.get("annotations_general_note"), + n::general_url() = k.get("annotations_general_url"), n::myoptions_number_selected() = k.get("annotations_myoptions_number_selected"), n::myoptions_number_selected_at_least_one() = k.get("annotations_myoptions_number_selected_at_least_one"), n::myoptions_number_selected_at_most_one() = k.get("annotations_myoptions_number_selected_at_most_one"), diff --git a/paludis/repositories/e/eapi.hh b/paludis/repositories/e/eapi.hh index 9a64fd183..89377f4d8 100644 --- a/paludis/repositories/e/eapi.hh +++ b/paludis/repositories/e/eapi.hh @@ -123,6 +123,10 @@ namespace paludis typedef Name<struct fancy_test_flag_name> fancy_test_flag; typedef Name<struct fix_mtimes_name> fix_mtimes; typedef Name<struct flat_list_index_name> flat_list_index; + typedef Name<struct general_description_name> general_description; + typedef Name<struct general_lang_name> general_lang; + typedef Name<struct general_note_name> general_note; + typedef Name<struct general_url_name> general_url; typedef Name<struct generated_from_name> generated_from; typedef Name<struct generated_time_name> generated_time; typedef Name<struct generated_using_name> generated_using; @@ -145,7 +149,6 @@ namespace paludis typedef Name<struct metadata_key_name> metadata_key; typedef Name<struct minimum_flat_list_size_name> minimum_flat_list_size; typedef Name<struct myoptions_name> myoptions; - typedef Name<struct myoptions_description_name> myoptions_description; typedef Name<struct myoptions_number_selected_name> myoptions_number_selected; typedef Name<struct myoptions_number_selected_at_least_one_name> myoptions_number_selected_at_least_one; typedef Name<struct myoptions_number_selected_at_most_one_name> myoptions_number_selected_at_most_one; @@ -464,7 +467,10 @@ namespace paludis NamedValue<n::blocker_resolution_uninstall_blocked_after, std::string> blocker_resolution_uninstall_blocked_after; NamedValue<n::blocker_resolution_uninstall_blocked_before, std::string> blocker_resolution_uninstall_blocked_before; NamedValue<n::blocker_resolution_upgrade_blocked_before, std::string> blocker_resolution_upgrade_blocked_before; - NamedValue<n::myoptions_description, std::string> myoptions_description; + NamedValue<n::general_description, std::string> general_description; + NamedValue<n::general_lang, std::string> general_lang; + NamedValue<n::general_note, std::string> general_note; + NamedValue<n::general_url, std::string> general_url; NamedValue<n::myoptions_number_selected, std::string> myoptions_number_selected; NamedValue<n::myoptions_number_selected_at_least_one, std::string> myoptions_number_selected_at_least_one; NamedValue<n::myoptions_number_selected_at_most_one, std::string> myoptions_number_selected_at_most_one; diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf index e27ab1815..7ab56bb85 100644 --- a/paludis/repositories/e/eapis/exheres-0.conf +++ b/paludis/repositories/e/eapis/exheres-0.conf @@ -356,7 +356,10 @@ annotations_blocker_resolution_manual = manual annotations_blocker_resolution_uninstall_blocked_after = uninstall-blocked-after annotations_blocker_resolution_uninstall_blocked_before = uninstall-blocked-before annotations_blocker_resolution_upgrade_blocked_before = upgrade-blocked-before -annotations_myoptions_description = description +annotations_general_description = description +annotations_general_lang = lang +annotations_general_note = note +annotations_general_url = url annotations_myoptions_requires = requires annotations_myoptions_number_selected = number-selected annotations_myoptions_number_selected_at_least_one = at-least-one diff --git a/paludis/repositories/e/myoptions_requirements_verifier.cc b/paludis/repositories/e/myoptions_requirements_verifier.cc index d78afcae4..eeac771d2 100644 --- a/paludis/repositories/e/myoptions_requirements_verifier.cc +++ b/paludis/repositories/e/myoptions_requirements_verifier.cc @@ -141,83 +141,76 @@ MyOptionsRequirementsVerifier::verify_one( for (auto m(annotations->begin()), m_end(annotations->end()) ; m != m_end ; ++m) { - std::string a_key(m->key()), a_value(m->value()); - - if (a_key == _imp->id->eapi()->supported()->annotations()->myoptions_description()) - { - } - else if (a_key == _imp->id->eapi()->supported()->annotations()->myoptions_number_selected()) - { - } - else if (a_key == _imp->id->eapi()->supported()->ebuild_options()->bracket_merged_variables_annotation()) + switch (m->role()) { - } - else if (a_key == _imp->id->eapi()->supported()->annotations()->myoptions_requires()) - { - std::list<std::string> tokens; - tokenise_whitespace(a_value, std::back_inserter(tokens)); - ChoicePrefixName prefix(""); - for (std::list<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end()) ; - t != t_end ; ++t) - { - if (t->empty()) - continue; - - if (':' == t->at(t->length() - 1)) + case dsar_myoptions_requires: { - prefix = ChoicePrefixName(t->substr(0, t->length() - 1)); - continue; - } - - bool req_state(true); - std::string req_flag_s(*t); - if ('-' == req_flag_s.at(0)) - { - req_state = false; - req_flag_s.erase(0, 1); - } - - UnprefixedChoiceName suffix(req_flag_s); - - std::shared_ptr<const ChoiceValue> choice_value; - if (_imp->id->choices_key()) - for (Choices::ConstIterator k(_imp->id->choices_key()->value()->begin()), - k_end(_imp->id->choices_key()->value()->end()) ; - k != k_end && ! choice_value ; ++k) + std::list<std::string> tokens; + tokenise_whitespace(m->value(), std::back_inserter(tokens)); + ChoicePrefixName prefix(""); + for (std::list<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end()) ; + t != t_end ; ++t) { - if ((*k)->prefix() != prefix) + if (t->empty()) continue; - for (Choice::ConstIterator i((*k)->begin()), i_end((*k)->end()) ; - i != i_end && ! choice_value ; ++i) - if ((*i)->unprefixed_name() == suffix) - choice_value = *i; - } - - if (choice_value) - { - if (choice_value->enabled() != req_state) - { - _imp->unmet_requirements->push_back(stringify(active_myoption.second ? "Enabling" : "Disabling") + - " option '" + stringify(active_flag) + "' requires option '" + - stringify(choice_value->name_with_prefix()) + "' to be " + - (req_state ? "enabled" : "disabled")); + if (':' == t->at(t->length() - 1)) + { + prefix = ChoicePrefixName(t->substr(0, t->length() - 1)); + continue; + } + + bool req_state(true); + std::string req_flag_s(*t); + if ('-' == req_flag_s.at(0)) + { + req_state = false; + req_flag_s.erase(0, 1); + } + + UnprefixedChoiceName suffix(req_flag_s); + + std::shared_ptr<const ChoiceValue> choice_value; + if (_imp->id->choices_key()) + for (Choices::ConstIterator k(_imp->id->choices_key()->value()->begin()), + k_end(_imp->id->choices_key()->value()->end()) ; + k != k_end && ! choice_value ; ++k) + { + if ((*k)->prefix() != prefix) + continue; + + for (Choice::ConstIterator i((*k)->begin()), i_end((*k)->end()) ; + i != i_end && ! choice_value ; ++i) + if ((*i)->unprefixed_name() == suffix) + choice_value = *i; + } + + if (choice_value) + { + if (choice_value->enabled() != req_state) + { + _imp->unmet_requirements->push_back(stringify(active_myoption.second ? "Enabling" : "Disabling") + + " option '" + stringify(active_flag) + "' requires option '" + + stringify(choice_value->name_with_prefix()) + "' to be " + + (req_state ? "enabled" : "disabled")); + } + } + else + { + /* ick */ + ChoiceNameWithPrefix qualified_flag_name((stringify(prefix).empty() ? "" : stringify(prefix) + + stringify(_imp->id->eapi()->supported()->choices_options()->use_expand_separator())) + stringify(suffix)); + _imp->unmet_requirements->push_back(stringify(active_myoption.second ? "Enabling" : "Disabling") + + " option '" + stringify(active_flag) + "' requires option '" + stringify(qualified_flag_name) + "' to be " + + (req_state ? "enabled" : "disabled") + ", but no such option exists"); + } } } - else - { - /* ick */ - ChoiceNameWithPrefix qualified_flag_name((stringify(prefix).empty() ? "" : stringify(prefix) + - stringify(_imp->id->eapi()->supported()->choices_options()->use_expand_separator())) + stringify(suffix)); - _imp->unmet_requirements->push_back(stringify(active_myoption.second ? "Enabling" : "Disabling") + - " option '" + stringify(active_flag) + "' requires option '" + stringify(qualified_flag_name) + "' to be " + - (req_state ? "enabled" : "disabled") + ", but no such option exists"); - } - } + break; + + default: + break; } - else - Log::get_instance()->message("e.myoptions_requirements_verifier.unknown_annotation", ll_warning, lc_context) - << "Unknown annotation '" << a_key << "' = '" << a_value << "' on option '" << spec_text << "'"; } } @@ -287,45 +280,52 @@ MyOptionsRequirementsVerifier::visit(const PlainTextSpecTree::NodeType<AllDepSpe for (auto m(node.spec()->maybe_annotations()->begin()), m_end(node.spec()->maybe_annotations()->end()) ; m != m_end ; ++m) { - std::string a_key(m->key()), a_value(m->value()); - - if (a_key == _imp->id->eapi()->supported()->annotations()->myoptions_number_selected()) + switch (m->role()) { - std::string children_s; - for (ChildrenList::const_iterator i(_imp->current_children_stack.begin()->begin()), - i_end(_imp->current_children_stack.begin()->end()) ; - i != i_end ; ++i) - { - if (! children_s.empty()) - children_s.append(", "); - - if (! stringify(i->first).empty()) + case dsar_myoptions_n_at_least_one: + case dsar_myoptions_n_at_most_one: + case dsar_myoptions_n_exactly_one: { - children_s.append(stringify(i->first)); - children_s.append(stringify(_imp->id->eapi()->supported()->choices_options()->use_expand_separator())); + std::string children_s; + for (ChildrenList::const_iterator i(_imp->current_children_stack.begin()->begin()), + i_end(_imp->current_children_stack.begin()->end()) ; + i != i_end ; ++i) + { + if (! children_s.empty()) + children_s.append(", "); + + if (! stringify(i->first).empty()) + { + children_s.append(stringify(i->first)); + children_s.append(stringify(_imp->id->eapi()->supported()->choices_options()->use_expand_separator())); + } + children_s.append(stringify(i->second)); + } + + children_s = "( " + children_s + " )"; + + if (dsar_myoptions_n_at_least_one != m->role()) + { + if (*_imp->number_enabled_stack.begin() < 1) + _imp->unmet_requirements->push_back("At least one of options " + children_s + " must be met"); + } + else if (dsar_myoptions_n_at_most_one != m->role()) + { + if (*_imp->number_enabled_stack.begin() > 1) + _imp->unmet_requirements->push_back("At most one of options " + children_s + " must be met"); + } + else if (dsar_myoptions_n_exactly_one != m->role()) + { + if (*_imp->number_enabled_stack.begin() != 1) + _imp->unmet_requirements->push_back("Exactly one of options " + children_s + " must be met"); + } + else + _imp->unmet_requirements->push_back("Don't know what '" + stringify(m->value()) + "' means"); } - children_s.append(stringify(i->second)); - } - - children_s = "( " + children_s + " )"; + break; - if (a_value == _imp->id->eapi()->supported()->annotations()->myoptions_number_selected_at_least_one()) - { - if (*_imp->number_enabled_stack.begin() < 1) - _imp->unmet_requirements->push_back("At least one of options " + children_s + " must be met"); - } - else if (a_value == _imp->id->eapi()->supported()->annotations()->myoptions_number_selected_at_most_one()) - { - if (*_imp->number_enabled_stack.begin() > 1) - _imp->unmet_requirements->push_back("At most one of options " + children_s + " must be met"); - } - else if (a_value == _imp->id->eapi()->supported()->annotations()->myoptions_number_selected_exactly_one()) - { - if (*_imp->number_enabled_stack.begin() != 1) - _imp->unmet_requirements->push_back("Exactly one of options " + children_s + " must be met"); - } - else - _imp->unmet_requirements->push_back("Don't know what '" + stringify(a_value) + "' means"); + default: + break; } } } diff --git a/paludis/repositories/e/pipe_command_handler.cc b/paludis/repositories/e/pipe_command_handler.cc index 1314c1926..d7e048fff 100644 --- a/paludis/repositories/e/pipe_command_handler.cc +++ b/paludis/repositories/e/pipe_command_handler.cc @@ -130,7 +130,7 @@ namespace str << m->key() << " = [" << (m->value().empty() ? " " : " " + m->value() + " ") << "] "; - if (m->key() == description_annotation) + if (m->role() == dsar_general_description) seen_description = true; } @@ -490,7 +490,7 @@ paludis::erepository::pipe_command_handler(const Environment * const environment StringifyFormatter ff; MyOptionsRewriter p(package_id, - eapi->supported()->annotations()->myoptions_description(), + eapi->supported()->annotations()->general_description(), std::string(1, eapi->supported()->choices_options()->use_expand_separator())); mm->value()->top()->accept(p); return "O0;" + p.str.str(); diff --git a/paludis/resolver/package_or_block_dep_spec.cc b/paludis/resolver/package_or_block_dep_spec.cc index 23ad5349b..059031ea4 100644 --- a/paludis/resolver/package_or_block_dep_spec.cc +++ b/paludis/resolver/package_or_block_dep_spec.cc @@ -89,6 +89,7 @@ PackageOrBlockDepSpec::serialise(Serialiser & s) const { w.member(SerialiserFlags<>(), "annotations_k_" + stringify(n), m->key()); w.member(SerialiserFlags<>(), "annotations_v_" + stringify(n), m->value()); + w.member(SerialiserFlags<>(), "annotations_r_" + stringify(n), stringify(m->role())); ++n; } @@ -120,8 +121,10 @@ PackageOrBlockDepSpec::deserialise(Deserialisation & d, const std::shared_ptr<co { std::string key(v.member<std::string>("annotations_k_" + stringify(a))); std::string value(v.member<std::string>("annotations_v_" + stringify(a))); + std::string role(v.member<std::string>("annotations_r_" + stringify(a))); annotations->add(make_named_values<DepSpecAnnotation>( n::key() = key, + n::role() = destringify<DepSpecAnnotationRole>(role), n::value() = value )); } |