1 |
On Sat, 16 May 2015 13:59:14 -0700 |
2 |
Zac Medico <zmedico@g.o> wrote: |
3 |
|
4 |
> If the repo is read-only, write the cache to /var/cache/edb/dep |
5 |
> where IndexedPortdb searches for it. |
6 |
> |
7 |
> X-Gentoo-Bug: 549616 |
8 |
> X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=549616 |
9 |
> --- |
10 |
> bin/egencache | 17 ++++++++++++++++- |
11 |
> pym/portage/repository/config.py | 12 ++++++++++++ |
12 |
> 2 files changed, 28 insertions(+), 1 deletion(-) |
13 |
> |
14 |
> diff --git a/bin/egencache b/bin/egencache |
15 |
> index f97432f..6075ccf 100755 |
16 |
> --- a/bin/egencache |
17 |
> +++ b/bin/egencache |
18 |
> @@ -1086,8 +1086,23 @@ def egencache_main(args): |
19 |
> ret.append(scheduler.returncode) |
20 |
> |
21 |
> if options.update_pkg_desc_index: |
22 |
> + if repo_config.writable: |
23 |
> + writable_location = repo_config.location |
24 |
> + else: |
25 |
> + writable_location = |
26 |
> os.path.join(portdb.depcachedir, |
27 |
> + repo_config.location.lstrip(os.sep)) |
28 |
> + msg = [ |
29 |
> + "WARNING: Repository is not |
30 |
> writable: %s" % ( |
31 |
> + repo_config.location,), |
32 |
> + " Using cache directory |
33 |
> instead: %s" % ( |
34 |
> + writable_location,) |
35 |
> + ] |
36 |
> + msg = "".join(line + '\n' for line in msg) |
37 |
> + writemsg_level(msg, |
38 |
> + level=logging.WARNING, noiselevel=-1) |
39 |
> + |
40 |
> gen_index = GenPkgDescIndex(portdb, os.path.join( |
41 |
> - repo_config.location, "metadata", |
42 |
> "pkg_desc_index")) |
43 |
> + writable_location, "metadata", |
44 |
> "pkg_desc_index")) gen_index.run() |
45 |
> ret.append(gen_index.returncode) |
46 |
> |
47 |
> diff --git a/pym/portage/repository/config.py |
48 |
> b/pym/portage/repository/config.py index e44b619..05eedbe 100644 |
49 |
> --- a/pym/portage/repository/config.py |
50 |
> +++ b/pym/portage/repository/config.py |
51 |
> @@ -26,6 +26,7 @@ from portage.env.loaders import |
52 |
> KeyValuePairFileLoader from portage.util import (normalize_path, |
53 |
> read_corresponding_eapi_file, shlex_split, stack_lists, writemsg, |
54 |
> writemsg_level, _recursive_file_list) from portage.util._path import |
55 |
> exists_raise_eaccess, isdir_raise_eaccess +from portage.util.path |
56 |
> import first_existing from portage.localization import _ |
57 |
> from portage import _unicode_decode |
58 |
> from portage import _unicode_encode |
59 |
> @@ -346,6 +347,17 @@ class RepoConfig(object): |
60 |
> if new_repo.name is not None: |
61 |
> self.missing_repo_name = |
62 |
> new_repo.missing_repo_name |
63 |
> + @property |
64 |
> + def writable(self): |
65 |
> + """ |
66 |
> + Check if self.location is writable, or permissions |
67 |
> are sufficient |
68 |
> + to create it if it does not exist yet. |
69 |
> + @rtype: bool |
70 |
> + @return: True if self.location is writable or can be |
71 |
> created, |
72 |
> + False otherwise |
73 |
> + """ |
74 |
> + return os.access(first_existing(self.location), |
75 |
> os.W_OK) + |
76 |
> @staticmethod |
77 |
> def _read_valid_repo_name(repo_path): |
78 |
> name, missing = RepoConfig._read_repo_name(repo_path) |
79 |
|
80 |
|
81 |
Yeah, looks good |
82 |
|
83 |
-- |
84 |
Brian Dolbec <dolsen> |