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