diff options
25 files changed, 117 insertions, 52 deletions
diff --git a/paludis/dep_spec-fwd.hh b/paludis/dep_spec-fwd.hh index 4bc9409d8..fb968411b 100644 --- a/paludis/dep_spec-fwd.hh +++ b/paludis/dep_spec-fwd.hh @@ -32,6 +32,9 @@ namespace paludis { + +#include <paludis/dep_spec-se.hh> + class DepSpec; class PackageDepSpec; class PlainTextDepSpec; diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc index 4221d4662..419dd2a23 100644 --- a/paludis/dep_spec.cc +++ b/paludis/dep_spec.cc @@ -45,6 +45,8 @@ using namespace paludis; +#include <paludis/dep_spec-se.cc> + namespace paludis { template <> @@ -252,17 +254,17 @@ NamedSetDepSpec::need_keys_added() const { } -BlockDepSpec::BlockDepSpec(const std::string & s, const PackageDepSpec & p, const bool t) : +BlockDepSpec::BlockDepSpec(const std::string & s, const PackageDepSpec & p, const BlockKind k) : StringDepSpec(s), _spec(p), - _strong(t) + _kind(k) { } BlockDepSpec::BlockDepSpec(const BlockDepSpec & other) : StringDepSpec(other.text()), _spec(other._spec), - _strong(other._strong) + _kind(other._kind) { } @@ -450,10 +452,10 @@ BlockDepSpec::blocking() const return _spec; } -bool -BlockDepSpec::strong() const +BlockKind +BlockDepSpec::block_kind() const { - return _strong; + return _kind; } std::shared_ptr<DepSpec> diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh index 98b485f22..8e710f933 100644 --- a/paludis/dep_spec.hh +++ b/paludis/dep_spec.hh @@ -595,7 +595,7 @@ namespace paludis { private: PackageDepSpec _spec; - bool _strong; + BlockKind _kind; protected: virtual void need_keys_added() const; @@ -605,9 +605,9 @@ namespace paludis ///\{ /** - * \since 0.41 + * \since 0.55 */ - BlockDepSpec(const std::string & text, const PackageDepSpec & spec, const bool strong); + BlockDepSpec(const std::string & text, const PackageDepSpec & spec, const BlockKind); BlockDepSpec(const BlockDepSpec &); @@ -621,11 +621,11 @@ namespace paludis const PackageDepSpec blocking() const PALUDIS_ATTRIBUTE((warn_unused_result)); /** - * Fetch whether we're a strong blocker. + * Fetch our blocker strength. * - * \since 0.41 + * \since 0.55 */ - bool strong() const PALUDIS_ATTRIBUTE((warn_unused_result)); + BlockKind block_kind() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual std::shared_ptr<DepSpec> clone() const PALUDIS_ATTRIBUTE((warn_unused_result)); }; diff --git a/paludis/dep_spec.se b/paludis/dep_spec.se new file mode 100644 index 000000000..3531f2bd9 --- /dev/null +++ b/paludis/dep_spec.se @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# vim: set sw=4 sts=4 et ft=sh : + +make_enum_BlockKind() +{ + prefix bk + + key bk_weak "Generic weak block" + key bk_strong "Generic strong block" + key bk_manual "A block requiring manual resolution" + key bk_upgrade_blocked_before "Strong, nothing is not fine if met" + key bk_uninstall_blocked_before "Strong, nothing is fine too" + key bk_uninstall_blocked_after "Weak, nothing is fine too" + + want_destringify + + doxygen_comment << "END" + /** + * Kind of a BlockDepSpec. + * + * \ingroup g_dep_spec + * \since 0.55 + */ +END +} + + diff --git a/paludis/dep_spec_TEST.cc b/paludis/dep_spec_TEST.cc index 7925b53ec..bf7e5595a 100644 --- a/paludis/dep_spec_TEST.cc +++ b/paludis/dep_spec_TEST.cc @@ -71,7 +71,7 @@ namespace test_cases std::shared_ptr<PackageDepSpec> c(std::static_pointer_cast<PackageDepSpec>(a.clone())); TEST_CHECK_STRINGIFY_EQUAL(a, *c); - BlockDepSpec d("!" + stringify(*c), *c, false); + BlockDepSpec d("!" + stringify(*c), *c, bk_weak); std::shared_ptr<BlockDepSpec> e(std::static_pointer_cast<BlockDepSpec>(d.clone())); TEST_CHECK_STRINGIFY_EQUAL(d.blocking(), e->blocking()); } diff --git a/paludis/files.m4 b/paludis/files.m4 index 6657ec749..b987297de 100644 --- a/paludis/files.m4 +++ b/paludis/files.m4 @@ -25,7 +25,7 @@ add(`common_sets', `hh', `cc', `fwd') 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') +add(`dep_spec', `hh', `cc', `test', `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 74192cebd..f5ae15424 100644 --- a/paludis/repositories/e/dep_parser.cc +++ b/paludis/repositories/e/dep_parser.cc @@ -123,7 +123,7 @@ namespace eapi.supported()->package_dep_spec_parse_options(), eapi.supported()->version_spec_options(), id), - strong)); + strong ? bk_strong : bk_weak)); h.begin()->item()->append(spec); annotations_go_here(spec); } diff --git a/paludis/repositories/fake/dep_parser.cc b/paludis/repositories/fake/dep_parser.cc index 3941a5dae..b627b1c5c 100644 --- a/paludis/repositories/fake/dep_parser.cc +++ b/paludis/repositories/fake/dep_parser.cc @@ -73,7 +73,7 @@ namespace + epdso_allow_use_deps + epdso_allow_ranged_deps + epdso_allow_tilde_greater_deps + epdso_strict_parsing, user_version_spec_options(), - id), false)); + id), bk_weak)); } else package_dep_spec_string_handler<T_>(h, s, id); diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc index 7c083c38c..a4d24a46e 100644 --- a/paludis/resolver/decider.cc +++ b/paludis/resolver/decider.cc @@ -1033,7 +1033,7 @@ Decider::_make_constraint_for_preloading( result->spec().if_block() = std::make_shared<BlockDepSpec>( "!" + stringify(s), s, - result->spec().if_block()->strong()); + result->spec().if_block()->block_kind()); } return result; diff --git a/paludis/resolver/get_constraints_for_dependent_helper.cc b/paludis/resolver/get_constraints_for_dependent_helper.cc index 1309f6288..642699aea 100644 --- a/paludis/resolver/get_constraints_for_dependent_helper.cc +++ b/paludis/resolver/get_constraints_for_dependent_helper.cc @@ -95,7 +95,7 @@ GetConstraintsForDependentHelper::operator() ( n::destination_type() = dt_install_to_slash, n::nothing_is_fine_too() = true, n::reason() = reason, - n::spec() = BlockDepSpec("!" + stringify(*spec), *spec, false), + n::spec() = BlockDepSpec("!" + stringify(*spec), *spec, bk_weak), n::untaken() = false, n::use_existing() = ue_if_possible ))); diff --git a/paludis/resolver/get_constraints_for_purge_helper.cc b/paludis/resolver/get_constraints_for_purge_helper.cc index 507290a25..625ae8887 100644 --- a/paludis/resolver/get_constraints_for_purge_helper.cc +++ b/paludis/resolver/get_constraints_for_purge_helper.cc @@ -86,7 +86,7 @@ GetConstraintsForPurgeHelper::operator() ( n::destination_type() = dt_install_to_slash, n::nothing_is_fine_too() = true, n::reason() = reason, - n::spec() = BlockDepSpec("!" + stringify(spec), spec, false), + n::spec() = BlockDepSpec("!" + stringify(spec), spec, bk_weak), n::untaken() = ! _imp->purge_specs.match_any(_imp->env, id, { }), n::use_existing() = ue_if_possible ))); diff --git a/paludis/resolver/orderer.cc b/paludis/resolver/orderer.cc index 5982901d1..ce753449e 100644 --- a/paludis/resolver/orderer.cc +++ b/paludis/resolver/orderer.cc @@ -260,8 +260,22 @@ namespace { bool normal(true); if (r.sanitised_dependency().spec().if_block()) - if (! r.sanitised_dependency().spec().if_block()->strong()) - normal = false; + switch (r.sanitised_dependency().spec().if_block()->block_kind()) + { + case bk_weak: + case bk_uninstall_blocked_after: + normal = false; + break; + + case bk_strong: + case bk_manual: + case bk_upgrade_blocked_before: + case bk_uninstall_blocked_before: + break; + + case last_bk: + break; + } NAGIndex from(make_named_values<NAGIndex>( n::resolvent() = r.from_resolvent(), diff --git a/paludis/resolver/package_or_block_dep_spec.cc b/paludis/resolver/package_or_block_dep_spec.cc index cb96300f3..576ec5755 100644 --- a/paludis/resolver/package_or_block_dep_spec.cc +++ b/paludis/resolver/package_or_block_dep_spec.cc @@ -66,7 +66,7 @@ PackageOrBlockDepSpec::serialise(Serialiser & s) const w .member(SerialiserFlags<>(), "block", true) .member(SerialiserFlags<>(), "spec", stringify(if_block()->blocking())) - .member(SerialiserFlags<>(), "strong", if_block()->strong()) + .member(SerialiserFlags<>(), "block_kind", stringify(if_block()->block_kind())) .member(SerialiserFlags<>(), "text", if_block()->text()) ; } @@ -140,9 +140,9 @@ PackageOrBlockDepSpec::deserialise(Deserialisation & d, const std::shared_ptr<co if (block) { - bool strong(v.member<bool>("strong")); + BlockKind kind(destringify<BlockKind>(v.member<std::string>("block_kind"))); std::string text(v.member<std::string>("text")); - BlockDepSpec b_spec(text, spec, strong); + BlockDepSpec b_spec(text, spec, kind); if (annotations) b_spec.set_annotations_key(annotations); return PackageOrBlockDepSpec(b_spec); diff --git a/paludis/resolver/resolver_TEST_blockers.cc b/paludis/resolver/resolver_TEST_blockers.cc index d6ea45832..3df4f44cd 100644 --- a/paludis/resolver/resolver_TEST_blockers.cc +++ b/paludis/resolver/resolver_TEST_blockers.cc @@ -189,7 +189,7 @@ namespace test_cases std::shared_ptr<const Resolved> resolved(get_resolved(BlockDepSpec( "!target/target", parse_user_package_dep_spec("target/target", &env, { }), - false))); + bk_weak))); check_resolved(resolved, n::taken_change_or_remove_decisions() = exists ? make_shared_copy(DecisionChecks() diff --git a/paludis/resolver/resolver_TEST_continue_on_failure.cc b/paludis/resolver/resolver_TEST_continue_on_failure.cc index ab9e63f28..29da32865 100644 --- a/paludis/resolver/resolver_TEST_continue_on_failure.cc +++ b/paludis/resolver/resolver_TEST_continue_on_failure.cc @@ -169,7 +169,7 @@ namespace test_cases std::shared_ptr<const Resolved> resolved(get_resolved(BlockDepSpec( "!continue-on-failure-uninstall/target", parse_user_package_dep_spec("continue-on-failure-uninstall/target", &env, { }), - false))); + bk_weak))); check_resolved(resolved, n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks() diff --git a/paludis/resolver/resolver_TEST_purges.cc b/paludis/resolver/resolver_TEST_purges.cc index be4a6fae0..7068f5b11 100644 --- a/paludis/resolver/resolver_TEST_purges.cc +++ b/paludis/resolver/resolver_TEST_purges.cc @@ -126,7 +126,7 @@ namespace test_cases std::shared_ptr<const Resolved> resolved(get_resolved(BlockDepSpec( "!star-slot-purges/target:1", parse_user_package_dep_spec("star-slot-purges/target:1", &env, { }), - false))); + bk_weak))); check_resolved(resolved, n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks() diff --git a/paludis/resolver/resolver_TEST_uninstalls.cc b/paludis/resolver/resolver_TEST_uninstalls.cc index 46c9ff7b5..8369b4600 100644 --- a/paludis/resolver/resolver_TEST_uninstalls.cc +++ b/paludis/resolver/resolver_TEST_uninstalls.cc @@ -96,7 +96,7 @@ namespace test_cases std::shared_ptr<const Resolved> resolved(get_resolved(BlockDepSpec( "!breaking/target", parse_user_package_dep_spec("breaking/target", &env, { }), - false))); + bk_weak))); if (allowed_to_remove) check_resolved(resolved, diff --git a/paludis/resolver/spec_rewriter.cc b/paludis/resolver/spec_rewriter.cc index d9208423c..08f6aca9b 100644 --- a/paludis/resolver/spec_rewriter.cc +++ b/paludis/resolver/spec_rewriter.cc @@ -136,7 +136,7 @@ SpecRewriter::rewrite_if_special(const PackageOrBlockDepSpec & s, const std::sha std::string::size_type p(prefix.find_first_not_of('!')); if (std::string::npos != p) prefix.erase(p); - result->specs()->push_back(BlockDepSpec(prefix + stringify(spec), spec, s.if_block()->strong())); + result->specs()->push_back(BlockDepSpec(prefix + stringify(spec), spec, s.if_block()->block_kind())); } return result; diff --git a/paludis/stringify_formatter_TEST.cc b/paludis/stringify_formatter_TEST.cc index e2e159208..5245f8705 100644 --- a/paludis/stringify_formatter_TEST.cc +++ b/paludis/stringify_formatter_TEST.cc @@ -115,8 +115,7 @@ namespace test_cases PartialFormatter f; StringifyFormatter ff(f); - BlockDepSpec b("!!!!!cat/pkg", parse_user_package_dep_spec("cat/pkg", - &env, { }), false); + BlockDepSpec b("!!!!!cat/pkg", parse_user_package_dep_spec("cat/pkg", &env, { }), bk_weak); NamedSetDepSpec u(SetName("foo")); std::string s(format_three( parse_user_package_dep_spec("cat/pkg", &env, { }), diff --git a/python/dep_spec.cc b/python/dep_spec.cc index 7d0146822..0d568a4de 100644 --- a/python/dep_spec.cc +++ b/python/dep_spec.cc @@ -438,17 +438,17 @@ PythonSimpleURIDepSpec::PythonSimpleURIDepSpec(const SimpleURIDepSpec & d) : { } -PythonBlockDepSpec::PythonBlockDepSpec(const std::string & t, const std::shared_ptr<const PythonPackageDepSpec> & a, const bool s) : +PythonBlockDepSpec::PythonBlockDepSpec(const std::string & t, const std::shared_ptr<const PythonPackageDepSpec> & a, const BlockKind s) : PythonStringDepSpec(t), _spec(a), - _strong(s) + _kind(s) { } PythonBlockDepSpec::PythonBlockDepSpec(const BlockDepSpec & d) : PythonStringDepSpec(d.text()), _spec(std::make_shared<PythonPackageDepSpec>(d.blocking())), - _strong(d.strong()) + _kind(d.block_kind()) { } @@ -458,10 +458,10 @@ PythonBlockDepSpec::blocking() const return _spec; } -bool -PythonBlockDepSpec::strong() const +BlockKind +PythonBlockDepSpec::block_kind() const { - return _strong; + return _kind; } PythonFetchableURIDepSpec::PythonFetchableURIDepSpec(const std::string & s) : @@ -924,7 +924,7 @@ template <typename H_> void SpecTreeFromPython<H_>::real_visit(const PythonBlockDepSpec & d) { - _add_to->append(std::make_shared<BlockDepSpec>(d.text(), *d.blocking(), d.strong())); + _add_to->append(std::make_shared<BlockDepSpec>(d.text(), *d.blocking(), d.block_kind())); } template <typename H_> @@ -1045,6 +1045,9 @@ void expose_dep_spec() enum_auto("UserPackageDepSpecOption", last_updso, "Options for parse_user_package_dep_spec."); + enum_auto("BlockKind", last_bk, + "Options for BlockDepSpec."); + /** * Options */ @@ -1332,15 +1335,15 @@ void expose_dep_spec() "BlockDepSpec", "A BlockDepSpec represents a block on a package name (for example, 'app-editors/vim'), \n" "possibly with associated version and SLOT restrictions.", - bp::init<std::string, std::shared_ptr<const PythonPackageDepSpec>, bool>("__init__(string, PackageDepSpec, bool)") + bp::init<std::string, std::shared_ptr<const PythonPackageDepSpec>, BlockKind>("__init__(string, PackageDepSpec, BlockKind)") ) .add_property("blocking", &PythonBlockDepSpec::blocking, "[ro] PackageDepSpec\n" "The spec we're blocking." ) - .add_property("strong", &PythonBlockDepSpec::strong, - "[ro] bool\n" + .add_property("block_kind", &PythonBlockDepSpec::block_kind, + "[ro] BlockKind\n" "Are we a strong block?" ) diff --git a/python/dep_spec.hh b/python/dep_spec.hh index e51af9a82..466a5eaf5 100644 --- a/python/dep_spec.hh +++ b/python/dep_spec.hh @@ -233,14 +233,14 @@ namespace paludis { private: std::shared_ptr<const PythonPackageDepSpec> _spec; - bool _strong; + BlockKind _kind; public: - PythonBlockDepSpec(const std::string &, const std::shared_ptr<const PythonPackageDepSpec> &, const bool); + PythonBlockDepSpec(const std::string &, const std::shared_ptr<const PythonPackageDepSpec> &, const BlockKind); PythonBlockDepSpec(const BlockDepSpec &); std::shared_ptr<const PythonPackageDepSpec> blocking() const; - bool strong() const; + BlockKind block_kind() const; }; class PALUDIS_VISIBLE PythonURILabelsDepSpec : diff --git a/python/dep_spec_TEST.py b/python/dep_spec_TEST.py index 556f24b28..375e7ee01 100755 --- a/python/dep_spec_TEST.py +++ b/python/dep_spec_TEST.py @@ -31,7 +31,7 @@ class TestCase_1_DepSpecs(unittest.TestCase): self.pds3 = parse_user_package_dep_spec("*/*::testrepo", self.env, [UserPackageDepSpecOption.ALLOW_WILDCARDS]) self.pds4 = parse_user_package_dep_spec("cat/pkg::testrepo", self.env, []) - self.bds = BlockDepSpec("!>=foo/bar-1:100::testrepo", self.pds, False) + self.bds = BlockDepSpec("!>=foo/bar-1:100::testrepo", self.pds, BlockKind.WEAK) self.nds = NamedSetDepSpec("system") def test_01_init(self): diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc index 6f6636175..aacaf7069 100644 --- a/ruby/dep_spec.cc +++ b/ruby/dep_spec.cc @@ -45,6 +45,7 @@ namespace static VALUE c_dep_spec; static VALUE c_string_dep_spec; + static VALUE c_block_kind; static VALUE c_block_dep_spec; static VALUE c_dependencies_labels_dep_spec; static VALUE c_fetchable_uri_dep_spec; @@ -465,14 +466,18 @@ namespace } VALUE - block_dep_spec_new(VALUE self, VALUE str, VALUE spec, VALUE strong) + block_dep_spec_new(VALUE self, VALUE str, VALUE spec, VALUE kind) { std::shared_ptr<const WrappedSpecBase> * ptr(0); try { + int l = NUM2INT(kind); + if (l < 0 || l >= last_bk) + rb_raise(rb_eTypeError, "BlockDepSpec expects a valid BlockKind as the third parameter"); + std::shared_ptr<const PackageDepSpec> pkg(value_to_package_dep_spec(spec)); ptr = new std::shared_ptr<const WrappedSpecBase>(std::make_shared<WrappedSpec<BlockDepSpec>>( - std::make_shared<BlockDepSpec>(StringValuePtr(str), *pkg, value_to_bool(strong)))); + std::make_shared<BlockDepSpec>(StringValuePtr(str), *pkg, static_cast<BlockKind>(l)))); VALUE tdata(Data_Wrap_Struct(self, 0, &Common<std::shared_ptr<const WrappedSpecBase> >::free, ptr)); rb_obj_call_init(tdata, 3, &str); return tdata; @@ -1274,6 +1279,18 @@ namespace rb_define_method(c_plain_text_label_dep_spec, "to_s", RUBY_FUNC_CAST(plain_text_dep_label_spec_to_s), 0); /* + * Document-module: Paludis::BlockKind + * + * The kind of a BlockDepSpec + */ + c_block_kind = rb_define_module_under(paludis_module(), "BlockKind"); + for (BlockKind l(static_cast<BlockKind>(0)), l_end(last_bk) ; l != l_end ; + l = static_cast<BlockKind>(static_cast<int>(l) + 1)) + rb_define_const(c_block_kind, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l)); + + // cc_enum_special<paludis/dep_spec.hh, BlockKind, c_block_kind> + + /* * Document-class: Paludis::BlockDepSpec * * A BlockDepSpec represents a block on a package name (for example, 'app-editors/vim'), possibly with diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb index 1ded8658e..8e8112a8d 100644 --- a/ruby/dep_spec_TEST.rb +++ b/ruby/dep_spec_TEST.rb @@ -273,22 +273,22 @@ module Paludis end def test_create - v = BlockDepSpec.new("!>=foo/bar-1", Paludis::parse_user_package_dep_spec(">=foo/bar-1", env, []), false) + v = BlockDepSpec.new("!>=foo/bar-1", Paludis::parse_user_package_dep_spec(">=foo/bar-1", env, []), BlockKind::Weak) end def test_create_error assert_raise TypeError do - v = BlockDepSpec.new("!>=foo/bar-1", 0, false) + v = BlockDepSpec.new("!>=foo/bar-1", 0, BlockKind::Weak) end assert_raise TypeError do - v = BlockDepSpec.new("!>=foo/bar-1", PlainTextDepSpec.new('foo-bar/baz'), false) + v = BlockDepSpec.new("!>=foo/bar-1", PlainTextDepSpec.new('foo-bar/baz'), BlockKind::Weak) end end def test_blocked_spec assert_equal "foo/baz", BlockDepSpec.new("!foo/baz", Paludis::parse_user_package_dep_spec( - "foo/baz", env, []), false).blocking.to_s + "foo/baz", env, []), BlockKind::Weak).blocking.to_s end end diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc index 341f64f1a..8cf9f5365 100644 --- a/src/clients/cave/resolve_common.cc +++ b/src/clients/cave/resolve_common.cc @@ -140,7 +140,7 @@ namespace { seen_packages = true; PackageDepSpec s(parse_user_package_dep_spec(p->first.substr(1), env.get(), { })); - BlockDepSpec bs("!" + stringify(s), s, false); + BlockDepSpec bs("!" + stringify(s), s, bk_weak); result->push_back(stringify(bs)); resolver->add_target(bs, p->second); } |