Add eclass_db attribute in portage.repository.config.RepoConfig objects.
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org>
Fri, 9 Dec 2011 04:43:20 +0000 (05:43 +0100)
committerArfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org>
Fri, 9 Dec 2011 04:43:20 +0000 (05:43 +0100)
pym/portage/dbapi/porttree.py
pym/portage/repository/config.py

index 15f1faf3a07650005024089078a652dfc22c77d4..94961dda18887af69394511209d89b02162ce4a4 100644 (file)
@@ -111,7 +111,7 @@ class portdbapi(dbapi):
                                        ":".join(filter(None, sandbox_write))
 
                self.porttrees = list(self.settings.repositories.repoLocationList())
-               self.eclassdb = eclass_cache.cache(self.settings.repositories.mainRepoLocation())
+               self.eclassdb = self.repositories.mainRepo().eclass_db
 
                # This is used as sanity check for aux_get(). If there is no
                # root eclass dir, we assume that PORTDIR is invalid or
@@ -126,23 +126,11 @@ class portdbapi(dbapi):
 
                #Create eclass dbs
                self._repo_info = {}
-               eclass_dbs = {self.settings.repositories.mainRepoLocation() : self.eclassdb}
                for repo in self.repositories:
                        if repo.location in self._repo_info:
                                continue
 
-                       eclass_db = None
-                       for eclass_location in repo.eclass_locations:
-                               tree_db = eclass_dbs.get(eclass_location)
-                               if tree_db is None:
-                                       tree_db = eclass_cache.cache(eclass_location)
-                                       eclass_dbs[eclass_location] = tree_db
-                               if eclass_db is None:
-                                       eclass_db = tree_db.copy()
-                               else:
-                                       eclass_db.append(tree_db)
-
-                       self._repo_info[repo.location] = _repo_info(repo.name, repo.location, eclass_db)
+                       self._repo_info[repo.location] = _repo_info(repo.name, repo.location, repo.eclass_db)
 
                #Keep a list of repo names, sorted by priority (highest priority first).
                self._ordered_repo_name_list = tuple(reversed(self.repositories.prepos_order))
index ed0f64dde57d72add7d3ec3cce95806e6e1ff49a..4a8d8666eee8c7c67c4eccc1a39d0f92176ac0f0 100644 (file)
@@ -15,7 +15,7 @@ try:
                from configparser import SafeConfigParser
 except ImportError:
        from ConfigParser import SafeConfigParser, ParsingError
-from portage import os
+from portage import eclass_cache, os
 from portage.const import (MANIFEST2_HASH_FUNCTIONS, MANIFEST2_REQUIRED_HASH,
        REPO_NAME_LOC, USER_CONFIG_PATH)
 from portage.env.loaders import KeyValuePairFileLoader
@@ -47,7 +47,7 @@ class RepoConfig(object):
 
        __slots__ = ('aliases', 'allow_missing_manifest',
                'cache_formats', 'create_manifest', 'disable_manifest',
-               'eclass_overrides', 'eclass_locations', 'format', 'location',
+               'eclass_db', 'eclass_locations', 'eclass_overrides', 'format', 'location',
                'main_repo', 'manifest_hashes', 'masters', 'missing_repo_name',
                'name', 'priority', 'sign_manifest', 'sync', 'thin_manifest',
                'update_changelog', 'user_location', 'portage1_profiles',
@@ -66,7 +66,8 @@ class RepoConfig(object):
                if eclass_overrides is not None:
                        eclass_overrides = tuple(eclass_overrides.split())
                self.eclass_overrides = eclass_overrides
-               #Locations are computed later.
+               # Eclass databases and locations are computed later.
+               self.eclass_db = None
                self.eclass_locations = None
 
                # Masters from repos.conf override layout.conf.
@@ -543,6 +544,23 @@ class RepoConfigLoader(object):
                                                        level=logging.ERROR, noiselevel=-1)
                        repo.eclass_locations = tuple(eclass_locations)
 
+               eclass_dbs = {}
+               for repo_name, repo in prepos.items():
+                       if repo_name == "DEFAULT":
+                               continue
+
+                       eclass_db = None
+                       for eclass_location in repo.eclass_locations:
+                               tree_db = eclass_dbs.get(eclass_location)
+                               if tree_db is None:
+                                       tree_db = eclass_cache.cache(eclass_location)
+                                       eclass_dbs[eclass_location] = tree_db
+                               if eclass_db is None:
+                                       eclass_db = tree_db.copy()
+                               else:
+                                       eclass_db.append(tree_db)
+                       repo.eclass_db = eclass_db
+
                self._prepos_changed = True
                self._repo_location_list = []