From: Sebastian Luther Date: Fri, 29 Nov 2013 18:02:21 +0000 (+0100) Subject: egencache: --write-timestamp to create metadata/timestamp.chk X-Git-Tag: v2.2.8~38 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c145e3cfcc016694f76488c21caaae37e3f3664e;p=portage.git egencache: --write-timestamp to create metadata/timestamp.chk This is required to sync repositories using rsnyc. URL: https://bugs.gentoo.org/488972 --- 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 # ===========================================================================