1 |
Author: zmedico |
2 |
Date: 2009-04-30 07:07:31 +0000 (Thu, 30 Apr 2009) |
3 |
New Revision: 13492 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.6/pym/portage/dbapi/porttree.py |
7 |
Log: |
8 |
Inside the portdbapi constructor, handle repositories with the same repo_name |
9 |
by discarding the ones that were encountered earlier. (trunk r13327) |
10 |
|
11 |
Modified: main/branches/2.1.6/pym/portage/dbapi/porttree.py |
12 |
=================================================================== |
13 |
--- main/branches/2.1.6/pym/portage/dbapi/porttree.py 2009-04-30 07:07:16 UTC (rev 13491) |
14 |
+++ main/branches/2.1.6/pym/portage/dbapi/porttree.py 2009-04-30 07:07:31 UTC (rev 13492) |
15 |
@@ -125,10 +125,6 @@ |
16 |
# this purpose because doebuild makes many changes to the config |
17 |
# instance that is passed in. |
18 |
self.doebuild_settings = config(clone=self.mysettings) |
19 |
- |
20 |
- porttree_root = os.path.realpath(porttree_root) |
21 |
- self.porttree_root = porttree_root |
22 |
- |
23 |
self.depcachedir = os.path.realpath(self.mysettings.depcachedir) |
24 |
|
25 |
if os.environ.get("SANDBOX_ON") == "1": |
26 |
@@ -140,6 +136,46 @@ |
27 |
os.environ["SANDBOX_WRITE"] = \ |
28 |
":".join(filter(None, sandbox_write)) |
29 |
|
30 |
+ porttrees = [os.path.realpath(porttree_root)] |
31 |
+ porttrees.extend(os.path.realpath(x) for x in \ |
32 |
+ self.mysettings.get('PORTDIR_OVERLAY', '').split()) |
33 |
+ treemap = {} |
34 |
+ repository_map = {} |
35 |
+ self.treemap = treemap |
36 |
+ self._repository_map = repository_map |
37 |
+ identically_named_paths = set() |
38 |
+ for path in porttrees: |
39 |
+ if path in repository_map: |
40 |
+ continue |
41 |
+ repo_name_path = os.path.join(path, REPO_NAME_LOC) |
42 |
+ try: |
43 |
+ repo_name = open(repo_name_path, 'r').readline().strip() |
44 |
+ except EnvironmentError: |
45 |
+ # warn about missing repo_name at some other time, since we |
46 |
+ # don't want to see a warning every time the portage module is |
47 |
+ # imported. |
48 |
+ pass |
49 |
+ else: |
50 |
+ identically_named_path = treemap.get(repo_name) |
51 |
+ if identically_named_path is not None: |
52 |
+ # The earlier one is discarded. |
53 |
+ del repository_map[identically_named_path] |
54 |
+ identically_named_paths.add(identically_named_path) |
55 |
+ if identically_named_path == porttrees[0]: |
56 |
+ # Found another repo with the same name as |
57 |
+ # $PORTDIR, so update porttrees[0] to match. |
58 |
+ porttrees[0] = path |
59 |
+ treemap[repo_name] = path |
60 |
+ repository_map[path] = repo_name |
61 |
+ |
62 |
+ # Ensure that each repo_name is unique. Later paths override |
63 |
+ # earlier ones that correspond to the same name. |
64 |
+ porttrees = [x for x in porttrees if x not in identically_named_paths] |
65 |
+ |
66 |
+ self.porttrees = porttrees |
67 |
+ porttree_root = porttrees[0] |
68 |
+ self.porttree_root = porttree_root |
69 |
+ |
70 |
self.eclassdb = eclass_cache.cache(porttree_root) |
71 |
|
72 |
# This is used as sanity check for aux_get(). If there is no |
73 |
@@ -155,22 +191,6 @@ |
74 |
self.xcache = {} |
75 |
self.frozen = 0 |
76 |
|
77 |
- self.porttrees = [self.porttree_root] + \ |
78 |
- [os.path.realpath(t) for t in self.mysettings["PORTDIR_OVERLAY"].split()] |
79 |
- self.treemap = {} |
80 |
- self._repository_map = {} |
81 |
- for path in self.porttrees: |
82 |
- repo_name_path = os.path.join(path, REPO_NAME_LOC) |
83 |
- try: |
84 |
- repo_name = open(repo_name_path, 'r').readline().strip() |
85 |
- self.treemap[repo_name] = path |
86 |
- self._repository_map[path] = repo_name |
87 |
- except (OSError,IOError): |
88 |
- # warn about missing repo_name at some other time, since we |
89 |
- # don't want to see a warning every time the portage module is |
90 |
- # imported. |
91 |
- pass |
92 |
- |
93 |
self._repo_info = {} |
94 |
eclass_dbs = {porttree_root : self.eclassdb} |
95 |
local_repo_configs = self.mysettings._local_repo_configs |