1 |
commit: bd30c829d20bb50bfcab3faa99261154281f3953 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Oct 21 01:13:45 2014 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Dec 1 21:49:41 2014 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=bd30c829 |
7 |
|
8 |
Remove obsolete git_sync_timestamps function. |
9 |
|
10 |
This function is no longer needed since we switched to the md5-cache |
11 |
format which does not use timestamps. |
12 |
|
13 |
--- |
14 |
pym/portage/sync/modules/git/git.py | 8 +- |
15 |
pym/portage/sync/modules/git/timestamps.py | 154 ----------------------------- |
16 |
2 files changed, 1 insertion(+), 161 deletions(-) |
17 |
|
18 |
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py |
19 |
index 5e0e5df..d8c5a32 100644 |
20 |
--- a/pym/portage/sync/modules/git/git.py |
21 |
+++ b/pym/portage/sync/modules/git/git.py |
22 |
@@ -10,7 +10,6 @@ from portage.output import create_color_func |
23 |
good = create_color_func("GOOD") |
24 |
bad = create_color_func("BAD") |
25 |
warn = create_color_func("WARN") |
26 |
-from .timestamps import git_sync_timestamps |
27 |
from portage.sync.syncbase import SyncBase |
28 |
|
29 |
|
30 |
@@ -116,9 +115,4 @@ class GitSync(SyncBase): |
31 |
# Reload the whole config from scratch. |
32 |
settings, trees, mtimedb = load_emerge_config(emerge_config=emerge_config) |
33 |
adjust_configs(emerge_config.opts, emerge_config.trees) |
34 |
- portdb = trees[settings['EROOT']]['porttree'].dbapi |
35 |
- updatecache_flg = False |
36 |
- exitcode = git_sync_timestamps(portdb, location) |
37 |
- if exitcode == os.EX_OK: |
38 |
- updatecache_flg = True |
39 |
- return (exitcode, updatecache_flg) |
40 |
+ return (os.EX_OK, True) |
41 |
|
42 |
diff --git a/pym/portage/sync/modules/git/timestamps.py b/pym/portage/sync/modules/git/timestamps.py |
43 |
deleted file mode 100644 |
44 |
index 5e44845..0000000 |
45 |
--- a/pym/portage/sync/modules/git/timestamps.py |
46 |
+++ /dev/null |
47 |
@@ -1,154 +0,0 @@ |
48 |
-# Copyright 1999-2014 Gentoo Foundation |
49 |
-# Distributed under the terms of the GNU General Public License v2 |
50 |
- |
51 |
-import logging |
52 |
-import stat |
53 |
-import subprocess |
54 |
- |
55 |
- |
56 |
-import portage |
57 |
-from portage import os |
58 |
-from portage import _unicode_decode |
59 |
-from portage.util import writemsg_level |
60 |
-from portage.cache.cache_errors import CacheError |
61 |
- |
62 |
- |
63 |
-def git_sync_timestamps(portdb, portdir): |
64 |
- """ |
65 |
- Since git doesn't preserve timestamps, synchronize timestamps between |
66 |
- entries and ebuilds/eclasses. Assume the cache has the correct timestamp |
67 |
- for a given file as long as the file in the working tree is not modified |
68 |
- (relative to HEAD). |
69 |
- """ |
70 |
- |
71 |
- cache_db = portdb._pregen_auxdb.get(portdir) |
72 |
- |
73 |
- try: |
74 |
- if cache_db is None: |
75 |
- # portdbapi does not populate _pregen_auxdb |
76 |
- # when FEATURES=metadata-transfer is enabled |
77 |
- cache_db = portdb._create_pregen_cache(portdir) |
78 |
- except CacheError as e: |
79 |
- writemsg_level("!!! Unable to instantiate cache: %s\n" % (e,), |
80 |
- level=logging.ERROR, noiselevel=-1) |
81 |
- return 1 |
82 |
- |
83 |
- if cache_db is None: |
84 |
- return os.EX_OK |
85 |
- |
86 |
- if cache_db.validation_chf != 'mtime': |
87 |
- # newer formats like md5-dict do not require mtime sync |
88 |
- return os.EX_OK |
89 |
- |
90 |
- writemsg_level(">>> Synchronizing timestamps...\n") |
91 |
- |
92 |
- ec_dir = os.path.join(portdir, "eclass") |
93 |
- try: |
94 |
- ec_names = set(f[:-7] for f in os.listdir(ec_dir) \ |
95 |
- if f.endswith(".eclass")) |
96 |
- except OSError as e: |
97 |
- writemsg_level("!!! Unable to list eclasses: %s\n" % (e,), |
98 |
- level=logging.ERROR, noiselevel=-1) |
99 |
- return 1 |
100 |
- |
101 |
- args = [portage.const.BASH_BINARY, "-c", |
102 |
- "cd %s && git diff-index --name-only --diff-filter=M HEAD" % \ |
103 |
- portage._shell_quote(portdir)] |
104 |
- proc = subprocess.Popen(args, stdout=subprocess.PIPE) |
105 |
- modified_files = set(_unicode_decode(l).rstrip("\n") for l in proc.stdout) |
106 |
- rval = proc.wait() |
107 |
- proc.stdout.close() |
108 |
- if rval != os.EX_OK: |
109 |
- return rval |
110 |
- |
111 |
- modified_eclasses = set(ec for ec in ec_names \ |
112 |
- if os.path.join("eclass", ec + ".eclass") in modified_files) |
113 |
- |
114 |
- updated_ec_mtimes = {} |
115 |
- |
116 |
- for cpv in cache_db: |
117 |
- cpv_split = portage.catpkgsplit(cpv) |
118 |
- if cpv_split is None: |
119 |
- writemsg_level("!!! Invalid cache entry: %s\n" % (cpv,), |
120 |
- level=logging.ERROR, noiselevel=-1) |
121 |
- continue |
122 |
- |
123 |
- cat, pn, ver, rev = cpv_split |
124 |
- cat, pf = portage.catsplit(cpv) |
125 |
- relative_eb_path = os.path.join(cat, pn, pf + ".ebuild") |
126 |
- if relative_eb_path in modified_files: |
127 |
- continue |
128 |
- |
129 |
- try: |
130 |
- cache_entry = cache_db[cpv] |
131 |
- eb_mtime = cache_entry.get("_mtime_") |
132 |
- ec_mtimes = cache_entry.get("_eclasses_") |
133 |
- except KeyError: |
134 |
- writemsg_level("!!! Missing cache entry: %s\n" % (cpv,), |
135 |
- level=logging.ERROR, noiselevel=-1) |
136 |
- continue |
137 |
- except CacheError as e: |
138 |
- writemsg_level("!!! Unable to access cache entry: %s %s\n" % \ |
139 |
- (cpv, e), level=logging.ERROR, noiselevel=-1) |
140 |
- continue |
141 |
- |
142 |
- if eb_mtime is None: |
143 |
- writemsg_level("!!! Missing ebuild mtime: %s\n" % (cpv,), |
144 |
- level=logging.ERROR, noiselevel=-1) |
145 |
- continue |
146 |
- |
147 |
- try: |
148 |
- eb_mtime = long(eb_mtime) |
149 |
- except ValueError: |
150 |
- writemsg_level("!!! Invalid ebuild mtime: %s %s\n" % \ |
151 |
- (cpv, eb_mtime), level=logging.ERROR, noiselevel=-1) |
152 |
- continue |
153 |
- |
154 |
- if ec_mtimes is None: |
155 |
- writemsg_level("!!! Missing eclass mtimes: %s\n" % (cpv,), |
156 |
- level=logging.ERROR, noiselevel=-1) |
157 |
- continue |
158 |
- |
159 |
- if modified_eclasses.intersection(ec_mtimes): |
160 |
- continue |
161 |
- |
162 |
- missing_eclasses = set(ec_mtimes).difference(ec_names) |
163 |
- if missing_eclasses: |
164 |
- writemsg_level("!!! Non-existent eclass(es): %s %s\n" % \ |
165 |
- (cpv, sorted(missing_eclasses)), level=logging.ERROR, |
166 |
- noiselevel=-1) |
167 |
- continue |
168 |
- |
169 |
- eb_path = os.path.join(portdir, relative_eb_path) |
170 |
- try: |
171 |
- current_eb_mtime = os.stat(eb_path) |
172 |
- except OSError: |
173 |
- writemsg_level("!!! Missing ebuild: %s\n" % \ |
174 |
- (cpv,), level=logging.ERROR, noiselevel=-1) |
175 |
- continue |
176 |
- |
177 |
- inconsistent = False |
178 |
- for ec, (ec_path, ec_mtime) in ec_mtimes.items(): |
179 |
- updated_mtime = updated_ec_mtimes.get(ec) |
180 |
- if updated_mtime is not None and updated_mtime != ec_mtime: |
181 |
- writemsg_level("!!! Inconsistent eclass mtime: %s %s\n" % \ |
182 |
- (cpv, ec), level=logging.ERROR, noiselevel=-1) |
183 |
- inconsistent = True |
184 |
- break |
185 |
- |
186 |
- if inconsistent: |
187 |
- continue |
188 |
- |
189 |
- if current_eb_mtime != eb_mtime: |
190 |
- os.utime(eb_path, (eb_mtime, eb_mtime)) |
191 |
- |
192 |
- for ec, (ec_path, ec_mtime) in ec_mtimes.items(): |
193 |
- if ec in updated_ec_mtimes: |
194 |
- continue |
195 |
- ec_path = os.path.join(ec_dir, ec + ".eclass") |
196 |
- current_mtime = os.stat(ec_path)[stat.ST_MTIME] |
197 |
- if current_mtime != ec_mtime: |
198 |
- os.utime(ec_path, (ec_mtime, ec_mtime)) |
199 |
- updated_ec_mtimes[ec] = ec_mtime |
200 |
- |
201 |
- return os.EX_OK |