1 |
commit: d3aebd49c1a6b893b078f5593677f295a8e77903 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Sep 7 16:29:48 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Sep 7 16:29:48 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d3aebd49 |
7 |
|
8 |
egencache: validate cache dir more |
9 |
|
10 |
--- |
11 |
bin/egencache | 22 +++++++++++++++++++--- |
12 |
1 files changed, 19 insertions(+), 3 deletions(-) |
13 |
|
14 |
diff --git a/bin/egencache b/bin/egencache |
15 |
index bf29474..66854e1 100755 |
16 |
--- a/bin/egencache |
17 |
+++ b/bin/egencache |
18 |
@@ -163,9 +163,13 @@ def parse_args(args): |
19 |
parser.error("Not a directory: --config-root='%s'" % \ |
20 |
(options.config_root,)) |
21 |
|
22 |
- if options.cache_dir is not None and not os.path.isdir(options.cache_dir): |
23 |
- parser.error("Not a directory: --cache-dir='%s'" % \ |
24 |
- (options.cache_dir,)) |
25 |
+ if options.cache_dir is not None: |
26 |
+ if not os.path.isdir(options.cache_dir): |
27 |
+ parser.error("Not a directory: --cache-dir='%s'" % \ |
28 |
+ (options.cache_dir,)) |
29 |
+ if not os.access(options.cache_dir, os.W_OK): |
30 |
+ parser.error("Write access denied: --cache-dir='%s'" % \ |
31 |
+ (options.cache_dir,)) |
32 |
|
33 |
if options.portdir_overlay is not None and \ |
34 |
options.repo is None: |
35 |
@@ -817,6 +821,18 @@ def egencache_main(args): |
36 |
level=logging.WARNING, noiselevel=-1) |
37 |
settings.features.add('metadata-transfer') |
38 |
|
39 |
+ if options.update: |
40 |
+ if options.cache_dir is not None: |
41 |
+ # already validated earlier |
42 |
+ pass |
43 |
+ else: |
44 |
+ if os.path.isdir(settings["PORTAGE_DEPCACHEDIR"]) and \ |
45 |
+ not os.access(settings["PORTAGE_DEPCACHEDIR"], os.W_OK): |
46 |
+ writemsg_level("ecachegen: error: " + \ |
47 |
+ "write access denied: %s\n" % (settings["PORTAGE_DEPCACHEDIR"],), |
48 |
+ level=logging.ERROR, noiselevel=-1) |
49 |
+ return 1 |
50 |
+ |
51 |
settings.lock() |
52 |
|
53 |
portdb = portage.portdbapi(mysettings=settings) |