1 |
commit: 61f625081294e1948bfa23da71ace43f332cd4ce |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jul 28 14:53:28 2011 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jul 28 14:53:28 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=61f62508 |
7 |
|
8 |
Portage: support '^^' in depstrings (using a hack). |
9 |
|
10 |
--- |
11 |
gentoopm/portagepm/depend.py | 22 ++++++++++++++++++---- |
12 |
gentoopm/portagepm/pkg.py | 5 +++++ |
13 |
2 files changed, 23 insertions(+), 4 deletions(-) |
14 |
|
15 |
diff --git a/gentoopm/portagepm/depend.py b/gentoopm/portagepm/depend.py |
16 |
index d4f3c33..f33fd5c 100644 |
17 |
--- a/gentoopm/portagepm/depend.py |
18 |
+++ b/gentoopm/portagepm/depend.py |
19 |
@@ -6,7 +6,7 @@ |
20 |
from portage.dep import paren_reduce, use_reduce |
21 |
|
22 |
from gentoopm.basepm.depend import PMPackageDepSet, PMConditionalDep, \ |
23 |
- PMAnyOfDep, PMAllOfDep, PMBaseDep |
24 |
+ PMAnyOfDep, PMAllOfDep, PMExactlyOneOfDep, PMBaseDep |
25 |
from gentoopm.portagepm.atom import PortageAtom |
26 |
|
27 |
class PortageBaseDep(PMBaseDep): |
28 |
@@ -21,6 +21,8 @@ class PortageBaseDep(PMBaseDep): |
29 |
yield PortageAnyOfDep(next(it), self._puse) |
30 |
elif d == '&&': |
31 |
yield PortageAllOfDep(next(it), self._puse) |
32 |
+ elif d == '__xor__?': |
33 |
+ yield PortageExactlyOneOfDep(next(it), self._puse) |
34 |
elif d.endswith('?'): |
35 |
yield PortageConditionalUseDep(next(it), |
36 |
self._puse, d.rstrip('?')) |
37 |
@@ -33,6 +35,9 @@ class PortageAnyOfDep(PMAnyOfDep, PortageBaseDep): |
38 |
class PortageAllOfDep(PMAllOfDep, PortageBaseDep): |
39 |
pass |
40 |
|
41 |
+class PortageExactlyOneOfDep(PMExactlyOneOfDep, PortageBaseDep): |
42 |
+ pass |
43 |
+ |
44 |
class PortageConditionalUseDep(PMConditionalDep, PortageBaseDep): |
45 |
def __init__(self, deps, puse, flag): |
46 |
PortageBaseDep.__init__(self, deps, puse) |
47 |
@@ -44,7 +49,11 @@ class PortageConditionalUseDep(PMConditionalDep, PortageBaseDep): |
48 |
|
49 |
class PortagePackageDepSet(PMPackageDepSet, PortageBaseDep): |
50 |
def __init__(self, s, puse): |
51 |
- self._depstr = s |
52 |
+ self._use_reducable = not '^^' in s |
53 |
+ if not self._use_reducable: |
54 |
+ # ARGV, paren_reduce() doesn't handle ^^ |
55 |
+ # so we hack it to a __xor__?, UGLY! |
56 |
+ self._depstr = s.replace('^^', '__xor__?') |
57 |
PortageBaseDep.__init__(self, None, puse) |
58 |
|
59 |
def __iter__(self): |
60 |
@@ -54,8 +63,10 @@ class PortagePackageDepSet(PMPackageDepSet, PortageBaseDep): |
61 |
|
62 |
@property |
63 |
def without_conditionals(self): |
64 |
- return PortageUncondAllOfDep( |
65 |
- use_reduce(self._depstr, self._puse)) |
66 |
+ if self._use_reducable: |
67 |
+ return PortageUncondAllOfDep( |
68 |
+ use_reduce(self._depstr, self._puse)) |
69 |
+ return PMPackageDepSet.without_conditionals.fget(self) |
70 |
|
71 |
class PortageUncondDep(PortageBaseDep): |
72 |
def __init__(self, deps): |
73 |
@@ -80,3 +91,6 @@ class PortageUncondAnyOfDep(PMAnyOfDep, PortageUncondDep): |
74 |
|
75 |
class PortageUncondAllOfDep(PMAllOfDep, PortageUncondDep): |
76 |
pass |
77 |
+ |
78 |
+class PortageUncondExactlyOneOfDep(PMExactlyOneOfDep, PortageUncondDep): |
79 |
+ pass |
80 |
|
81 |
diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py |
82 |
index ed4c80c..221e728 100644 |
83 |
--- a/gentoopm/portagepm/pkg.py |
84 |
+++ b/gentoopm/portagepm/pkg.py |
85 |
@@ -183,6 +183,11 @@ class PortageDBCPV(PMPackage, CompletePortageAtom): |
86 |
return PortagePackageDepSet(self._aux_get('PDEPEND'), |
87 |
self._applied_use) |
88 |
|
89 |
+ @property |
90 |
+ def required_use(self): |
91 |
+ return PortagePackageDepSet(self._aux_get('REQUIRED_USE'), |
92 |
+ self._applied_use) |
93 |
+ |
94 |
def __str__(self): |
95 |
return '=%s' % self._cpv |