From 2843806fad6d0aa07ad4ce97290ebe1d03b00104 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 25 Oct 2011 15:52:59 -0700 Subject: layout.conf: rename cache_format to cache_formats We read layout.conf cache-formats from left to right and use the first supported type that's found. This will allow support for multiple formats in parallel, providing for smooth transitions between formats. --- pym/portage/repository/config.py | 44 +++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'pym/portage/repository') diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py index 377ba4733..9b4a76f59 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -44,7 +44,7 @@ class RepoConfig(object): """Stores config of one repository""" __slots__ = ('aliases', 'allow_missing_manifest', - 'cache_format', 'create_manifest', 'disable_manifest', + 'cache_formats', 'create_manifest', 'disable_manifest', 'eclass_overrides', 'eclass_locations', 'format', 'location', 'main_repo', 'manifest_hashes', 'masters', 'missing_repo_name', 'name', 'priority', 'sign_manifest', 'sync', 'thin_manifest', @@ -128,22 +128,32 @@ class RepoConfig(object): self.disable_manifest = False self.manifest_hashes = None self.update_changelog = False - self.cache_format = None + self.cache_formats = None self.portage1_profiles = True self.portage1_profiles_compat = False def get_pregenerated_cache(self, auxdbkeys, readonly=True, force=False): - format = self.cache_format - if format is None: + """ + Reads layout.conf cache-formats from left to right and returns a + cache instance for the first supported type that's found. If no + cache-formats are specified in layout.conf, 'pms' type is assumed + if the metadata/cache directory exists or force is True. + """ + formats = self.cache_formats + if not formats: if not force: return None - format = 'pms' - if format == 'pms': - from portage.cache.metadata import database - name = 'metadata/cache' - elif format == 'md5-dict': - from portage.cache.flat_hash import md5_database as database - name = 'metadata/md5-cache' + formats = ('pms',) + + for fmt in formats: + if fmt == 'pms': + from portage.cache.metadata import database + name = 'metadata/cache' + break + elif fmt == 'md5-dict': + from portage.cache.flat_hash import md5_database as database + name = 'metadata/md5-cache' + break else: return None return database(self.location, name, @@ -379,7 +389,7 @@ class RepoConfigLoader(object): repo.aliases = tuple(aliases) + layout_data['aliases'] for value in ('sign-manifest', 'thin-manifest', 'allow-missing-manifest', - 'create-manifest', 'disable-manifest', 'cache-format', 'manifest-hashes', + 'create-manifest', 'disable-manifest', 'cache-formats', 'manifest-hashes', 'update-changelog'): setattr(repo, value.lower().replace("-", "_"), layout_data[value]) @@ -387,6 +397,8 @@ class RepoConfigLoader(object): for x in layout_data['profile-formats']) repo.portage1_profiles_compat = layout_data['profile-formats'] == ('portage-1-compat',) + repo.cache_formats = layout_data['cache-formats'] + #Take aliases into account. new_prepos = {} for repo_name, repo in prepos.items(): @@ -608,11 +620,11 @@ def parse_layout_conf(repo_location, repo_name=None): # for compatibility w/ PMS, fallback to pms; but also check if the # cache exists or not. - cache_format = layout_data.get('cache-format', 'pms').lower() - if cache_format == 'pms' and not os.path.isdir( + cache_formats = layout_data.get('cache-formats', 'pms').lower().split() + if 'pms' in cache_formats and not os.path.isdir( os.path.join(repo_location, 'metadata', 'cache')): - cache_format = None - data['cache-format'] = cache_format + cache_formats.remove('pms') + data['cache-formats'] = tuple(cache_formats) manifest_hashes = layout_data.get('manifest-hashes') if manifest_hashes is not None: -- cgit v1.2.3-1-g7c22