summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-04-12 02:55:17 +0000
committerZac Medico <zmedico@gentoo.org>2009-04-12 02:55:17 +0000
commit3fdb4663ebdb0653a0dae919442b2d9948647fbe (patch)
tree6bd8911452ba8798e8a25288bafd05ef979c2869
parent0d7f95f63c7e5d858cd1ac3e10bcf47c0c6b5dc4 (diff)
downloadportage-3fdb4663ebdb0653a0dae919442b2d9948647fbe.tar.gz
portage-3fdb4663ebdb0653a0dae919442b2d9948647fbe.tar.bz2
portage-3fdb4663ebdb0653a0dae919442b2d9948647fbe.zip
Inside the portdbapi constructor, handle repositories with the same repo_name
by discarding the ones that were encountered earlier. svn path=/main/trunk/; revision=13327
-rw-r--r--pym/portage/dbapi/porttree.py60
1 files changed, 40 insertions, 20 deletions
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index 1bc08b8fa..a7e074d45 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -125,10 +125,6 @@ class portdbapi(dbapi):
# this purpose because doebuild makes many changes to the config
# instance that is passed in.
self.doebuild_settings = config(clone=self.mysettings)
-
- porttree_root = os.path.realpath(porttree_root)
- self.porttree_root = porttree_root
-
self.depcachedir = os.path.realpath(self.mysettings.depcachedir)
if os.environ.get("SANDBOX_ON") == "1":
@@ -140,6 +136,46 @@ class portdbapi(dbapi):
os.environ["SANDBOX_WRITE"] = \
":".join(filter(None, sandbox_write))
+ porttrees = [os.path.realpath(porttree_root)]
+ porttrees.extend(os.path.realpath(x) for x in \
+ self.mysettings.get('PORTDIR_OVERLAY', '').split())
+ treemap = {}
+ repository_map = {}
+ self.treemap = treemap
+ self._repository_map = repository_map
+ identically_named_paths = set()
+ for path in porttrees:
+ if path in repository_map:
+ continue
+ repo_name_path = os.path.join(path, REPO_NAME_LOC)
+ try:
+ repo_name = open(repo_name_path, 'r').readline().strip()
+ except EnvironmentError:
+ # warn about missing repo_name at some other time, since we
+ # don't want to see a warning every time the portage module is
+ # imported.
+ pass
+ else:
+ identically_named_path = treemap.get(repo_name)
+ if identically_named_path is not None:
+ # The earlier one is discarded.
+ del repository_map[identically_named_path]
+ identically_named_paths.add(identically_named_path)
+ if identically_named_path == porttrees[0]:
+ # Found another repo with the same name as
+ # $PORTDIR, so update porttrees[0] to match.
+ porttrees[0] = path
+ treemap[repo_name] = path
+ repository_map[path] = repo_name
+
+ # Ensure that each repo_name is unique. Later paths override
+ # earlier ones that correspond to the same name.
+ porttrees = [x for x in porttrees if x not in identically_named_paths]
+
+ self.porttrees = porttrees
+ porttree_root = porttrees[0]
+ self.porttree_root = porttree_root
+
self.eclassdb = eclass_cache.cache(porttree_root)
# This is used as sanity check for aux_get(). If there is no
@@ -155,22 +191,6 @@ class portdbapi(dbapi):
self.xcache = {}
self.frozen = 0
- self.porttrees = [self.porttree_root] + \
- [os.path.realpath(t) for t in self.mysettings["PORTDIR_OVERLAY"].split()]
- self.treemap = {}
- self._repository_map = {}
- for path in self.porttrees:
- repo_name_path = os.path.join(path, REPO_NAME_LOC)
- try:
- repo_name = open(repo_name_path, 'r').readline().strip()
- self.treemap[repo_name] = path
- self._repository_map[path] = repo_name
- except (OSError,IOError):
- # warn about missing repo_name at some other time, since we
- # don't want to see a warning every time the portage module is
- # imported.
- pass
-
self._repo_info = {}
eclass_dbs = {porttree_root : self.eclassdb}
local_repo_configs = self.mysettings._local_repo_configs