Gentoo Archives: gentoo-portage-dev

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

Replies