1 |
commit: 43760dfaaf7a140a0c941c1cbd89c481796f50cf |
2 |
Author: André Erdmann <dywi <AT> mailerd <DOT> de> |
3 |
AuthorDate: Thu Aug 2 15:04:05 2012 +0000 |
4 |
Commit: André Erdmann <dywi <AT> mailerd <DOT> de> |
5 |
CommitDate: Thu Aug 2 15:04:05 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=43760dfa |
7 |
|
8 |
ebuild: replace dep_allowed code |
9 |
|
10 |
Should be more stable now (and doesn't raise an exception for deps |
11 |
that cannot be filtered due to various reasons) |
12 |
|
13 |
--- |
14 |
roverlay/ebuild/depfilter.py | 68 ++++++++++++++++++++++++++++++++++++++++++ |
15 |
roverlay/ebuild/depres.py | 55 +++++++-------------------------- |
16 |
2 files changed, 80 insertions(+), 43 deletions(-) |
17 |
|
18 |
diff --git a/roverlay/ebuild/depfilter.py b/roverlay/ebuild/depfilter.py |
19 |
new file mode 100644 |
20 |
index 0000000..8aaf18e |
21 |
--- /dev/null |
22 |
+++ b/roverlay/ebuild/depfilter.py |
23 |
@@ -0,0 +1,68 @@ |
24 |
+def dep_allowed ( dep ): |
25 |
+ """Filters out redundant dependencies on dev-lang/R.""" |
26 |
+ |
27 |
+ if not dep: |
28 |
+ return 0 |
29 |
+ elif dep[0] in '|(': |
30 |
+ # compound dep statements "|| ( a b c )", "( a b c )" |
31 |
+ return 1 |
32 |
+ |
33 |
+ |
34 |
+ # the oldest version of dev-lang/R in portage |
35 |
+ OLDEST_R_VERSION = ( 2, 10, 1 ) |
36 |
+# OLDEST_R_VERSION = config.get ( |
37 |
+# "PORTAGE.lowest_r_version", "2.10.1" |
38 |
+# ).split ( '.' ) |
39 |
+ |
40 |
+ cat, sep, remainder = dep.partition ( '/' ) |
41 |
+ # don't strip leading '!' |
42 |
+ cat = cat.lstrip ( "<>=" ) |
43 |
+ |
44 |
+ |
45 |
+ if not sep: |
46 |
+ # cannot parse this |
47 |
+ return 2 |
48 |
+ |
49 |
+ elif cat != 'dev-lang': |
50 |
+ # only filtering dev-lang/R |
51 |
+ return 3 |
52 |
+ |
53 |
+ elif '[' in remainder: |
54 |
+ # USE flag requirements, e.g. "dev-lang/R[lapack]" |
55 |
+ return 4 |
56 |
+ |
57 |
+ # result is ${PN}-${PV} or ${PN}-${PV}-${PR} |
58 |
+ pn_or_pnpv, sepa, ver_or_rev = remainder.rpartition ( '-' ) |
59 |
+ |
60 |
+ if not sepa or not pn_or_pnpv: |
61 |
+ return 5 if ver_or_rev != 'R' else 0 |
62 |
+ |
63 |
+ elif pn_or_pnpv [0] != 'R' or ( |
64 |
+ len ( pn_or_pnpv ) > 1 and pn_or_pnpv [1] != '-' |
65 |
+ ): |
66 |
+ # only filtering dev-lang/R |
67 |
+ return 6 |
68 |
+ |
69 |
+ elif len ( ver_or_rev ) == 0: |
70 |
+ return 7 |
71 |
+ |
72 |
+ elif ver_or_rev [0] == 'r': |
73 |
+ try: |
74 |
+ pr = int ( ver_or_rev [1:] ) |
75 |
+ except ValueError: |
76 |
+ return 8 |
77 |
+ |
78 |
+ pn, sepa, ver_or_rev = pn_or_pnpv.rpartition ( '-' ) |
79 |
+ |
80 |
+ else: |
81 |
+ pn = pn_or_pnpv |
82 |
+ pr = 0 |
83 |
+ |
84 |
+ try: |
85 |
+ pv = tuple ( int (x) for x in ver_or_rev.split ( '.' ) ) + ( pr, ) |
86 |
+ except ValueError: |
87 |
+ raise |
88 |
+ return 9 |
89 |
+ |
90 |
+ return 10 if pv > OLDEST_R_VERSION else 0 |
91 |
+# --- end of dep_allowed (...) --- |
92 |
|
93 |
diff --git a/roverlay/ebuild/depres.py b/roverlay/ebuild/depres.py |
94 |
index 8b38e91..b08c913 100644 |
95 |
--- a/roverlay/ebuild/depres.py |
96 |
+++ b/roverlay/ebuild/depres.py |
97 |
@@ -2,10 +2,10 @@ |
98 |
# Copyright 2006-2012 Gentoo Foundation |
99 |
# Distributed under the terms of the GNU General Public License v2 |
100 |
|
101 |
+from roverlay import config |
102 |
from roverlay.depres import deptype |
103 |
-from roverlay.ebuild import evars |
104 |
+from roverlay.ebuild import evars, depfilter |
105 |
|
106 |
-# TODO/FIXME/IGNORE move this to const / config |
107 |
FIELDS_TO_EVAR = { |
108 |
'R_SUGGESTS' : ( 'Suggests', ), |
109 |
'DEPENDS' : ( 'Depends', 'Imports' ), |
110 |
@@ -16,19 +16,24 @@ FIELDS_TO_EVAR = { |
111 |
# setting per-field dep types here, in accordance with |
112 |
# http://cran.r-project.org/doc/manuals/R-exts.html#The-DESCRIPTION-file |
113 |
FIELDS = { |
114 |
+ |
115 |
# "The Depends field gives a comma-separated |
116 |
# list of >>package names<< which this package depends on." |
117 |
'Depends' : deptype.PKG, |
118 |
+ |
119 |
# "Other dependencies (>>external to the R system<<) |
120 |
# should be listed in the SystemRequirements field" |
121 |
'SystemRequirements' : deptype.SYS, |
122 |
+ |
123 |
# "The Imports field lists >>packages<< whose namespaces |
124 |
# are imported from (as specified in the NAMESPACE file) |
125 |
# but which do not need to be attached." |
126 |
'Imports' : deptype.PKG, |
127 |
+ |
128 |
# "The Suggests field uses the same syntax as Depends |
129 |
# and lists >>packages<< that are >>not necessarily needed<<." |
130 |
'Suggests' : deptype.internal, |
131 |
+ |
132 |
# "A package that wishes to make use of header files |
133 |
# in other >>packages<< needs to declare them as |
134 |
# a comma-separated list in the field LinkingTo in the DESCRIPTION file." |
135 |
@@ -174,44 +179,6 @@ class EbuildDepRes ( object ): |
136 |
|
137 |
def _make_result ( self ): |
138 |
"""Make evars using the depres result.""" |
139 |
- def dep_allowed ( dep ): |
140 |
- try: |
141 |
- #FIXME hardcoded |
142 |
- #FIXME fails for "qt-core" etc. |
143 |
- |
144 |
- # the oldest version of dev-lang/R in portage |
145 |
- OLDEST_R_VERSION = ( 2, 20, 1 ) |
146 |
- |
147 |
- if not dep: |
148 |
- return False |
149 |
- |
150 |
- cat, sep, remainder = dep.partition ( '/' ) |
151 |
- |
152 |
- if not sep: |
153 |
- raise Exception ( "bad dependency string '%s'!" % dep ) |
154 |
- |
155 |
- dep_list = remainder.split ( '-', 2 ) |
156 |
- |
157 |
- if len ( dep_list ) < 2: |
158 |
- ver = ( 0, ) |
159 |
- else: |
160 |
- ver = tuple ( int (x) for x in dep_list [1].split ( '.' ) ) |
161 |
- |
162 |
- |
163 |
- if cat.endswith ( 'dev-lang' ) \ |
164 |
- and dep_list [0] == 'R' \ |
165 |
- and cat [0] != '!' \ |
166 |
- : |
167 |
- if not ver: |
168 |
- # filters out 'dev-lang/R' |
169 |
- return False |
170 |
- else: |
171 |
- return ver > OLDEST_R_VERSION |
172 |
- except Exception as e: |
173 |
- self.logger.exception ( e ) |
174 |
- |
175 |
- return True |
176 |
- # --- end of dep_allowed (...) --- |
177 |
|
178 |
# RDEPEND -> <deps>, DEPEND -> <deps>, .. |
179 |
_depmap = dict() |
180 |
@@ -219,15 +186,17 @@ class EbuildDepRes ( object ): |
181 |
# (e.g. whether to include R_SUGGESTS in RDEPEND) |
182 |
for dep_type, channel in self._channels.items(): |
183 |
deplist = tuple ( filter ( |
184 |
- dep_allowed, channel.collect_dependencies() ) |
185 |
+ depfilter.dep_allowed, channel.collect_dependencies() ) |
186 |
) |
187 |
|
188 |
if len ( deplist ) > 0: |
189 |
- self.logger.debug ( "adding %s to %s", deplist, dep_type ) |
190 |
+ self.logger.debug ( |
191 |
+ "adding {deps} to {depvar}".format ( |
192 |
+ deps=deplist, depvar=dep_type |
193 |
+ ) ) |
194 |
_depmap [dep_type] = deplist |
195 |
# else: (effectively) no dependencies for dep_type |
196 |
|
197 |
- |
198 |
self._close_channels() |
199 |
|
200 |
self.has_suggests = bool ( 'R_SUGGESTS' in _depmap ) |