aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-03 12:41:49 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-03 18:13:28 +0000
commit95f9c8ea6d44a550c363839b704ce90ad5c96859 (patch)
tree199b6a003d999db52f234c2a7747f9fbfb4b1010
parent397abbd06696bffe7a9a49bd1d64de8785cc3879 (diff)
downloadpaludis-95f9c8ea6d44a550c363839b704ce90ad5c96859.tar.gz
paludis-95f9c8ea6d44a550c363839b704ce90ad5c96859.tar.xz
(?) use deps
-rw-r--r--paludis/elike_package_dep_spec.cc4
-rw-r--r--paludis/elike_package_dep_spec.se27
-rw-r--r--paludis/elike_use_requirement.cc122
-rw-r--r--paludis/elike_use_requirement.se11
-rw-r--r--paludis/elike_use_requirement_TEST.cc37
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf2
6 files changed, 143 insertions, 60 deletions
diff --git a/paludis/elike_package_dep_spec.cc b/paludis/elike_package_dep_spec.cc
index 738d725..c2f7c9a 100644
--- a/paludis/elike_package_dep_spec.cc
+++ b/paludis/elike_package_dep_spec.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -233,6 +233,8 @@ paludis::elike_remove_trailing_square_bracket_if_exists(std::string & s, Partial
euro += options[epdso_allow_use_deps] ? euro_both_syntaxes : euro_portage_syntax;
if (options[epdso_allow_use_dep_defaults])
euro += euro_allow_default_values;
+ if (options[epdso_allow_use_dep_question_defaults])
+ euro += euro_allow_default_question_values;
if (options[epdso_strict_parsing])
euro += euro_strict_parsing;
diff --git a/paludis/elike_package_dep_spec.se b/paludis/elike_package_dep_spec.se
index bc55366..3746241 100644
--- a/paludis/elike_package_dep_spec.se
+++ b/paludis/elike_package_dep_spec.se
@@ -6,18 +6,19 @@ make_enum_ELikePackageDepSpecOption()
prefix epdso
want_destringify
- 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_repository_deps "Allow ::repo deps"
- key epdso_allow_use_deps "Allow [use] deps"
- key epdso_allow_use_deps_portage "Allow [use] deps with Portage syntax"
- key epdso_allow_use_dep_defaults "Allow [use+] and [use-] deps"
- key epdso_allow_ranged_deps "Allow [op version] deps"
- key epdso_allow_tilde_greater_deps "Allow ~> deps"
- key epdso_disallow_nonranged_deps "Disallow >=foo/bar-1 deps"
- key epdso_nice_equal_star "Make =* do something sensible"
- key epdso_strict_parsing "Error rather than warn for violations"
- key epdso_allow_key_requirements "Allow [.key=value] requirements. \since 0.40"
+ 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_repository_deps "Allow ::repo deps"
+ key epdso_allow_use_deps "Allow [use] deps"
+ key epdso_allow_use_deps_portage "Allow [use] deps with Portage syntax"
+ key epdso_allow_use_dep_defaults "Allow [use(+)] and [use(-)] deps"
+ key epdso_allow_use_dep_question_defaults "Allow [use(?)] deps"
+ key epdso_allow_ranged_deps "Allow [op version] deps"
+ key epdso_allow_tilde_greater_deps "Allow ~> deps"
+ key epdso_disallow_nonranged_deps "Disallow >=foo/bar-1 deps"
+ key epdso_nice_equal_star "Make =* do something sensible"
+ key epdso_strict_parsing "Error rather than warn for violations"
+ key epdso_allow_key_requirements "Allow [.key=value] requirements. \since 0.40"
}
diff --git a/paludis/elike_use_requirement.cc b/paludis/elike_use_requirement.cc
index 3b58ae6..ff8c150 100644
--- a/paludis/elike_use_requirement.cc
+++ b/paludis/elike_use_requirement.cc
@@ -66,14 +66,16 @@ namespace
const std::tr1::shared_ptr<const PackageID> _id;
const ELikeUseRequirementOptions _options;
const Tribool _default_value;
+ const bool _ignore_if_no_such_group;
public:
UseRequirement(const std::string & n, const std::tr1::shared_ptr<const PackageID> & i,
- const ELikeUseRequirementOptions & o, Tribool d) :
+ const ELikeUseRequirementOptions & o, Tribool d, const bool g) :
_flags(n),
_id(i),
_options(o),
- _default_value(d)
+ _default_value(d),
+ _ignore_if_no_such_group(g)
{
}
@@ -81,11 +83,32 @@ namespace
{
}
- virtual bool one_requirement_met(
+ virtual bool one_requirement_met_base(
const Environment * const,
const ChoiceNameWithPrefix &,
const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ bool one_requirement_met(
+ const Environment * const env,
+ const ChoiceNameWithPrefix & c,
+ const PackageID & id) const PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ if (_ignore_if_no_such_group)
+ {
+ std::string::size_type p(_flags.find(':'));
+ ChoicePrefixName prefix((std::string::npos == p) ? "" : _flags.substr(0, p));
+ if (! id.choices_key())
+ return true;
+ Choices::ConstIterator k(id.choices_key()->value()->find(prefix));
+ if (id.choices_key()->value()->end() == k)
+ return true;
+ if ((*k)->begin() == (*k)->end())
+ return true;
+ }
+
+ return one_requirement_met_base(env, c, id);
+ }
+
virtual const std::string as_human_string() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
const std::string flags() const PALUDIS_ATTRIBUTE((warn_unused_result))
@@ -152,12 +175,16 @@ namespace
const std::string default_value_human_string_fragment() const PALUDIS_ATTRIBUTE((warn_unused_result))
{
+ std::string result;
if (_default_value.is_true())
- return ", assuming enabled if missing";
+ result = ", assuming enabled if missing";
else if (_default_value.is_false())
- return ", assuming disabled if missing";
- else
- return "";
+ result = ", assuming disabled if missing";
+
+ if (_ignore_if_no_such_group)
+ result.append(", only if the target has any flags with this prefix");
+
+ return result;
}
};
@@ -168,12 +195,12 @@ namespace
EnabledUseRequirement(const std::string & n,
const std::tr1::shared_ptr<const PackageID> & i,
const ELikeUseRequirementOptions & o,
- Tribool d) :
- UseRequirement(n, i, o, d)
+ Tribool d, const bool b) :
+ UseRequirement(n, i, o, d, b)
{
}
- virtual bool one_requirement_met(const Environment * const, const ChoiceNameWithPrefix & flag,
+ virtual bool one_requirement_met_base(const Environment * const, const ChoiceNameWithPrefix & flag,
const PackageID & pkg) const
{
return icky_use_query(flag, pkg, default_value());
@@ -192,12 +219,12 @@ namespace
DisabledUseRequirement(const std::string & n,
const std::tr1::shared_ptr<const PackageID> & i,
const ELikeUseRequirementOptions & o,
- Tribool d) :
- UseRequirement(n, i, o, d)
+ Tribool d, const bool b) :
+ UseRequirement(n, i, o, d, b)
{
}
- virtual bool one_requirement_met(const Environment * const, const ChoiceNameWithPrefix & flag,
+ virtual bool one_requirement_met_base(const Environment * const, const ChoiceNameWithPrefix & flag,
const PackageID & pkg) const
{
return ! icky_use_query(flag, pkg, default_value());
@@ -216,8 +243,8 @@ namespace
ConditionalUseRequirement(const std::string & n,
const std::tr1::shared_ptr<const PackageID> & i,
const ELikeUseRequirementOptions & o,
- Tribool d) :
- UseRequirement(n, i, o, d)
+ Tribool d, const bool b) :
+ UseRequirement(n, i, o, d, b)
{
}
};
@@ -230,12 +257,12 @@ namespace
const std::string & n,
const std::tr1::shared_ptr<const PackageID> & i,
const ELikeUseRequirementOptions & o,
- Tribool d) :
- ConditionalUseRequirement(n, i, o, d)
+ Tribool d, const bool b) :
+ ConditionalUseRequirement(n, i, o, d, b)
{
}
- virtual bool one_requirement_met(const Environment * const, const ChoiceNameWithPrefix & flag,
+ virtual bool one_requirement_met_base(const Environment * const, const ChoiceNameWithPrefix & flag,
const PackageID & pkg) const
{
return ! icky_use_query(flag, *package_id()) || icky_use_query(flag, pkg, default_value());
@@ -255,12 +282,12 @@ namespace
IfNotMineThenUseRequirement(const std::string & n,
const std::tr1::shared_ptr<const PackageID> & i,
const ELikeUseRequirementOptions & o,
- Tribool d) :
- ConditionalUseRequirement(n, i, o, d)
+ Tribool d, const bool b) :
+ ConditionalUseRequirement(n, i, o, d, b)
{
}
- virtual bool one_requirement_met(const Environment * const, const ChoiceNameWithPrefix & flag,
+ virtual bool one_requirement_met_base(const Environment * const, const ChoiceNameWithPrefix & flag,
const PackageID & pkg) const
{
return icky_use_query(flag, *package_id()) || icky_use_query(flag, pkg, default_value());
@@ -280,12 +307,12 @@ namespace
IfMineThenNotUseRequirement(const std::string & n,
const std::tr1::shared_ptr<const PackageID> & i,
const ELikeUseRequirementOptions & o,
- Tribool d) :
- ConditionalUseRequirement(n, i, o, d)
+ Tribool d, const bool b) :
+ ConditionalUseRequirement(n, i, o, d, b)
{
}
- virtual bool one_requirement_met(const Environment * const, const ChoiceNameWithPrefix & flag,
+ virtual bool one_requirement_met_base(const Environment * const, const ChoiceNameWithPrefix & flag,
const PackageID & pkg) const
{
return ! icky_use_query(flag, *package_id()) || ! icky_use_query(flag, pkg, default_value());
@@ -305,12 +332,12 @@ namespace
IfNotMineThenNotUseRequirement(const std::string & n,
const std::tr1::shared_ptr<const PackageID> & i,
const ELikeUseRequirementOptions & o,
- Tribool d) :
- ConditionalUseRequirement(n, i, o, d)
+ Tribool d, const bool b) :
+ ConditionalUseRequirement(n, i, o, d, b)
{
}
- virtual bool one_requirement_met(const Environment * const, const ChoiceNameWithPrefix & flag,
+ virtual bool one_requirement_met_base(const Environment * const, const ChoiceNameWithPrefix & flag,
const PackageID & pkg) const
{
return icky_use_query(flag, *package_id()) || ! icky_use_query(flag, pkg, default_value());
@@ -330,12 +357,12 @@ namespace
EqualUseRequirement(const std::string & n,
const std::tr1::shared_ptr<const PackageID> & i,
const ELikeUseRequirementOptions & o,
- Tribool d) :
- ConditionalUseRequirement(n, i, o, d)
+ Tribool d, const bool b) :
+ ConditionalUseRequirement(n, i, o, d, b)
{
}
- virtual bool one_requirement_met(const Environment * const, const ChoiceNameWithPrefix & flag,
+ virtual bool one_requirement_met_base(const Environment * const, const ChoiceNameWithPrefix & flag,
const PackageID & pkg) const
{
return icky_use_query(flag, pkg, default_value()) == icky_use_query(flag, *package_id());
@@ -355,12 +382,12 @@ namespace
NotEqualUseRequirement(const std::string & n,
const std::tr1::shared_ptr<const PackageID> & i,
const ELikeUseRequirementOptions & o,
- Tribool d) :
- ConditionalUseRequirement(n, i, o, d)
+ Tribool d, const bool b) :
+ ConditionalUseRequirement(n, i, o, d, b)
{
}
- virtual bool one_requirement_met(const Environment * const, const ChoiceNameWithPrefix & flag,
+ virtual bool one_requirement_met_base(const Environment * const, const ChoiceNameWithPrefix & flag,
const PackageID & pkg) const
{
return icky_use_query(flag, pkg, default_value()) != icky_use_query(flag, *package_id());
@@ -428,14 +455,14 @@ namespace
template <typename T_>
std::tr1::shared_ptr<const UseRequirement>
make_requirement(const std::string & n, const std::tr1::shared_ptr<const PackageID > & i,
- const ELikeUseRequirementOptions & o, Tribool d)
+ const ELikeUseRequirementOptions & o, Tribool d, const bool b)
{
- return make_shared_ptr(new T_(n, i, o, d));
+ return make_shared_ptr(new T_(n, i, o, d, b));
}
typedef std::tr1::shared_ptr<const UseRequirement> (* Factory)(
const std::string &, const std::tr1::shared_ptr<const PackageID> &,
- const ELikeUseRequirementOptions &, Tribool);
+ const ELikeUseRequirementOptions &, Tribool, bool);
void
parse_flag(
@@ -444,9 +471,10 @@ namespace
const std::string & c,
const std::tr1::shared_ptr<const PackageID> & id,
Tribool d,
+ const bool i,
const ELikeUseRequirementOptions & options)
{
- result->add_requirement(factory(c, id, options, d));
+ result->add_requirement(factory(c, id, options, d, i));
}
void
@@ -616,7 +644,7 @@ namespace
}
flag.erase(flag.length() - 3, 3);
- parse_flag(result, factory, flag, id, Tribool(true), options);
+ parse_flag(result, factory, flag, id, Tribool(true), false, options);
}
else if ('-' == flag.at(flag.length() - 2))
{
@@ -630,13 +658,27 @@ namespace
}
flag.erase(flag.length() - 3, 3);
- parse_flag(result, factory, flag, id, Tribool(false), options);
+ parse_flag(result, factory, flag, id, Tribool(false), false, options);
+ }
+ else if ('?' == flag.at(flag.length() - 2))
+ {
+ if (! options[euro_allow_default_question_values])
+ {
+ if (options[euro_strict_parsing])
+ throw ELikeUseRequirementError(s, "[use(?)] not safe for use here");
+ else
+ Log::get_instance()->message("e.use_requirement.flag_bracket_question_not_allowed", ll_warning, lc_context)
+ << "[use(?)] not safe for use here";
+ }
+
+ flag.erase(flag.length() - 3, 3);
+ parse_flag(result, factory, flag, id, Tribool(false), true, options);
}
else
throw ELikeUseRequirementError(s, "Invalid [] contents");
}
else
- parse_flag(result, factory, flag, id, Tribool(indeterminate), options);
+ parse_flag(result, factory, flag, id, Tribool(indeterminate), false, options);
}
}
diff --git a/paludis/elike_use_requirement.se b/paludis/elike_use_requirement.se
index ff75d61..6099b88 100644
--- a/paludis/elike_use_requirement.se
+++ b/paludis/elike_use_requirement.se
@@ -6,10 +6,11 @@ make_enum_ELikeUseRequirementOption()
prefix euro
want_destringify
- key euro_allow_self_deps "Allow self-dependent use deps"
- key euro_allow_default_values "Allow the dep to specify a default value for when the flag is missing"
- key euro_portage_syntax "Parse using Portage syntax"
- key euro_both_syntaxes "Accept both Portage and Paludis syntax"
- key euro_strict_parsing "Error rather than warn for violations"
+ key euro_allow_self_deps "Allow self-dependent use deps"
+ key euro_allow_default_values "Allow the dep to specify a default value for when the flag is missing"
+ key euro_allow_default_question_values "Allow (?) default values"
+ key euro_portage_syntax "Parse using Portage syntax"
+ key euro_both_syntaxes "Accept both Portage and Paludis syntax"
+ key euro_strict_parsing "Error rather than warn for violations"
}
diff --git a/paludis/elike_use_requirement_TEST.cc b/paludis/elike_use_requirement_TEST.cc
index 6a493fc..bc83a38 100644
--- a/paludis/elike_use_requirement_TEST.cc
+++ b/paludis/elike_use_requirement_TEST.cc
@@ -916,5 +916,42 @@ namespace test_cases
TEST_CHECK(req2->requirement_met(&env, *id).first);
}
} test_prefix_star_use_requirements;
+
+ struct PrefixQuestionDefaultsRequirementsTest : TestCase
+ {
+ PrefixQuestionDefaultsRequirementsTest() : TestCase("(?) defaults") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ const std::tr1::shared_ptr<FakeRepository> fake(new FakeRepository(make_named_values<FakeRepositoryParams>(
+ value_for<n::environment>(&env),
+ value_for<n::name>(RepositoryName("fake"))
+ )));
+ env.package_database()->add_repository(1, fake);
+
+ std::tr1::shared_ptr<FakePackageID> id1(fake->add_version("cat", "pkg1", "1"));
+ set_conditionals(id1, "foo:enabled foo:disabled");
+
+ std::tr1::shared_ptr<FakePackageID> id2(fake->add_version("cat", "pkg2", "1"));
+ set_conditionals(id2, "foo:enabled foo:disabled bar:enabled bar:disabled");
+
+ std::tr1::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
+ parse_elike_use_requirement("foo:*(?)=", id2,
+ ELikeUseRequirementOptions() + euro_allow_default_values + euro_allow_self_deps +
+ euro_allow_default_question_values));
+ TEST_CHECK_EQUAL(req1->as_raw_string(), "[foo:*(?)=]");
+ TEST_CHECK(req1->requirement_met(&env, *id2).first);
+ TEST_CHECK(req1->requirement_met(&env, *id1).first);
+
+ std::tr1::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
+ parse_elike_use_requirement("bar:*(?)=", id2,
+ ELikeUseRequirementOptions() + euro_allow_default_values + euro_allow_self_deps +
+ euro_allow_default_question_values));
+ TEST_CHECK_EQUAL(req2->as_raw_string(), "[bar:*(?)=]");
+ TEST_CHECK(req2->requirement_met(&env, *id2).first);
+ TEST_CHECK(req2->requirement_met(&env, *id1).first);
+ }
+ } test_question_default_requirements;
}
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index d3e1213..cbca610 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -8,7 +8,7 @@ can_be_pbin = true
package_dep_spec_parse_options = allow_slot_deps allow_use_deps \
allow_ranged_deps allow_tilde_greater_deps strict_parsing \
allow_slot_equal_deps allow_slot_star_deps allow_use_dep_defaults \
- nice_equal_star disallow_nonranged_deps
+ nice_equal_star disallow_nonranged_deps allow_use_dep_question_defaults
dependency_spec_tree_parse_options = disallow_any_use uri_supports_arrow single_bang_block_is_hard
iuse_flag_parse_options = strict_parsing
version_spec_options = flexible_dashes flexible_dots ignore_case \