1 |
commit: 1cc91c92cd6103185598fa2e4ce9829a01a30b2d |
2 |
Author: André Erdmann <dywi <AT> mailerd <DOT> de> |
3 |
AuthorDate: Tue Jul 29 17:00:06 2014 +0000 |
4 |
Commit: André Erdmann <dywi <AT> mailerd <DOT> de> |
5 |
CommitDate: Tue Jul 29 17:00:06 2014 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=1cc91c92 |
7 |
|
8 |
roverlay/depres, slot rules: "wide match" |
9 |
|
10 |
In continuation of commit #50bd6d5aac48317c46b777acf9c1836e792bff58, |
11 |
make the slot match behavior configurable (depending on the slot rule, |
12 |
not the dep env<-package). |
13 |
|
14 |
--- |
15 |
roverlay/depres/simpledeprule/rules.py | 142 +++++++++++++++++++++++---------- |
16 |
1 file changed, 98 insertions(+), 44 deletions(-) |
17 |
|
18 |
diff --git a/roverlay/depres/simpledeprule/rules.py b/roverlay/depres/simpledeprule/rules.py |
19 |
index 7ba4967..df767ba 100644 |
20 |
--- a/roverlay/depres/simpledeprule/rules.py |
21 |
+++ b/roverlay/depres/simpledeprule/rules.py |
22 |
@@ -27,6 +27,8 @@ from roverlay.depres.simpledeprule.util import \ |
23 |
from roverlay.depres.simpledeprule.abstractrules import \ |
24 |
SimpleRule, FuzzySimpleRule |
25 |
|
26 |
+import roverlay.depres.depenv |
27 |
+ |
28 |
|
29 |
|
30 |
|
31 |
@@ -100,6 +102,12 @@ class RuleConstructor ( object ): |
32 |
# # unsafe, could be used to inject "$(rm -rf /)" etc. |
33 |
# kwargs ['slot_operator'] = value |
34 |
|
35 |
+ elif opt == 'wide_match': |
36 |
+ if not has_value: |
37 |
+ kwargs ['allow_wide_match'] = True |
38 |
+ else: |
39 |
+ raise NotImplementedError("wide_match value") |
40 |
+ |
41 |
elif opt == '*': |
42 |
kwargs ['slot_operator'] = '*' |
43 |
|
44 |
@@ -232,8 +240,17 @@ class SimpleFuzzySlotDependencyRule ( FuzzySimpleRule ): |
45 |
# 'slot' : '{slot}', |
46 |
# } |
47 |
|
48 |
- #RULE_PREFIX = '~' |
49 |
- RULE_PREFIX = SimpleFuzzyDependencyRule.RULE_PREFIX |
50 |
+ #RULE_PREFIX = '~' |
51 |
+ RULE_PREFIX = SimpleFuzzyDependencyRule.RULE_PREFIX |
52 |
+ |
53 |
+ # version relation operators that should never be matched in slot dep rules |
54 |
+ # (bitmask) |
55 |
+ VMOD_BASE_DENY_MASK = roverlay.depres.depenv.DepEnv.VMOD_NOT |
56 |
+ |
57 |
+ # operators that should not be matched in nonwide mode (bitmask) |
58 |
+ # - in addition to the base mask - |
59 |
+ VMOD_WIDE_DENY_MASK = roverlay.depres.depenv.DepEnv.VMOD_GT |
60 |
+ |
61 |
|
62 |
def __init__ ( self, |
63 |
priority = 71, |
64 |
@@ -243,6 +260,7 @@ class SimpleFuzzySlotDependencyRule ( FuzzySimpleRule ): |
65 |
slotparts = None, |
66 |
subslotparts = None, |
67 |
slot_operator = None, |
68 |
+ allow_wide_match = None, |
69 |
**kw |
70 |
): |
71 |
super ( SimpleFuzzySlotDependencyRule, self ) . __init__ ( |
72 |
@@ -252,11 +270,17 @@ class SimpleFuzzySlotDependencyRule ( FuzzySimpleRule ): |
73 |
**kw |
74 |
) |
75 |
|
76 |
- self.mode = 0 if slot_mode is None else slot_mode |
77 |
- self.slot_restrict = slot_restrict |
78 |
- self.slot_operator = slot_operator |
79 |
- self.slotparts = get_slot_parser ("0") if slotparts is None else slotparts |
80 |
- self.subslotparts = subslotparts |
81 |
+ self.mode = 0 if slot_mode is None else slot_mode |
82 |
+ self.slot_restrict = slot_restrict |
83 |
+ self.slot_operator = slot_operator |
84 |
+ self.slotparts = ( |
85 |
+ get_slot_parser ("0") if slotparts is None else slotparts |
86 |
+ ) |
87 |
+ self.subslotparts = subslotparts |
88 |
+ self.allow_wide_match = allow_wide_match |
89 |
+ self.vmod_mask = self.VMOD_BASE_DENY_MASK |
90 |
+ if not allow_wide_match: |
91 |
+ self.vmod_mask |= self.VMOD_WIDE_DENY_MASK |
92 |
|
93 |
if self.mode == 0: |
94 |
# "default" |
95 |
@@ -294,13 +318,21 @@ class SimpleFuzzySlotDependencyRule ( FuzzySimpleRule ): |
96 |
|
97 |
def noexport ( self ): |
98 |
del self.slot_operator |
99 |
- del self.mode |
100 |
+ del self.allow_wide_match |
101 |
+ |
102 |
if self.slot_restrict: |
103 |
self.slot_restrict.noexport() |
104 |
# --- end of noexport (...) --- |
105 |
|
106 |
def get_resolving_str ( self ): |
107 |
def gen_opts(): |
108 |
+ if self.allow_wide_match: |
109 |
+ yield "wide_match" |
110 |
+ |
111 |
+# yield "vmod_mask={:#x}".format ( |
112 |
+# self.vmod_mask & ~self.VMOD_BASE_DENY_MASK |
113 |
+# ) |
114 |
+ |
115 |
if self.mode == 2: |
116 |
yield "open" |
117 |
else: |
118 |
@@ -327,52 +359,74 @@ class SimpleFuzzySlotDependencyRule ( FuzzySimpleRule ): |
119 |
resolv = ( |
120 |
self._orig_resolving_package |
121 |
if hasattr ( self, '_orig_resolving_package' ) |
122 |
- else self.resolving_package, |
123 |
+ else self.resolving_package |
124 |
), |
125 |
opts = ':'.join ( gen_opts() ) |
126 |
) |
127 |
# --- end of get_resolving_str (...) --- |
128 |
|
129 |
def handle_version_relative_match ( self, dep_env, fuzzy ): |
130 |
+ def get_slotted_result ( dep_env, fuzzy, vmod ): |
131 |
+ slot_str = None |
132 |
+ vslot_str = None |
133 |
+ slot = self.slotparts.get_slot ( fuzzy ) |
134 |
+ |
135 |
+ if slot is not None: |
136 |
+ if self.subslotparts: |
137 |
+ subslot = self.subslotparts.get_slot ( fuzzy ) |
138 |
+ if subslot is not None: |
139 |
+ slot_str = slot + '/' + subslot |
140 |
+ vslot_str = ( |
141 |
+ self.slotparts.calculate_slot ( fuzzy, slot ) |
142 |
+ + '/' |
143 |
+ + self.subslotparts.calculate_slot ( fuzzy, subslot ) |
144 |
+ ) |
145 |
+ else: |
146 |
+ vslot_str = self.slotparts.calculate_slot ( fuzzy, slot ) |
147 |
+ slot_str = slot |
148 |
+ |
149 |
+ if slot_str and ( |
150 |
+ not self.slot_restrict |
151 |
+ or self.slot_restrict.accepts ( vslot_str ) |
152 |
+ ): |
153 |
+ return self._resolving_fmt.format ( |
154 |
+ slot = slot_str, |
155 |
+ version = fuzzy ['version'], |
156 |
+ vmod = fuzzy ['version_modifier'] |
157 |
+ ) |
158 |
+ # -- end if <accepted slot> |
159 |
+ # -- end if <have slot> |
160 |
+ |
161 |
+ # explicit return |
162 |
+ return None |
163 |
+ # --- end of get_slot_result (...) --- |
164 |
+ |
165 |
res = False |
166 |
vmod = fuzzy ['vmod'] |
167 |
|
168 |
- # FIXME: improve decision making |
169 |
- # |
170 |
- if not ( vmod & (dep_env.VMOD_NOT|dep_env.VMOD_GT) ): |
171 |
- # can be resolved as slot(ted) dep |
172 |
|
173 |
- if self.mode == 2: |
174 |
- res = self.resolving_package |
175 |
- elif vmod & dep_env.VMOD_EQ: |
176 |
- slot_str = None |
177 |
- vslot_str = None |
178 |
- slot = self.slotparts.get_slot ( fuzzy ) |
179 |
- |
180 |
- if slot is not None: |
181 |
- if self.subslotparts: |
182 |
- subslot = self.subslotparts.get_slot ( fuzzy ) |
183 |
- if subslot is not None: |
184 |
- slot_str = slot + '/' + subslot |
185 |
- vslot_str = ( |
186 |
- self.slotparts.calculate_slot ( fuzzy, slot ) |
187 |
- + '/' |
188 |
- + self.subslotparts.calculate_slot ( fuzzy, subslot ) |
189 |
- ) |
190 |
- else: |
191 |
- vslot_str = self.slotparts.calculate_slot ( fuzzy, slot ) |
192 |
- slot_str = slot |
193 |
- |
194 |
- if slot_str and ( |
195 |
- not self.slot_restrict |
196 |
- or self.slot_restrict.accepts ( vslot_str ) |
197 |
- ): |
198 |
- res = self._resolving_fmt.format ( |
199 |
- slot=slot_str, |
200 |
- version=fuzzy['version'], vmod=fuzzy['version_modifier'] |
201 |
- ) |
202 |
+ if vmod & self.vmod_mask: |
203 |
+ # can never be resolved as slot(ted) dep |
204 |
+ return False |
205 |
|
206 |
- # -- end if vmod != NOT |
207 |
+## MAYBE TODO |
208 |
+## elif self.ident and dep_env.want_slotres_override(self.ident): |
209 |
+### ^^^^^^^^^^? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^? |
210 |
+## want_slot_res, ... = dep_env.get_slotres_override(self.ident,...) |
211 |
+### ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^? |
212 |
+## if not want_slot_res: |
213 |
+## return False |
214 |
+## elif ...: |
215 |
+## ... |
216 |
+## |
217 |
+ |
218 |
+ # else might be resolvable as slot(ted) dep |
219 |
+ elif self.mode == 2: |
220 |
+ return self.resolving_package |
221 |
+ elif vmod & dep_env.VMOD_EQ: |
222 |
+ return get_slotted_result ( dep_env, fuzzy, vmod ) |
223 |
+ else: |
224 |
+ return False |
225 |
+ # -- end if <vmod> |
226 |
|
227 |
- return res |
228 |
# --- end of handle_version_relative_match (...) --- |