aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-09-05 14:04:28 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-09-05 14:10:55 +0100
commita4cb561d69f5f6f9e464e78f5b82ba829ecaa32f (patch)
tree56fc6f0c9a10da31033b40743183afc720678353
parentab6ef15c88f168bd5bc75967e62aa76f10066fb6 (diff)
downloadpaludis-a4cb561d69f5f6f9e464e78f5b82ba829ecaa32f.tar.gz
paludis-a4cb561d69f5f6f9e464e78f5b82ba829ecaa32f.tar.xz
user specs [.::repothing=blah]
-rw-r--r--doc/configuration/specs.html.part14
-rw-r--r--paludis/user_dep_spec.cc21
-rw-r--r--paludis/user_dep_spec_TEST.cc12
3 files changed, 43 insertions, 4 deletions
diff --git a/doc/configuration/specs.html.part b/doc/configuration/specs.html.part
index 97029e3..ed37606 100644
--- a/doc/configuration/specs.html.part
+++ b/doc/configuration/specs.html.part
@@ -25,22 +25,30 @@ the following order:</p>
<ul>
<li><code>:slot</code>: Match only in that slot.</li>
+
<li><code>::repo-&gt;repo</code>: Repository requirements, described below.</li>
+
<li><code>::something</code>: like <code>::-&gt;something</code>, for all legal values of something.</li>
+
<li><code>[use]</code> and <code>[-use]</code>: Match only if the named USE flag is enabled / disabled for this
package. May be specified multiple times with different USE flag names.</li>
+
<li><code>[=1.23]</code>: Match a particular version. Any operator described below
can be used. May be extended to ranged dependencies, using either <code>[=1.23|=1.24|=1.25]</code> for an or
dependency or <code>[&gt;=1.2&amp;&lt;2]</code> for an and dependency.</li>
+
<li><code>[.key?]</code>: Match only if the specified metadata key exists. <code>key</code> may be a key's raw
name (e.g. <code>DESCRIPTION</code>, <code>DEPEND</code>) or a role prefixed with a dollar sign (e.g.
- <code>$short_description</code>, <code>$build_dependencies</code>).</li>
+ <code>$short_description</code>, <code>$build_dependencies</code>). If the key's name is prefixed with
+ <code>::</code>, metadata from the repository rather than the package ID is checked.</li>
+
<li><code>[.key=value]</code>: Match only if the specified metadata key has a particular exact value. Only works for
simple values, sets and sequences, not spec trees and other complex compound keys. If <code>&lt;</code> is used in
place of <code>=</code>, for numeric values a less-than comparison is used, and for sets, sequences and spec trees,
a match occurs if any member of the set or sequence is equal to the value. Similarly if <code>&gt;</code> is used,
- for numeric values a greater-than comparison is used; it does not match for other types of values. The key may
- be a raw name or a dollar-prefixed role name as above.</li>
+ for numeric values a greater-than comparison is used; it does not match for other types of values. As above, the key
+ may be a raw name or a dollar-prefixed role name, and may be prefixed with <code>::</code> for checking repository
+ metadata.</li>
</ul>
<p>Repository requirements are in the form <code>to</code>, <code>from-&gt;</code> or <code>::from-&gt;to</code>. The
diff --git a/paludis/user_dep_spec.cc b/paludis/user_dep_spec.cc
index bcee27f..61ec80d 100644
--- a/paludis/user_dep_spec.cc
+++ b/paludis/user_dep_spec.cc
@@ -760,7 +760,20 @@ UserKeyRequirement::requirement_met(const Environment * const, const ChangedChoi
const MetadataKey * key(0);
- if ((! _imp->key.empty()) && (_imp->key.at(0) == '$'))
+ if (0 == _imp->key.compare(0, 3, "::$"))
+ {
+ if (_imp->key == "::$format")
+ key = id.repository()->format_key().get();
+ else if (_imp->key == "::$location")
+ key = id.repository()->location_key().get();
+ else if (_imp->key == "::$installed_root")
+ key = id.repository()->installed_root_key().get();
+ else if (_imp->key == "::$accept_keywords")
+ key = id.repository()->accept_keywords_key().get();
+ else if (_imp->key == "::$sync_host")
+ key = id.repository()->sync_host_key().get();
+ }
+ else if (0 == _imp->key.compare(0, 1, "$"))
{
if (_imp->key == "$behaviours")
key = id.behaviours_key().get();
@@ -805,6 +818,12 @@ UserKeyRequirement::requirement_met(const Environment * const, const ChangedChoi
else if (_imp->key == "$virtual_for")
key = id.virtual_for_key().get();
}
+ else if (0 == _imp->key.compare(0, 2, "::"))
+ {
+ Repository::MetadataConstIterator m(id.repository()->find_metadata(_imp->key.substr(2)));
+ if (m != id.repository()->end_metadata())
+ key = m->get();
+ }
else
{
PackageID::MetadataConstIterator m(id.find_metadata(_imp->key));
diff --git a/paludis/user_dep_spec_TEST.cc b/paludis/user_dep_spec_TEST.cc
index 033c49e..dff1e3d 100644
--- a/paludis/user_dep_spec_TEST.cc
+++ b/paludis/user_dep_spec_TEST.cc
@@ -487,6 +487,18 @@ namespace test_cases
TEST_CHECK(match_package(env, o, *pkg1, { }));
TEST_CHECK(match_package(env, o, *pkg2, { }));
TEST_CHECK(! match_package(env, o, *pkg3, { }));
+
+ PackageDepSpec p(parse_user_package_dep_spec("cat/pkg1[.::$format=fake]", &env, { }));
+ TEST_CHECK(match_package(env, p, *pkg1, { }));
+
+ PackageDepSpec q(parse_user_package_dep_spec("cat/pkg1[.::$format=e]", &env, { }));
+ TEST_CHECK(! match_package(env, q, *pkg1, { }));
+
+ PackageDepSpec r(parse_user_package_dep_spec("cat/pkg1[.::format=fake]", &env, { }));
+ TEST_CHECK(match_package(env, r, *pkg1, { }));
+
+ PackageDepSpec s(parse_user_package_dep_spec("cat/pkg1[.::format=e]", &env, { }));
+ TEST_CHECK(! match_package(env, s, *pkg1, { }));
}
} test_user_package_dep_spec_user_key_req;
}