commit:     160534995aad8623f278485047ee67303daf5b60
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Thu Jul 17 14:14:31 2014 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Thu Jul 17 14:14:31 2014 +0000
URL:        
http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=16053499

package rules: add "version" match keyword

---
 doc/rst/usage.rst                             |  9 +++++++++
 roverlay/packagerules/acceptors/util.py       | 12 ++++++++++++
 roverlay/packagerules/parser/context/match.py |  3 +++
 3 files changed, 24 insertions(+)

diff --git a/doc/rst/usage.rst b/doc/rst/usage.rst
index ffa690b..f841f36 100644
--- a/doc/rst/usage.rst
+++ b/doc/rst/usage.rst
@@ -1819,6 +1819,15 @@ These *match keywords* are recognized:
    +---------------+------------------+--------------------------------------+
    | name          | *implicit*       | *alias to ebuild_name*               |
    +---------------+------------------+--------------------------------------+
+   | version       | *implicit*       | ebuild version ``${PV}``             |
+   |               |                  |                                      |
+   |               |                  | To be exact, matches the ebuild      |
+   |               |                  | version with revision ``-rN``        |
+   |               |                  | (``${PVR}``). ``-r0`` gets always    |
+   |               |                  | omitted and all packages are         |
+   |               |                  | initially ``-r0``, so  *version*     |
+   |               |                  | effectively matches ``${PV}``.       |
+   +---------------+------------------+--------------------------------------+
    | category      | exact-string     | the package's overlay category,      |
    |               |                  | which is unknown (represented by     |
    |               |                  | ``@default``) unless it has been set |

diff --git a/roverlay/packagerules/acceptors/util.py 
b/roverlay/packagerules/acceptors/util.py
index e3b62cd..6b8e472 100644
--- a/roverlay/packagerules/acceptors/util.py
+++ b/roverlay/packagerules/acceptors/util.py
@@ -30,3 +30,15 @@ def get_ebuild_name ( p_info ):
 def get_category ( p_info ):
    return p_info.get ( 'category', None ) or DEFAULT_CATEGORY_REPLACEMENT
 # --- end of get_category (...) ---
+
+def get_ebuild_version_tuple ( p_info ):
+   return p_info ['version']
+# --- end of get_ebuild_version_tuple (...) ---
+
+def get_ebuild_version ( p_info ):
+   return p_info ['ebuild_verstr']
+# --- end of get_ebuild_version (...) ---
+
+
+get_ebuild_version_tuple.func_name = "version"
+get_ebuild_version.func_name       = "version"

diff --git a/roverlay/packagerules/parser/context/match.py 
b/roverlay/packagerules/parser/context/match.py
index 8eab9bb..577c1cf 100644
--- a/roverlay/packagerules/parser/context/match.py
+++ b/roverlay/packagerules/parser/context/match.py
@@ -138,6 +138,9 @@ class RuleMatchContext (
       'ebuild_name' : (
          None, roverlay.packagerules.acceptors.util.get_ebuild_name,
       ),
+      'version' : (
+         None, roverlay.packagerules.acceptors.util.get_ebuild_version,
+      ),
    }
 
    def __init__ ( self, namespace, level=0, bool_type=None, priority=-1 ):

Reply via email to