From c145e3cfcc016694f76488c21caaae37e3f3664e Mon Sep 17 00:00:00 2001 From: Sebastian Luther Date: Fri, 29 Nov 2013 19:02:21 +0100 Subject: [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk This is required to sync repositories using rsnyc. URL: https://bugs.gentoo.org/488972 --- bin/egencache | 14 ++++++++++++++ pym/portage/const.py | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/bin/egencache b/bin/egencache index 54c517e1d..915adc847 100755 --- a/bin/egencache +++ b/bin/egencache @@ -48,6 +48,7 @@ portage._internal_caller = True from portage import os, _encodings, _unicode_encode, _unicode_decode from _emerge.MetadataRegen import MetadataRegen from portage.cache.cache_errors import CacheError, StatCollision +from portage.const import TIMESTAMP_FORMAT from portage.manifest import guessManifestFileType from portage.package.ebuild._parallel_manifest.ManifestScheduler import ManifestScheduler from portage.util import cmp_sort_key, writemsg_level @@ -133,6 +134,9 @@ def parse_args(args): common.add_argument("--ignore-default-opts", action="store_true", help="do not use the EGENCACHE_DEFAULT_OPTS environment variable") + common.add_argument("--write-timestamp", + action="store_true", + help="write metdata/timestamp.chk as required for rsync repositories") update = parser.add_argument_group('--update options') update.add_argument("--cache-dir", @@ -1063,6 +1067,16 @@ def egencache_main(args): gen_clogs.run() ret.append(gen_clogs.returncode) + if options.write_timestamp: + timestamp_path = os.path.join(repo_path, 'metadata', 'timestamp.chk') + try: + with open(timestamp_path, 'w') as f: + f.write(time.strftime('%s\n' % TIMESTAMP_FORMAT, time.gmtime())) + except IOError: + ret.append(os.EX_IOERR) + else: + ret.append(os.EX_OK) + return max(ret) if __name__ == "__main__": diff --git a/pym/portage/const.py b/pym/portage/const.py index 214ede414..b2e970eb7 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -175,6 +175,10 @@ if "PORTAGE_OVERRIDE_EPREFIX" in os.environ: VCS_DIRS = ("CVS", "RCS", "SCCS", ".bzr", ".git", ".hg", ".svn") SUPPORTED_BINPKG_FORMATS = ("tar", "rpm") + +# Time formats used in various places like metadata.chk. +TIMESTAMP_FORMAT = "%a, %d %b %Y %H:%M:%S +0000" # to be used with time.gmtime() + # =========================================================================== # END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANT # =========================================================================== -- 2.26.2