diff options
author | 2012-11-16 00:18:17 +0000 | |
---|---|---|
committer | 2012-11-16 22:28:15 +0000 | |
commit | 4d0e01e9f2490ca7be09ef4c3424dbb9f7a64e45 (patch) | |
tree | 14dd4a9f1f8626eed072acb28db65a5a68bfaf9a | |
parent | a48b2c55c744a8a8c04464533b482302f838102b (diff) | |
download | paludis-4d0e01e9f2490ca7be09ef4c3424dbb9f7a64e45.tar.gz paludis-4d0e01e9f2490ca7be09ef4c3424dbb9f7a64e45.tar.xz |
Parse/generate SlotUnknownRewrittenRequirement in Gentoo EAPIs
-rw-r--r-- | paludis/elike_package_dep_spec.cc | 47 | ||||
-rw-r--r-- | paludis/elike_package_dep_spec.se | 3 | ||||
-rw-r--r-- | paludis/elike_slot_requirement-fwd.hh | 1 | ||||
-rw-r--r-- | paludis/elike_slot_requirement.cc | 31 | ||||
-rw-r--r-- | paludis/elike_slot_requirement.hh | 14 | ||||
-rw-r--r-- | paludis/repositories/e/eapis/5.conf | 2 | ||||
-rw-r--r-- | paludis/repositories/e/fix_locked_dependencies.cc | 12 | ||||
-rw-r--r-- | paludis/resolver/package_or_block_dep_spec.cc | 3 | ||||
-rw-r--r-- | paludis/serialise.cc | 3 |
9 files changed, 106 insertions, 10 deletions
diff --git a/paludis/elike_package_dep_spec.cc b/paludis/elike_package_dep_spec.cc index aa4663a1f..23f227f89 100644 --- a/paludis/elike_package_dep_spec.cc +++ b/paludis/elike_package_dep_spec.cc @@ -299,7 +299,7 @@ paludis::elike_remove_trailing_slot_if_exists(std::string & s, PartiallyMadePack } else if ('=' == match.at(0)) { - if (! options[epdso_allow_slot_equal_deps]) + if (! options[epdso_allow_slot_equal_deps] && ! options[epdso_allow_slot_equal_deps_portage]) { if (options[epdso_strict_parsing]) throw PackageDepSpecError("Slot '=' dependencies not safe for use here"); @@ -315,6 +315,15 @@ paludis::elike_remove_trailing_slot_if_exists(std::string & s, PartiallyMadePack } else { + if (! options[epdso_allow_slot_equal_deps]) + { + if (options[epdso_strict_parsing]) + throw PackageDepSpecError("Slot '=slot' or '=slot/sub' dependencies not safe for use here"); + else + Log::get_instance()->message("e.package_dep_spec.slot_equals_non_portage_not_allowed", ll_warning, lc_context) + << "Slot '=slot' or '=slot/sub' dependencies not safe for use here"; + } + std::string text(s.substr(slot_p + 2)); auto p(text.find('/')); if (options[epdso_allow_subslot_deps] && std::string::npos != p) @@ -344,20 +353,50 @@ paludis::elike_remove_trailing_slot_if_exists(std::string & s, PartiallyMadePack std::string text(s.substr(slot_p + 1)); auto q(text.find('=')); - if (options[epdso_allow_subslot_deps] && options[epdso_allow_slot_equal_deps] && std::string::npos != q) + if (options[epdso_allow_subslot_deps] + && (options[epdso_allow_slot_equal_deps] || options[epdso_allow_slot_equal_deps_portage]) + && std::string::npos != q) { std::string left_text(text.substr(0, q)), right_text(text.substr(q + 1)); auto p(right_text.find('/')); if (std::string::npos != p) { + if (! options[epdso_allow_slot_equal_deps]) + { + if (options[epdso_strict_parsing]) + throw PackageDepSpecError("Slot 'slot=slot/sub' dependencies not safe for use here"); + else + Log::get_instance()->message("e.package_dep_spec.slot_equals_non_portage_not_allowed", ll_warning, lc_context) + << "Slot 'slot=slot/sub' dependencies not safe for use here"; + } + /* c/p:l=s/u */ result.slot_requirement(std::make_shared<ELikeSlotExactFullRequirement>(std::make_pair(SlotName(right_text.substr(0, p)), SlotName(right_text.substr(p + 1))), std::make_shared<ELikeSlotAnyPartialLockedRequirement>(SlotName(left_text)))); } else if (right_text.empty()) { - /* c/p:l= */ - result.slot_requirement(std::make_shared<ELikeSlotAnyPartialLockedRequirement>(SlotName(left_text))); + auto r(left_text.find('/')); + if (std::string::npos != r) + { + if (! options[epdso_allow_slot_equal_deps_portage]) + { + if (options[epdso_strict_parsing]) + throw PackageDepSpecError("Slot 'slot/sub=' dependencies not safe for use here"); + else + Log::get_instance()->message("e.package_dep_spec.slot_equals_portage_not_allowed", ll_warning, lc_context) + << "Slot 'slot/sub=' dependencies not safe for use here"; + } + + /* c/p:s/u= */ + result.slot_requirement(std::make_shared<ELikeSlotExactFullRequirement>(std::make_pair(SlotName(left_text.substr(0, r)), SlotName(left_text.substr(r + 1))), + std::make_shared<ELikeSlotUnknownRewrittenRequirement>(SlotName(left_text.substr(0, r))))); + } + else + { + /* c/p:l= */ + result.slot_requirement(std::make_shared<ELikeSlotAnyPartialLockedRequirement>(SlotName(left_text))); + } } else { diff --git a/paludis/elike_package_dep_spec.se b/paludis/elike_package_dep_spec.se index 25aaaf2e5..a82a75b57 100644 --- a/paludis/elike_package_dep_spec.se +++ b/paludis/elike_package_dep_spec.se @@ -8,7 +8,8 @@ make_enum_ELikePackageDepSpecOption() key epdso_allow_slot_deps "Allow :slot deps" key epdso_allow_slot_star_deps "Allow :* slot deps" - key epdso_allow_slot_equal_deps "Allow := and :=blah slot deps" + key epdso_allow_slot_equal_deps "Allow := and :blah= slot deps" + key epdso_allow_slot_equal_deps_portage "Allow := and :blah= slot deps with Portage rewriting rules" key epdso_allow_subslot_deps "Allow subslots in slot deps" key epdso_allow_repository_deps "Allow ::repo deps" key epdso_allow_use_deps "Allow [use] deps" diff --git a/paludis/elike_slot_requirement-fwd.hh b/paludis/elike_slot_requirement-fwd.hh index 8614d3ccc..0e21a639c 100644 --- a/paludis/elike_slot_requirement-fwd.hh +++ b/paludis/elike_slot_requirement-fwd.hh @@ -27,6 +27,7 @@ namespace paludis class ELikeSlotAnyAtAllLockedRequirement; class ELikeSlotAnyPartialLockedRequirement; class ELikeSlotAnyUnlockedRequirement; + class ELikeSlotUnknownRewrittenRequirement; } #endif diff --git a/paludis/elike_slot_requirement.cc b/paludis/elike_slot_requirement.cc index 90077e023..d5b9aa319 100644 --- a/paludis/elike_slot_requirement.cc +++ b/paludis/elike_slot_requirement.cc @@ -20,6 +20,7 @@ #include <paludis/elike_slot_requirement.hh> #include <paludis/util/stringify.hh> #include <paludis/util/make_null_shared_ptr.hh> +#include <paludis/util/visitor_cast.hh> using namespace paludis; @@ -33,7 +34,12 @@ const std::string ELikeSlotExactFullRequirement::as_string() const { if (_maybe_original_requirement_if_rewritten) - return _maybe_original_requirement_if_rewritten->as_string() + stringify(_s.first) + "/" + stringify(_s.second); + { + if (visitor_cast<const SlotUnknownRewrittenRequirement>(*_maybe_original_requirement_if_rewritten)) + return ":" + stringify(_s.first) + "/" + stringify(_s.second) + "="; + else + return _maybe_original_requirement_if_rewritten->as_string() + stringify(_s.first) + "/" + stringify(_s.second); + } else return ":" + stringify(_s.first) + "/" + stringify(_s.second); } @@ -124,3 +130,26 @@ ELikeSlotAnyPartialLockedRequirement::slot() const return _s; } +ELikeSlotUnknownRewrittenRequirement::ELikeSlotUnknownRewrittenRequirement(const SlotName & s) : + _s(s) +{ +} + +const std::string +ELikeSlotUnknownRewrittenRequirement::as_string() const +{ + throw InternalError(PALUDIS_HERE, "Should not be stringifying ELikeUnknownRewrittenSlotRequirement"); +} + +const std::shared_ptr<const SlotRequirement> +ELikeSlotUnknownRewrittenRequirement::maybe_original_requirement_if_rewritten() const +{ + return make_null_shared_ptr(); +} + +const SlotName +ELikeSlotUnknownRewrittenRequirement::slot() const +{ + return _s; +} + diff --git a/paludis/elike_slot_requirement.hh b/paludis/elike_slot_requirement.hh index bdc4f7b9f..a447ecb63 100644 --- a/paludis/elike_slot_requirement.hh +++ b/paludis/elike_slot_requirement.hh @@ -85,6 +85,20 @@ namespace paludis virtual const std::shared_ptr<const SlotRequirement> maybe_original_requirement_if_rewritten() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const SlotName slot() const PALUDIS_ATTRIBUTE((warn_unused_result)); }; + + class PALUDIS_VISIBLE ELikeSlotUnknownRewrittenRequirement : + public SlotUnknownRewrittenRequirement + { + private: + const SlotName _s; + + public: + ELikeSlotUnknownRewrittenRequirement(const SlotName &); + + virtual const std::string as_string() const PALUDIS_ATTRIBUTE((noreturn)); + virtual const std::shared_ptr<const SlotRequirement> maybe_original_requirement_if_rewritten() const PALUDIS_ATTRIBUTE((warn_unused_result)); + virtual const SlotName slot() const PALUDIS_ATTRIBUTE((warn_unused_result)); + }; } #endif diff --git a/paludis/repositories/e/eapis/5.conf b/paludis/repositories/e/eapis/5.conf index b09e5b094..91d51ac82 100644 --- a/paludis/repositories/e/eapis/5.conf +++ b/paludis/repositories/e/eapis/5.conf @@ -14,7 +14,7 @@ description_iuse = Listed relevant USE flags vdb_from_env_variables = ${vdb_from_env_variables} IUSE_EFFECTIVE package_dep_spec_parse_options = ${package_dep_spec_parse_options} \ - allow_slot_equal_deps allow_slot_star_deps allow_subslot_deps + allow_slot_equal_deps_portage allow_slot_star_deps allow_subslot_deps ebuild_module_suffixes = 5 4 3 2 1 0 utility_path_suffixes = 5 4 3 2 1 0 diff --git a/paludis/repositories/e/fix_locked_dependencies.cc b/paludis/repositories/e/fix_locked_dependencies.cc index e92edfbf1..faeb2be3b 100644 --- a/paludis/repositories/e/fix_locked_dependencies.cc +++ b/paludis/repositories/e/fix_locked_dependencies.cc @@ -86,7 +86,12 @@ namespace { auto ss((*matches->last())->slot_key()->parse_value()); if (eapi.supported()->ebuild_options()->has_subslots()) - return std::make_shared<ELikeSlotExactFullRequirement>(ss.match_values(), spec->slot_requirement_ptr()); + { + if (eapi.supported()->package_dep_spec_parse_options()[epdso_allow_slot_equal_deps]) + return std::make_shared<ELikeSlotExactFullRequirement>(ss.match_values(), spec->slot_requirement_ptr()); + else + return std::make_shared<ELikeSlotExactFullRequirement>(ss.match_values(), std::make_shared<ELikeSlotUnknownRewrittenRequirement>(ss.match_values().first)); + } else return std::make_shared<ELikeSlotExactPartialRequirement>(ss.match_values().first, spec->slot_requirement_ptr()); } @@ -103,6 +108,11 @@ namespace { return rewrite(); } + + std::shared_ptr<const SlotRequirement> visit(const SlotUnknownRewrittenRequirement &) const PALUDIS_ATTRIBUTE((noreturn)) + { + throw InternalError(PALUDIS_HERE, "Should not be rewriting SlotUnknownRewrittenRequirement"); + } }; struct Fixer diff --git a/paludis/resolver/package_or_block_dep_spec.cc b/paludis/resolver/package_or_block_dep_spec.cc index 36cee2fe8..87b63614a 100644 --- a/paludis/resolver/package_or_block_dep_spec.cc +++ b/paludis/resolver/package_or_block_dep_spec.cc @@ -109,7 +109,8 @@ PackageOrBlockDepSpec::deserialise(Deserialisation & d, const std::shared_ptr<co { epdso_allow_tilde_greater_deps, epdso_nice_equal_star, epdso_allow_ranged_deps, epdso_allow_use_deps, epdso_allow_use_deps_portage, epdso_allow_use_dep_defaults, epdso_allow_repository_deps, epdso_allow_slot_star_deps, - epdso_allow_slot_equal_deps, epdso_allow_slot_deps, epdso_allow_key_requirements, + epdso_allow_slot_equal_deps, epdso_allow_slot_equal_deps_portage, + epdso_allow_slot_deps, epdso_allow_key_requirements, epdso_allow_use_dep_question_defaults, epdso_allow_subslot_deps }, { vso_flexible_dashes, vso_flexible_dots, vso_ignore_case, vso_letters_anywhere, vso_dotted_suffixes })); diff --git a/paludis/serialise.cc b/paludis/serialise.cc index 85277eed9..75657bacb 100644 --- a/paludis/serialise.cc +++ b/paludis/serialise.cc @@ -374,7 +374,8 @@ DeserialisatorHandler<std::shared_ptr<const PackageID> >::handle(Deserialisation { epdso_allow_tilde_greater_deps, epdso_nice_equal_star, epdso_allow_ranged_deps, epdso_allow_use_deps, epdso_allow_use_deps_portage, epdso_allow_use_dep_defaults, epdso_allow_repository_deps, epdso_allow_slot_star_deps, - epdso_allow_slot_equal_deps, epdso_allow_slot_deps, epdso_allow_key_requirements, + epdso_allow_slot_equal_deps, epdso_allow_slot_equal_deps_portage, + epdso_allow_slot_deps, epdso_allow_key_requirements, epdso_allow_use_dep_question_defaults, epdso_allow_subslot_deps }, { vso_flexible_dashes, vso_flexible_dots, vso_ignore_case, vso_letters_anywhere, vso_dotted_suffixes }), make_null_shared_ptr(), { }))]->begin(); |