1 |
commit: c145e3cfcc016694f76488c21caaae37e3f3664e |
2 |
Author: Sebastian Luther <SebastianLuther <AT> gmx <DOT> de> |
3 |
AuthorDate: Fri Nov 29 18:02:21 2013 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Nov 29 23:21:03 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c145e3cf |
7 |
|
8 |
egencache: --write-timestamp to create metadata/timestamp.chk |
9 |
|
10 |
This is required to sync repositories using rsnyc. |
11 |
|
12 |
URL: https://bugs.gentoo.org/488972 |
13 |
|
14 |
--- |
15 |
bin/egencache | 14 ++++++++++++++ |
16 |
pym/portage/const.py | 4 ++++ |
17 |
2 files changed, 18 insertions(+) |
18 |
|
19 |
diff --git a/bin/egencache b/bin/egencache |
20 |
index 54c517e..915adc8 100755 |
21 |
--- a/bin/egencache |
22 |
+++ b/bin/egencache |
23 |
@@ -48,6 +48,7 @@ portage._internal_caller = True |
24 |
from portage import os, _encodings, _unicode_encode, _unicode_decode |
25 |
from _emerge.MetadataRegen import MetadataRegen |
26 |
from portage.cache.cache_errors import CacheError, StatCollision |
27 |
+from portage.const import TIMESTAMP_FORMAT |
28 |
from portage.manifest import guessManifestFileType |
29 |
from portage.package.ebuild._parallel_manifest.ManifestScheduler import ManifestScheduler |
30 |
from portage.util import cmp_sort_key, writemsg_level |
31 |
@@ -133,6 +134,9 @@ def parse_args(args): |
32 |
common.add_argument("--ignore-default-opts", |
33 |
action="store_true", |
34 |
help="do not use the EGENCACHE_DEFAULT_OPTS environment variable") |
35 |
+ common.add_argument("--write-timestamp", |
36 |
+ action="store_true", |
37 |
+ help="write metdata/timestamp.chk as required for rsync repositories") |
38 |
|
39 |
update = parser.add_argument_group('--update options') |
40 |
update.add_argument("--cache-dir", |
41 |
@@ -1063,6 +1067,16 @@ def egencache_main(args): |
42 |
gen_clogs.run() |
43 |
ret.append(gen_clogs.returncode) |
44 |
|
45 |
+ if options.write_timestamp: |
46 |
+ timestamp_path = os.path.join(repo_path, 'metadata', 'timestamp.chk') |
47 |
+ try: |
48 |
+ with open(timestamp_path, 'w') as f: |
49 |
+ f.write(time.strftime('%s\n' % TIMESTAMP_FORMAT, time.gmtime())) |
50 |
+ except IOError: |
51 |
+ ret.append(os.EX_IOERR) |
52 |
+ else: |
53 |
+ ret.append(os.EX_OK) |
54 |
+ |
55 |
return max(ret) |
56 |
|
57 |
if __name__ == "__main__": |
58 |
|
59 |
diff --git a/pym/portage/const.py b/pym/portage/const.py |
60 |
index 214ede4..b2e970e 100644 |
61 |
--- a/pym/portage/const.py |
62 |
+++ b/pym/portage/const.py |
63 |
@@ -175,6 +175,10 @@ if "PORTAGE_OVERRIDE_EPREFIX" in os.environ: |
64 |
VCS_DIRS = ("CVS", "RCS", "SCCS", ".bzr", ".git", ".hg", ".svn") |
65 |
|
66 |
SUPPORTED_BINPKG_FORMATS = ("tar", "rpm") |
67 |
+ |
68 |
+# Time formats used in various places like metadata.chk. |
69 |
+TIMESTAMP_FORMAT = "%a, %d %b %Y %H:%M:%S +0000" # to be used with time.gmtime() |
70 |
+ |
71 |
# =========================================================================== |
72 |
# END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANT |
73 |
# =========================================================================== |