1 |
commit: a72a01746638debe472496bd8fc661992a6ba08b |
2 |
Author: Brian Harring <ferringb <AT> chromium <DOT> org> |
3 |
AuthorDate: Fri Sep 30 09:37:04 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Sep 30 17:32:34 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a72a0174 |
7 |
|
8 |
layout.conf: allow a repository to state the cache is authorative |
9 |
|
10 |
By authorative, this means "the cache is accurate; skip validation". While |
11 |
a useful hint for a slight speedup in validation, the true gain is for |
12 |
repositories that are distributed in a fashion that doesn't preserve mtime; |
13 |
git primarily. Setting authorative-cache = true results in portage |
14 |
skipping mtime validation checks for the bundled cache, allowing |
15 |
for git vcs based repos to distribute a cache. |
16 |
|
17 |
BUG=chromium-os:21049 |
18 |
TEST=dump a cache into metadata/cache, touch it to now, set layout.conf |
19 |
to authorative-cache=true, verify it doesn't generate cache entries |
20 |
for that repo. |
21 |
|
22 |
Change-Id: I92423e679bc171d2411a18d6d3ac22e8ef457753 |
23 |
|
24 |
--- |
25 |
pym/portage/cache/template.py | 1 + |
26 |
pym/portage/dbapi/porttree.py | 15 +++++++++------ |
27 |
pym/portage/repository/config.py | 4 +++- |
28 |
3 files changed, 13 insertions(+), 7 deletions(-) |
29 |
|
30 |
diff --git a/pym/portage/cache/template.py b/pym/portage/cache/template.py |
31 |
index f84d8f4..4cb27bf 100644 |
32 |
--- a/pym/portage/cache/template.py |
33 |
+++ b/pym/portage/cache/template.py |
34 |
@@ -30,6 +30,7 @@ class database(object): |
35 |
self.readonly = readonly |
36 |
self.sync_rate = 0 |
37 |
self.updates = 0 |
38 |
+ self.is_authorative = False |
39 |
|
40 |
def __getitem__(self, cpv): |
41 |
"""set a cpv to values |
42 |
|
43 |
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py |
44 |
index e679f00..ab38247 100644 |
45 |
--- a/pym/portage/dbapi/porttree.py |
46 |
+++ b/pym/portage/dbapi/porttree.py |
47 |
@@ -215,10 +215,12 @@ class portdbapi(dbapi): |
48 |
if x in self._pregen_auxdb: |
49 |
continue |
50 |
if os.path.isdir(os.path.join(x, "metadata", "cache")): |
51 |
- self._pregen_auxdb[x] = self.metadbmodule( |
52 |
+ conf = self.repositories.get_repo_for_location(x) |
53 |
+ cache = self._pregen_auxdb[x] = self.metadbmodule( |
54 |
x, "metadata/cache", filtered_auxdbkeys, readonly=True) |
55 |
+ cache.is_authorative = conf.cache_is_authorative |
56 |
try: |
57 |
- self._pregen_auxdb[x].ec = self._repo_info[x].eclass_db |
58 |
+ cache.ec = self._repo_info[x].eclass_db |
59 |
except AttributeError: |
60 |
pass |
61 |
# Selectively cache metadata in order to optimize dep matching. |
62 |
@@ -441,10 +443,11 @@ class portdbapi(dbapi): |
63 |
eapi = metadata.get('EAPI', '').strip() |
64 |
if not eapi: |
65 |
eapi = '0' |
66 |
- if not (eapi[:1] == '-' and eapi_is_supported(eapi[1:])) and \ |
67 |
- emtime == metadata['_mtime_'] and \ |
68 |
- eclass_db.is_eclass_data_valid(metadata['_eclasses_']): |
69 |
- doregen = False |
70 |
+ if not (eapi[:1] == '-' and eapi_is_supported(eapi[1:])): |
71 |
+ if auxdb.is_authorative or ( \ |
72 |
+ emtime == metadata['_mtime_'] and \ |
73 |
+ eclass_db.is_eclass_data_valid(metadata['_eclasses_'])): |
74 |
+ doregen = False |
75 |
|
76 |
if not doregen: |
77 |
break |
78 |
|
79 |
diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py |
80 |
index 3cb5501..6924450 100644 |
81 |
--- a/pym/portage/repository/config.py |
82 |
+++ b/pym/portage/repository/config.py |
83 |
@@ -43,7 +43,7 @@ class RepoConfig(object): |
84 |
|
85 |
__slots__ = ['aliases', 'eclass_overrides', 'eclass_locations', 'location', 'user_location', 'masters', 'main_repo', |
86 |
'missing_repo_name', 'name', 'priority', 'sync', 'format', 'sign_manifest', 'thin_manifest', |
87 |
- 'allow_missing_manifest', 'create_manifest', 'disable_manifest'] |
88 |
+ 'allow_missing_manifest', 'create_manifest', 'disable_manifest', 'cache_is_authorative'] |
89 |
|
90 |
def __init__(self, name, repo_opts): |
91 |
"""Build a RepoConfig with options in repo_opts |
92 |
@@ -117,6 +117,7 @@ class RepoConfig(object): |
93 |
self.allow_missing_manifest = False |
94 |
self.create_manifest = True |
95 |
self.disable_manifest = False |
96 |
+ self.cache_is_authorative = False |
97 |
|
98 |
def load_manifest(self, *args, **kwds): |
99 |
kwds['thin'] = self.thin_manifest |
100 |
@@ -357,6 +358,7 @@ class RepoConfigLoader(object): |
101 |
repo.allow_missing_manifest = manifest_policy != 'strict' |
102 |
repo.create_manifest = manifest_policy != 'false' |
103 |
repo.disable_manifest = manifest_policy == 'false' |
104 |
+ repo.cache_is_authorative = layout_data.get('authorative-cache', 'false').lower() == 'true' |
105 |
|
106 |
#Take aliases into account. |
107 |
new_prepos = {} |