From: Zac Medico Date: Sat, 8 Sep 2012 05:35:03 +0000 (-0700) Subject: egencache: skip metadata-transfer if possible X-Git-Tag: v2.2.0_alpha125~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7da74976e44534bcb286bd9bcb7a7847ba4d6a14;p=portage.git egencache: skip metadata-transfer if possible If there is an existing metadata/md5-cache directory, then it's not necessary to forcibly enable metadata-transfer. --- diff --git a/bin/egencache b/bin/egencache index a0766b1f2..18ab45dde 100755 --- a/bin/egencache +++ b/bin/egencache @@ -35,6 +35,7 @@ import portage from portage import os, _encodings, _unicode_encode, _unicode_decode from _emerge.MetadataRegen import MetadataRegen from portage.cache.cache_errors import CacheError, StatCollision +from portage.cache.flat_hash import md5_database from portage.manifest import guessManifestFileType from portage.util import cmp_sort_key, writemsg_level from portage import cpv_getkey @@ -867,13 +868,40 @@ def egencache_main(args): parser.error('No action specified') return 1 + repo_path = None + if options.repo is not None: + repo_path = settings.repositories.treemap.get(options.repo) + if repo_path is None: + parser.error("Unable to locate repository named '%s'" % \ + (options.repo,)) + return 1 + else: + repo_path = settings.repositories.mainRepoLocation() + if not repo_path: + parser.error("PORTDIR is undefined") + return 1 + if options.update and 'metadata-transfer' not in settings.features: - settings.features.add('metadata-transfer') + metadata_transfer = True + repo_config = settings.repositories.get_repo_for_location(repo_path) + cache = repo_config.get_pregenerated_cache( + portage.dbapi.dbapi._known_keys, readonly=True) + if cache is not None: + if isinstance(cache, md5_database) and \ + os.path.isdir(cache.location): + metadata_transfer = False + cache = None + + if metadata_transfer: + settings.features.add('metadata-transfer') settings.lock() portdb = portage.portdbapi(mysettings=settings) + # Limit ebuilds to the specified repo. + portdb.porttrees = [repo_path] + if options.update: if options.cache_dir is not None: # already validated earlier @@ -889,18 +917,6 @@ def egencache_main(args): level=logging.ERROR, noiselevel=-1) return 1 - if options.repo is not None: - repo_path = portdb.getRepositoryPath(options.repo) - if repo_path is None: - parser.error("Unable to locate repository named '%s'" % \ - (options.repo,)) - return 1 - - # Limit ebuilds to the specified repo. - portdb.porttrees = [repo_path] - else: - portdb.porttrees = [portdb.porttree_root] - ret = [os.EX_OK] if options.update: