diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-09-07 11:01:14 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-09-07 11:01:14 -0700 |
commit | 4b8614d99da3e4d5ce46c70c944cce5d5d1d9a1f (patch) | |
tree | 3ffbbc2c02043704a41f392a0d01dbff3ee6bb5b | |
parent | 5e1f136ba4c4f31dd5540594f48dc42f62ee09d9 (diff) | |
download | portage-4b8614d99da3e4d5ce46c70c944cce5d5d1d9a1f.tar.gz portage-4b8614d99da3e4d5ce46c70c944cce5d5d1d9a1f.tar.bz2 portage-4b8614d99da3e4d5ce46c70c944cce5d5d1d9a1f.zip |
egencache: tweak cache dir write access check
-rwxr-xr-x | bin/egencache | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/bin/egencache b/bin/egencache index 6229ed6cd..7766e786e 100755 --- a/bin/egencache +++ b/bin/egencache @@ -818,21 +818,25 @@ def egencache_main(args): if options.update and 'metadata-transfer' not in settings.features: settings.features.add('metadata-transfer') + settings.lock() + + portdb = portage.portdbapi(mysettings=settings) + if options.update: if options.cache_dir is not None: # already validated earlier pass else: - if os.path.isdir(settings["PORTAGE_DEPCACHEDIR"]) and \ - not os.access(settings["PORTAGE_DEPCACHEDIR"], os.W_OK): + # We check write access after the portdbapi constructor + # has had an opportunity to create it. This ensures that + # we don't use the cache in the "volatile" mode which is + # undesirable for egencache. + if not os.access(settings["PORTAGE_DEPCACHEDIR"], os.W_OK): writemsg_level("ecachegen: error: " + \ "write access denied: %s\n" % (settings["PORTAGE_DEPCACHEDIR"],), level=logging.ERROR, noiselevel=-1) return 1 - settings.lock() - - portdb = portage.portdbapi(mysettings=settings) if options.repo is not None: repo_path = portdb.getRepositoryPath(options.repo) if repo_path is None: |