Gentoo Archives: gentoo-commits

From: "Paul Varner (fuzzyray)" <fuzzyray@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoolkit r737 - in trunk/gentoolkit: . bin pym/gentoolkit pym/gentoolkit/equery pym/gentoolkit/test
Date: Tue, 02 Feb 2010 17:07:00
Message-Id: E1NcMDI-0005XS-FY@stork.gentoo.org
1 Author: fuzzyray
2 Date: 2010-02-02 17:06:55 +0000 (Tue, 02 Feb 2010)
3 New Revision: 737
4
5 Modified:
6 trunk/gentoolkit/TODO
7 trunk/gentoolkit/bin/revdep-rebuild
8 trunk/gentoolkit/pym/gentoolkit/atom.py
9 trunk/gentoolkit/pym/gentoolkit/cpv.py
10 trunk/gentoolkit/pym/gentoolkit/dependencies.py
11 trunk/gentoolkit/pym/gentoolkit/equery/meta.py
12 trunk/gentoolkit/pym/gentoolkit/helpers.py
13 trunk/gentoolkit/pym/gentoolkit/metadata.py
14 trunk/gentoolkit/pym/gentoolkit/package.py
15 trunk/gentoolkit/pym/gentoolkit/test/test_helpers.py
16 trunk/gentoolkit/pym/gentoolkit/versionmatch.py
17 trunk/gentoolkit/setup.py
18 Log:
19 Merge genscripts revision 191
20
21 Modified: trunk/gentoolkit/TODO
22 ===================================================================
23 --- trunk/gentoolkit/TODO 2010-02-01 19:15:14 UTC (rev 736)
24 +++ trunk/gentoolkit/TODO 2010-02-02 17:06:55 UTC (rev 737)
25 @@ -21,12 +21,9 @@
26 - use /etc/gentoolkit/ebump.conf
27
28 equery:
29 - Tests:
30 - +helpers2 (FileOwner._extend_realpaths test probably doesn't clean up)
31 - Run pylint and write test to run pylint
32 - Write test to compile all modules (full syntax check). Take from portage.
33 Add more --debug stuff
34 Write tests for Dependencies._parser
35 + Profile Dependencies._parser
36 Refactor each module to be useful for import. Done modules:
37 +depends
38 +belongs
39 @@ -44,7 +41,7 @@
40
41 For Next Release:
42 - write NEWS file
43 - - make CPV.__init__ more strict, it allows some silly stuff
44 + - make CPV.__init__ more strict, it allows some silly stuff
45 - $ equery uses '>=sys-apps/portage-2'
46 * Searching for >=sys-apps/portage-2 ...
47 * Found these USE flags for sys-apps/portage-2.1.6.13:
48
49 Modified: trunk/gentoolkit/bin/revdep-rebuild
50 ===================================================================
51 --- trunk/gentoolkit/bin/revdep-rebuild 2010-02-01 19:15:14 UTC (rev 736)
52 +++ trunk/gentoolkit/bin/revdep-rebuild 2010-02-02 17:06:55 UTC (rev 737)
53 @@ -1149,7 +1149,7 @@
54 if [[ -r "$OWNERS_FILE" && -s "$OWNERS_FILE" ]]; then
55 show_unowned_files
56 fi
57 - [[ $KEEP_TEMP ]] || rm "${FILES[@]}"
58 + [[ $KEEP_TEMP ]] || rm -f "${FILES[@]}"
59 else
60 einfo 'Now you can remove -p (or --pretend) from arguments and re-run revdep-rebuild.'
61 fi
62
63 Modified: trunk/gentoolkit/pym/gentoolkit/atom.py
64 ===================================================================
65 --- trunk/gentoolkit/pym/gentoolkit/atom.py 2010-02-01 19:15:14 UTC (rev 736)
66 +++ trunk/gentoolkit/pym/gentoolkit/atom.py 2010-02-02 17:06:55 UTC (rev 737)
67 @@ -1,6 +1,6 @@
68 #!/usr/bin/python
69 #
70 -# Copyright(c) 2009-2010, Gentoo Foundation
71 +# Copyright 2009-2010 Gentoo Foundation
72 #
73 # Licensed under the GNU General Public License, v2
74 #
75 @@ -27,21 +27,8 @@
76 # =======
77
78 class Atom(portage.dep.Atom, CPV):
79 - """Portage's Atom class with an improvements from pkgcore.
80 + """Portage's Atom class with improvements from pkgcore.
81
82 - Gentoolkit's Atom is not backwards compatible with Portage's because we set
83 - parts and combinations of parts of cpv as attributes on Atom.cpv instead of
84 - putting them directly in Atom's namespace like Portage does, for one.
85 - For example:
86 - Gentoolkit.Atom: str(atom.cpv) # cpv string
87 - atom.cpv.category # category
88 - Portage.Atom: atom.cpv # cpv string
89 - atom.category # category
90 -
91 - Also, Portage's Atom.slot is a string, whereas
92 - Gentoolkit's Atom.slot is a tuple as in pkgcore, since multiple slots are
93 - OK
94 -
95 portage.dep.Atom provides the following instance variables:
96
97 @type operator: str
98 @@ -70,7 +57,7 @@
99 if self.operator is None:
100 self.operator = ''
101
102 - self.cpv = CPV(self.cpv)
103 + CPV.__init__(self, self.cpv)
104
105 # use_conditional is USE flag condition for this Atom to be required:
106 # For: !build? ( >=sys-apps/sed-4.0.5 ), use_conditional = '!build'
107 @@ -84,7 +71,7 @@
108 if self.operator != other.operator:
109 return False
110
111 - if self.cpv != other.cpv:
112 + if not CPV.__eq__(self, other):
113 return False
114
115 if bool(self.blocker) != bool(other.blocker):
116 @@ -112,14 +99,10 @@
117 return False
118
119 # Not supported by Portage Atom yet
120 - #return cmp(self.repo_id, other.repo_id)
121 + #return cmp(self.repo_name, other.repo_name)
122 return True
123
124 def __ne__(self, other):
125 - if not isinstance(other, self.__class__):
126 - err = "other isn't of %s type, is %s"
127 - raise TypeError(err % (self.__class__, other.__class__))
128 -
129 return not self == other
130
131 def __lt__(self, other):
132 @@ -130,8 +113,8 @@
133 if self.operator != other.operator:
134 return self.operator < other.operator
135
136 - if self.cpv != other.cpv:
137 - return self.cpv < other.cpv
138 + if not CPV.__eq__(self, other):
139 + return CPV.__lt__(self, other)
140
141 if bool(self.blocker) != bool(other.blocker):
142 # We want non blockers, then blockers, so only return True
143 @@ -162,7 +145,7 @@
144 return this_use < that_use
145
146 # Not supported by Portage Atom yet
147 - #return cmp(self.repo_id, other.repo_id)
148 + #return cmp(self.repo_name, other.repo_name)
149
150 return False
151
152 @@ -217,15 +200,15 @@
153 @see: L{pkgcore.ebuild.atom}
154 """
155 # Our "cp" (cat/pkg) must match exactly:
156 - if self.cpv.cp != other.cpv.cp:
157 + if self.cp != other.cp:
158 # Check to see if one is name only:
159 # Avoid slow partitioning if we're definitely not matching
160 # (yes, this is hackish, but it's faster):
161 - if self.cpv.cp[-1:] != other.cpv.cp[-1:]:
162 + if self.cp[-1:] != other.cp[-1:]:
163 return False
164
165 - if ((not self.cpv.category and self.cpv.name == other.cpv.name) or
166 - (not other.cpv.category and other.cpv.name == self.cpv.name)):
167 + if ((not self.category and self.name == other.name) or
168 + (not other.category and other.name == self.name)):
169 return True
170 return False
171
172 @@ -238,8 +221,8 @@
173 return False
174
175 # TODO: Uncomment when Portage's Atom supports repo
176 - #if (self.repo_id is not None and other.repo_id is not None and
177 - # self.repo_id != other.repo_id):
178 + #if (self.repo_name is not None and other.repo_name is not None and
179 + # self.repo_name != other.repo_name):
180 # return False
181
182 # Use deps are similar: if one of us forces a flag on and the
183 @@ -273,29 +256,29 @@
184 # If one of us is an exact match we intersect if the other matches it:
185 if self.operator == '=':
186 if other.operator == '=*':
187 - return self.cpv.fullversion.startswith(other.cpv.fullversion)
188 - return VersionMatch(other.cpv, op=other.operator).match(self.cpv)
189 + return self.fullversion.startswith(other.fullversion)
190 + return VersionMatch(other, op=other.operator).match(self)
191 if other.operator == '=':
192 if self.operator == '=*':
193 - return other.cpv.fullversion.startswith(self.cpv.fullversion)
194 - return VersionMatch(self.cpv, op=self.operator).match(other.cpv)
195 + return other.fullversion.startswith(self.fullversion)
196 + return VersionMatch(self, op=self.operator).match(other)
197
198 # If we are both ~ matches we match if we are identical:
199 if self.operator == other.operator == '~':
200 - return (self.cpv.version == other.cpv.version and
201 - self.cpv.revision == other.cpv.revision)
202 + return (self.version == other.version and
203 + self.revision == other.revision)
204
205 # If we are both glob matches we match if one of us matches the other.
206 if self.operator == other.operator == '=*':
207 - return (self.cpv.fullversion.startswith(other.cpv.fullversion) or
208 - other.cpv.fullversion.startswith(self.cpv.fullversion))
209 + return (self.fullversion.startswith(other.fullversion) or
210 + other.fullversion.startswith(self.fullversion))
211
212 # If one of us is a glob match and the other a ~ we match if the glob
213 # matches the ~ (ignoring a revision on the glob):
214 if self.operator == '=*' and other.operator == '~':
215 - return other.cpv.fullversion.startswith(self.cpv.version)
216 + return other.fullversion.startswith(self.version)
217 if other.operator == '=*' and self.operator == '~':
218 - return self.cpv.fullversion.startswith(other.cpv.version)
219 + return self.fullversion.startswith(other.version)
220
221 # If we get here at least one of us is a <, <=, > or >=:
222 if self.operator in ('<', '<=', '>', '>='):
223 @@ -313,42 +296,42 @@
224 # match the other's endpoint (just checking one endpoint
225 # is not enough, it would give a false positive on <=2 vs >2)
226 return (
227 - VersionMatch(other.cpv, op=other.operator).match(ranged.cpv) and
228 - VersionMatch(ranged.cpv, op=ranged.operator).match(other.cpv)
229 + VersionMatch(other, op=other.operator).match(ranged) and
230 + VersionMatch(ranged, op=ranged.operator).match(other)
231 )
232
233 if other.operator == '~':
234 # Other definitely matches its own version. If ranged also
235 # does we're done:
236 - if VersionMatch(ranged.cpv, op=ranged.operator).match(other.cpv):
237 + if VersionMatch(ranged, op=ranged.operator).match(other):
238 return True
239 # The only other case where we intersect is if ranged is a
240 # > or >= on other's version and a nonzero revision. In
241 # that case other will match ranged. Be careful not to
242 # give a false positive for ~2 vs <2 here:
243 return (ranged.operator in ('>', '>=') and
244 - VersionMatch(other.cpv, op=other.operator).match(ranged.cpv))
245 + VersionMatch(other, op=other.operator).match(ranged))
246
247 if other.operator == '=*':
248 # a glob match definitely matches its own version, so if
249 # ranged does too we're done:
250 - if VersionMatch(ranged.cpv, op=ranged.operator).match(other.cpv):
251 + if VersionMatch(ranged, op=ranged.operator).match(other):
252 return True
253 if '<' in ranged.operator:
254 # If other.revision is not defined then other does not
255 # match anything smaller than its own fullversion:
256 - if other.cpv.revision:
257 + if other.revision:
258 return False
259
260 # If other.revision is defined then we can always
261 # construct a package smaller than other.fullversion by
262 # tagging e.g. an _alpha1 on.
263 - return ranged.cpv.fullversion.startswith(other.cpv.version)
264 + return ranged.fullversion.startswith(other.version)
265 else:
266 # Remaining cases where this intersects: there is a
267 # package greater than ranged.fullversion and
268 # other.fullversion that they both match.
269 - return ranged.cpv.fullversion.startswith(other.cpv.version)
270 + return ranged.fullversion.startswith(other.version)
271
272 # Handled all possible ops.
273 raise NotImplementedError(
274
275 Modified: trunk/gentoolkit/pym/gentoolkit/cpv.py
276 ===================================================================
277 --- trunk/gentoolkit/pym/gentoolkit/cpv.py 2010-02-01 19:15:14 UTC (rev 736)
278 +++ trunk/gentoolkit/pym/gentoolkit/cpv.py 2010-02-02 17:06:55 UTC (rev 737)
279 @@ -1,6 +1,6 @@
280 #!/usr/bin/python
281 #
282 -# Copyright(c) 2009-2010, Gentoo Foundation
283 +# Copyright 2009-2010 Gentoo Foundation
284 #
285 # Licensed under the GNU General Public License, v2
286 #
287 @@ -40,7 +40,7 @@
288 """
289
290 def __init__(self, cpv):
291 - self.scpv = cpv
292 + self.cpv = cpv
293
294 values = split_cpv(cpv)
295 self.category = values[0]
296 @@ -61,16 +61,10 @@
297
298 def __eq__(self, other):
299 if not isinstance(other, self.__class__):
300 - raise TypeError("other isn't of %s type, is %s" % (
301 - self.__class__, other.__class__)
302 - )
303 - return self.scpv == other.scpv
304 + return False
305 + return self.cpv == other.cpv
306
307 def __ne__(self, other):
308 - if not isinstance(other, self.__class__):
309 - raise TypeError("other isn't of %s type, is %s" % (
310 - self.__class__, other.__class__)
311 - )
312 return not self == other
313
314 def __lt__(self, other):
315 @@ -118,7 +112,7 @@
316 return "<%s %r>" % (self.__class__.__name__, str(self))
317
318 def __str__(self):
319 - return self.scpv
320 + return self.cpv
321
322
323 # =========
324
325 Modified: trunk/gentoolkit/pym/gentoolkit/dependencies.py
326 ===================================================================
327 --- trunk/gentoolkit/pym/gentoolkit/dependencies.py 2010-02-01 19:15:14 UTC (rev 736)
328 +++ trunk/gentoolkit/pym/gentoolkit/dependencies.py 2010-02-02 17:06:55 UTC (rev 737)
329 @@ -1,4 +1,4 @@
330 -# Copyright(c) 2009, Gentoo Foundation
331 +# Copyright 2009-2010 Gentoo Foundation
332 #
333 # Licensed under the GNU General Public License, v2
334 #
335 @@ -41,12 +41,12 @@
336 """
337 def __init__(self, cpv, op='', parser=None):
338 if isinstance(cpv, CPV):
339 - self.cpv = cpv
340 + self.__dict__.update(cpv.__dict__)
341 else:
342 - self.cpv = CPV(cpv)
343 + CPV.__init__(self, cpv)
344
345 self.operator = op
346 - self.atom = self.operator + str(self.cpv)
347 + self.atom = self.operator + self.cpv
348 self.use = []
349 self.depatom = str()
350
351 @@ -74,9 +74,9 @@
352 # Try to use the Portage tree first, since emerge only uses the tree
353 # when calculating dependencies
354 try:
355 - result = PORTDB.aux_get(str(self.cpv), envvars)
356 + result = PORTDB.aux_get(self.cpv, envvars)
357 except KeyError:
358 - result = VARDB.aux_get(str(self.cpv), envvars)
359 + result = VARDB.aux_get(self.cpv, envvars)
360 return result
361
362 def get_depend(self):
363 @@ -153,7 +153,7 @@
364 except KeyError:
365 pkgdep = find_best_match(dep.atom)
366 depcache[dep.atom] = pkgdep
367 - if pkgdep and str(pkgdep.cpv) in seen:
368 + if pkgdep and pkgdep.cpv in seen:
369 continue
370 if depth < max_depth or max_depth <= 0:
371
372 @@ -162,7 +162,7 @@
373 if not pkgdep:
374 continue
375
376 - seen.add(str(pkgdep.cpv))
377 + seen.add(pkgdep.cpv)
378 result.append((
379 depth,
380 pkgdep.deps.graph_depends(
381 @@ -264,11 +264,11 @@
382 # Do not call if we have already called ourselves.
383 if (
384 dep_is_displayed and not only_direct and
385 - str(pkgdep.cpv) not in seen and
386 + pkgdep.cpv not in seen and
387 (depth < max_depth or max_depth == -1)
388 ):
389
390 - seen.add(str(pkgdep.cpv))
391 + seen.add(pkgdep.cpv)
392 result.append(
393 pkgdep.graph_reverse_depends(
394 pkgset=pkgset,
395
396 Modified: trunk/gentoolkit/pym/gentoolkit/equery/meta.py
397 ===================================================================
398 --- trunk/gentoolkit/pym/gentoolkit/equery/meta.py 2010-02-01 19:15:14 UTC (rev 736)
399 +++ trunk/gentoolkit/pym/gentoolkit/equery/meta.py 2010-02-02 17:06:55 UTC (rev 737)
400 @@ -1,4 +1,4 @@
401 -# Copyright(c) 2009-2010, Gentoo Foundation
402 +# Copyright 2009-2010 Gentoo Foundation
403 #
404 # Licensed under the GNU General Public License, v2 or higher
405 #
406 @@ -143,8 +143,10 @@
407 maintstr = maint.email
408 if CONFIG['verbose']:
409 maintstr += " (%s)" % (maint.name,) if maint.name else ''
410 - maintstr += "\n%s" % (maint.description,) \
411 - if maint.description else ''
412 + maintstr += " - %s" % (maint.restrict,) if maint.restrict else ''
413 + maintstr += "\n%s" % (
414 + (maint.description,) if maint.description else ''
415 + )
416 result.append(maintstr)
417
418 return result
419 @@ -231,7 +233,7 @@
420 def format_keywords_line(pkg, fmtd_keywords, slot, verstr_len):
421 """Format the entire keywords line for display."""
422
423 - ver = pkg.cpv.fullversion
424 + ver = pkg.fullversion
425 result = "%s:%s: %s" % (ver, pp.slot(slot), fmtd_keywords)
426 if CONFIG['verbose'] and fmtd_keywords:
427 result = format_line(fmtd_keywords, "%s:%s: " % (ver, pp.slot(slot)),
428 @@ -249,8 +251,8 @@
429 ref_pkg = get_reference_pkg(matches)
430
431 if CONFIG['verbose']:
432 - repo = ref_pkg.repo_id()
433 - print " * %s [%s]" % (pp.cpv(ref_pkg.cpv.cp), pp.section(repo))
434 + repo = ref_pkg.repo_name()
435 + print " * %s [%s]" % (pp.cpv(ref_pkg.cp), pp.section(repo))
436
437 got_opts = False
438 if any(QUERY_OPTS.values()):
439 @@ -294,7 +296,7 @@
440
441 for match in matches:
442 slot = match.environment('SLOT')
443 - verstr_len = len(match.cpv.fullversion) + len(slot)
444 + verstr_len = len(match.fullversion) + len(slot)
445 fmtd_keywords = format_keywords(keyword_map[match])
446 keywords_line = format_keywords_line(
447 match, fmtd_keywords, slot, verstr_len
448
449 Modified: trunk/gentoolkit/pym/gentoolkit/helpers.py
450 ===================================================================
451 --- trunk/gentoolkit/pym/gentoolkit/helpers.py 2010-02-01 19:15:14 UTC (rev 736)
452 +++ trunk/gentoolkit/pym/gentoolkit/helpers.py 2010-02-02 17:06:55 UTC (rev 737)
453 @@ -1,4 +1,4 @@
454 -# Copyright(c) 2009-2010, Gentoo Foundation
455 +# Copyright 2009-2010 Gentoo Foundation
456 #
457 # Licensed under the GNU General Public License, v2 or higher
458 #
459 @@ -114,7 +114,7 @@
460 for entry_set in self.indexed_entries:
461 i, entry = entry_set
462 # VersionMatch doesn't store .cp, so we'll force it to match here:
463 - i.cpv.cp = atom.cpv.cp
464 + i.cp = atom.cp
465 if atom.intersects(i):
466 result.append(entry)
467
468
469 Modified: trunk/gentoolkit/pym/gentoolkit/metadata.py
470 ===================================================================
471 --- trunk/gentoolkit/pym/gentoolkit/metadata.py 2010-02-01 19:15:14 UTC (rev 736)
472 +++ trunk/gentoolkit/pym/gentoolkit/metadata.py 2010-02-02 17:06:55 UTC (rev 737)
473 @@ -1,6 +1,6 @@
474 #!/usr/bin/python
475 #
476 -# Copyright(c) 2009-2010, Gentoo Foundation
477 +# Copyright 2009-2010 Gentoo Foundation
478 #
479 # Licensed under the GNU General Public License, v2
480 #
481 @@ -64,7 +64,8 @@
482 @ivar description: Description of what a maintainer does. Gentoo only.
483 @type restrict: str or None
484 @ivar restrict: e.g. &gt;=portage-2.2 means only maintains versions
485 - of Portage greater than 2.2.
486 + of Portage greater than 2.2. Should be DEPEND string with < and >
487 + converted to &lt; and &gt; respectively.
488 @type status: str or None
489 @ivar status: If set, either 'active' or 'inactive'. Upstream only.
490 """
491 @@ -208,6 +209,7 @@
492 try:
493 self._herdstree = etree.parse(herds_path)
494 except IOError:
495 + # For some trees, herds.xml may not exist. Bug #300108.
496 return None
497
498 # Some special herds are not listed in herds.xml
499 @@ -224,7 +226,7 @@
500 @type include_email: bool
501 @keyword include_email: if True, also look up the herd's email
502 @rtype: list
503 - @return: if include_email is False, return a list of string;
504 + @return: if include_email is False, return a list of strings;
505 if include_email is True, return a list of tuples containing:
506 [('herd1', 'herd1@g.o'), ('no-herd', None);
507 """
508
509 Modified: trunk/gentoolkit/pym/gentoolkit/package.py
510 ===================================================================
511 --- trunk/gentoolkit/pym/gentoolkit/package.py 2010-02-01 19:15:14 UTC (rev 736)
512 +++ trunk/gentoolkit/pym/gentoolkit/package.py 2010-02-02 17:06:55 UTC (rev 737)
513 @@ -1,7 +1,7 @@
514 #!/usr/bin/python
515 #
516 -# Copyright(c) 2004, Karl Trygve Kalleberg <karltk@g.o>
517 -# Copyright(c) 2004-2009, Gentoo Foundation
518 +# Copyright 2004, Karl Trygve Kalleberg <karltk@g.o>
519 +# Copyright 2004-2010 Gentoo Foundation
520 #
521 # Licensed under the GNU General Public License, v2
522 #
523 @@ -54,14 +54,14 @@
524
525 def __init__(self, cpv):
526 if isinstance(cpv, CPV):
527 - self.cpv = cpv
528 + self.__dict__.update(cpv.__dict__)
529 else:
530 - self.cpv = CPV(cpv)
531 + CPV.__init__(self, cpv)
532 del cpv
533
534 - if not all(getattr(self.cpv, x) for x in ('category', 'version')):
535 + if not all(hasattr(self, x) for x in ('category', 'version')):
536 # CPV allows some things that Package must not
537 - raise errors.GentoolkitInvalidPackage(str(self.cpv))
538 + raise errors.GentoolkitInvalidPackage(self.cpv)
539
540 # Set dynamically
541 self._package_path = None
542 @@ -71,30 +71,16 @@
543 self._portdir_path = None
544
545 def __repr__(self):
546 - return "<%s %r>" % (self.__class__.__name__, str(self.cpv))
547 + return "<%s %r>" % (self.__class__.__name__, self.cpv)
548
549 - def __eq__(self, other):
550 - if not hasattr(other, 'cpv'):
551 - return False
552 - return self.cpv == other.cpv
553 -
554 - def __ne__(self, other):
555 - return not self == other
556 -
557 - def __lt__(self, other):
558 - return self.cpv < other.cpv
559 -
560 - def __gt__(self, other):
561 - return self.cpv > other.cpv
562 -
563 def __hash__(self):
564 - return hash(str(self.cpv))
565 + return hash(self.cpv)
566
567 def __contains__(self, key):
568 - return key in str(self.cpv)
569 + return key in self.cpv
570
571 def __str__(self):
572 - return str(self.cpv)
573 + return self.cpv
574
575 @property
576 def metadata(self):
577 @@ -114,8 +100,8 @@
578
579 if self._dblink is None:
580 self._dblink = portage.dblink(
581 - self.cpv.category,
582 - "%s-%s" % (self.cpv.name, self.cpv.fullversion),
583 + self.category,
584 + "%s-%s" % (self.name, self.fullversion),
585 settings["ROOT"],
586 settings
587 )
588 @@ -131,7 +117,7 @@
589
590 return self._deps
591
592 - def environment(self, envvars, prefer_vdb=True, no_fallback=False):
593 + def environment(self, envvars, prefer_vdb=True, fallback=True):
594 """Returns one or more of the predefined environment variables.
595
596 Available envvars are:
597 @@ -157,8 +143,8 @@
598 @keyword prefer_vdb: if True, look in the vardb before portdb, else
599 reverse order. Specifically KEYWORDS will get more recent
600 information by preferring portdb.
601 - @type no_fallback: bool
602 - @keyword no_fallback: query only the preferred db
603 + @type fallback: bool
604 + @keyword fallback: query only the preferred db if False
605 @rtype: str or list
606 @return: str if envvars is str, list if envvars is array
607 @raise KeyError: if key is not found in requested db(s)
608 @@ -170,23 +156,23 @@
609 envvars = (envvars,)
610 if prefer_vdb:
611 try:
612 - result = VARDB.aux_get(str(self.cpv), envvars)
613 + result = VARDB.aux_get(self.cpv, envvars)
614 except KeyError:
615 try:
616 - if no_fallback:
617 + if not fallback:
618 raise KeyError
619 - result = PORTDB.aux_get(str(self.cpv), envvars)
620 + result = PORTDB.aux_get(self.cpv, envvars)
621 except KeyError:
622 err = "aux_get returned unexpected results"
623 raise errors.GentoolkitFatalError(err)
624 else:
625 try:
626 - result = PORTDB.aux_get(str(self.cpv), envvars)
627 + result = PORTDB.aux_get(self.cpv, envvars)
628 except KeyError:
629 try:
630 - if no_fallback:
631 + if not fallback:
632 raise KeyError
633 - result = VARDB.aux_get(str(self.cpv), envvars)
634 + result = VARDB.aux_get(self.cpv, envvars)
635 except KeyError:
636 err = "aux_get returned unexpected results"
637 raise errors.GentoolkitFatalError(err)
638 @@ -198,7 +184,7 @@
639 def exists(self):
640 """Return True if package exists in the Portage tree, else False"""
641
642 - return bool(PORTDB.cpv_exists(str(self.cpv)))
643 + return bool(PORTDB.cpv_exists(self.cpv))
644
645 @staticmethod
646 def settings(key):
647 @@ -228,7 +214,7 @@
648 if settings.locked:
649 settings.unlock()
650 try:
651 - result = portage.getmaskingstatus(str(self.cpv),
652 + result = portage.getmaskingstatus(self.cpv,
653 settings=settings,
654 portdb=PORTDB)
655 except KeyError:
656 @@ -247,7 +233,7 @@
657 """
658
659 try:
660 - result = portage.getmaskingreason(str(self.cpv),
661 + result = portage.getmaskingreason(self.cpv,
662 settings=settings,
663 portdb=PORTDB,
664 return_location=True)
665 @@ -271,8 +257,8 @@
666 """
667
668 if in_vartree:
669 - return VARDB.findname(str(self.cpv))
670 - return PORTDB.findname(str(self.cpv))
671 + return VARDB.findname(self.cpv)
672 + return PORTDB.findname(self.cpv)
673
674 def package_path(self, in_vartree=False):
675 """Return the path to where the ebuilds and other files reside."""
676 @@ -281,14 +267,26 @@
677 return self.dblink.getpath()
678 return os.sep.join(self.ebuild_path().split(os.sep)[:-1])
679
680 - def repo_id(self):
681 - """Using the package path, determine the repository id.
682 + def repo_name(self, fallback=True):
683 + """Determine the repository name.
684
685 + @type fallback: bool
686 + @param fallback: if the repo_name file does not exist, return the
687 + repository name from the path
688 @rtype: str
689 - @return: /usr/<THIS>portage</THIS>/category/name/
690 + @return: output of the repository metadata file, which stores the
691 + repo_name variable, or try to get the name of the repo from
692 + the path.
693 + @raise GentoolkitFatalError: if fallback is False and repo_name is
694 + not specified by the repository.
695 """
696
697 - return self.package_path().split(os.sep)[-3]
698 + try:
699 + return self.environment('repository')
700 + except errors.GentoolkitFatalError:
701 + if fallback:
702 + return self.package_path().split(os.sep)[-3]
703 + raise
704
705 def use(self):
706 """Returns the USE flags active at time of installation."""
707 @@ -311,11 +309,15 @@
708 @return: (size, number of files in total, number of uncounted files)
709 """
710
711 - contents = self.parsed_contents()
712 + seen = set()
713 + content_stats = (os.lstat(x) for x in self.parsed_contents())
714 + # Remove hardlinks by checking for duplicate inodes. Bug #301026.
715 + unique_file_stats = (x for x in content_stats if x.st_ino not in seen
716 + and not seen.add(x.st_ino))
717 size = n_uncounted = n_files = 0
718 - for cfile in contents:
719 + for st in unique_file_stats:
720 try:
721 - size += os.lstat(cfile).st_size
722 + size += st.st_size
723 n_files += 1
724 except OSError:
725 n_uncounted += 1
726 @@ -329,7 +331,7 @@
727 def is_overlay(self):
728 """Returns True if the package is in an overlay."""
729
730 - ebuild, tree = PORTDB.findname2(str(self.cpv))
731 + ebuild, tree = PORTDB.findname2(self.cpv)
732 if not ebuild:
733 return None
734 if self._portdir_path is None:
735 @@ -341,8 +343,8 @@
736 Note: We blindly assume that the package actually exists on disk
737 somewhere."""
738
739 - unmasked = PORTDB.xmatch("match-visible", str(self.cpv))
740 - return str(self.cpv) not in unmasked
741 + unmasked = PORTDB.xmatch("match-visible", self.cpv)
742 + return self.cpv not in unmasked
743
744
745 class PackageFormatter(object):
746
747 Modified: trunk/gentoolkit/pym/gentoolkit/test/test_helpers.py
748 ===================================================================
749 --- trunk/gentoolkit/pym/gentoolkit/test/test_helpers.py 2010-02-01 19:15:14 UTC (rev 736)
750 +++ trunk/gentoolkit/pym/gentoolkit/test/test_helpers.py 2010-02-02 17:06:55 UTC (rev 737)
751 @@ -7,6 +7,51 @@
752 from gentoolkit import helpers
753
754
755 +class TestChangeLog(unittest.TestCase):
756 +
757 + def setUp(self):
758 + pass
759 +
760 + def tearDown(self):
761 + pass
762 +
763 + def test_split_changelog(self):
764 + changelog = """
765 +*portage-2.1.6.2 (20 Dec 2008)
766 +
767 + 20 Dec 2008; Zac Medico <zmedico@g.o> +portage-2.1.6.2.ebuild:
768 + 2.1.6.2 bump. This fixes bug #251591 (repoman inherit.autotools false
769 + positives) and bug #251616 (performance issue in build log search regex
770 + makes emerge appear to hang). Bug #216231 tracks all bugs fixed since
771 + 2.1.4.x.
772 +
773 + 20 Dec 2008; Zac Medico <zmedico@g.o> -portage-2.1.6.ebuild,
774 + -portage-2.1.6.1.ebuild, -portage-2.2_rc17.ebuild:
775 + Remove old versions.
776 +
777 +
778 +*portage-2.1.6.1 (12 Dec 2008)
779 +
780 + 12 Dec 2008; Zac Medico <zmedico@g.o> +portage-2.1.6.1.ebuild:
781 + 2.1.6.1 bump. This fixes bug #250148 (emerge hangs with selinux if ebuild
782 + spawns a daemon), bug #250166 (trigger download when generating manifest
783 + if file size differs from existing entry), and bug #250212 (new repoman
784 + upstream.workaround category for emake -j1 warnings). Bug #216231 tracks
785 + all bugs fixed since 2.1.4.x.
786 +
787 +
788 +*portage-2.1.6 (07 Dec 2008)
789 +
790 + 07 Dec 2008; Zac Medico <zmedico@g.o> +portage-2.1.6.ebuild:
791 + 2.1.6 final release. This fixes bug #249586. Bug #216231 tracks all bugs
792 + fixed since 2.1.4.x.
793 +
794 + 07 Dec 2008; Zac Medico <zmedico@g.o> -portage-2.1.6_rc1.ebuild,
795 + -portage-2.1.6_rc2.ebuild, -portage-2.1.6_rc3.ebuild,
796 + -portage-2.2_rc16.ebuild:
797 + Remove old versions.
798 + """
799 +
800 class TestFileOwner(unittest.TestCase):
801
802 def setUp(self):
803
804 Modified: trunk/gentoolkit/pym/gentoolkit/versionmatch.py
805 ===================================================================
806 --- trunk/gentoolkit/pym/gentoolkit/versionmatch.py 2010-02-01 19:15:14 UTC (rev 736)
807 +++ trunk/gentoolkit/pym/gentoolkit/versionmatch.py 2010-02-02 17:06:55 UTC (rev 737)
808 @@ -1,9 +1,9 @@
809 #! /usr/bin/python
810 #
811 -# Copyright(c) 2009-2010 Gentoo Foundation
812 +# Copyright 2009-2010 Gentoo Foundation
813 # Licensed under the GNU General Public License, v2
814 #
815 -# Copyright(c): 2005-2007 Brian Harring <ferringb@×××××.com>
816 +# Copyright 2005-2007 Brian Harring <ferringb@×××××.com>
817 # License: GPL2/BSD
818 #
819 # $Header$
820 @@ -43,8 +43,10 @@
821 @keyword op: operator
822 """
823
824 - if not isinstance(cpv, CPV):
825 - raise ValueError("cpv must be a gentoolkit.cpv.CPV instance")
826 + if not isinstance(cpv, (CPV, self.__class__)):
827 + err = "cpv must be a gentoolkit.cpv.CPV "
828 + err += "or gentoolkit.versionmatch.VersionMatch instance"
829 + raise ValueError(err)
830 self.cpv = cpv
831 self.operator = op
832 self.version = cpv.version
833
834 Modified: trunk/gentoolkit/setup.py
835 ===================================================================
836 --- trunk/gentoolkit/setup.py 2010-02-01 19:15:14 UTC (rev 736)
837 +++ trunk/gentoolkit/setup.py 2010-02-02 17:06:55 UTC (rev 737)
838 @@ -41,6 +41,7 @@
839
840 def run(self):
841 ver = 'svn' if __version__ == '9999' else __version__
842 + print "Setting version to %s" % ver
843 def sub(files, pattern):
844 for f in files:
845 updated_file = []