public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH 1/2] egencache: --write-timestamp to create metadata/timestamp.chk
@ 2013-11-29 18:02 SebastianLuther
  2013-11-29 18:02 ` [gentoo-portage-dev] [PATCH 2/2] Use portage.const.TIMESTAMP_FORMAT where appropriate SebastianLuther
  2013-11-29 23:25 ` [gentoo-portage-dev] [PATCH 1/2] egencache: --write-timestamp to create metadata/timestamp.chk Mike Frysinger
  0 siblings, 2 replies; 3+ messages in thread
From: SebastianLuther @ 2013-11-29 18:02 UTC (permalink / raw
  To: gentoo-portage-dev

From: Sebastian Luther <SebastianLuther@gmx.de>

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 54c517e..5088bdf 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(TIMESTAMP_FORMAT + "\n", 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 214ede4..02860e1 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.
+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
 # ===========================================================================
-- 
1.8.1.5



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-portage-dev] [PATCH 2/2] Use portage.const.TIMESTAMP_FORMAT where appropriate
  2013-11-29 18:02 [gentoo-portage-dev] [PATCH 1/2] egencache: --write-timestamp to create metadata/timestamp.chk SebastianLuther
@ 2013-11-29 18:02 ` SebastianLuther
  2013-11-29 23:25 ` [gentoo-portage-dev] [PATCH 1/2] egencache: --write-timestamp to create metadata/timestamp.chk Mike Frysinger
  1 sibling, 0 replies; 3+ messages in thread
From: SebastianLuther @ 2013-11-29 18:02 UTC (permalink / raw
  To: gentoo-portage-dev

From: Sebastian Luther <SebastianLuther@gmx.de>

---
 pym/_emerge/actions.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 86d67d2..19268cb 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -40,6 +40,7 @@ from portage import eapi_is_supported, _encodings, _unicode_decode
 from portage.cache.cache_errors import CacheError
 from portage.const import GLOBAL_CONFIG_PATH, VCS_DIRS, _DEPCLEAN_LIB_CHECK_DEFAULT
 from portage.const import SUPPORTED_BINPKG_FORMATS
+from portage.const import TIMESTAMP_FORMAT
 from portage.dbapi.dep_expand import dep_expand
 from portage.dbapi._expand_new_virt import expand_new_virt
 from portage.dep import Atom
@@ -2282,7 +2283,7 @@ def _sync_repo(emerge_config, repo):
 		if content:
 			try:
 				mytimestamp = time.mktime(time.strptime(content[0],
-					"%a, %d %b %Y %H:%M:%S +0000"))
+					TIMESTAMP_FORMAT))
 			except (OverflowError, ValueError):
 				pass
 		del content
@@ -2511,7 +2512,7 @@ def _sync_repo(emerge_config, repo):
 				if content:
 					try:
 						servertimestamp = time.mktime(time.strptime(
-							content[0], "%a, %d %b %Y %H:%M:%S +0000"))
+							content[0], TIMESTAMP_FORMAT))
 					except (OverflowError, ValueError):
 						pass
 				del mycommand, mypids, content
-- 
1.8.1.5



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [gentoo-portage-dev] [PATCH 1/2] egencache: --write-timestamp to create metadata/timestamp.chk
  2013-11-29 18:02 [gentoo-portage-dev] [PATCH 1/2] egencache: --write-timestamp to create metadata/timestamp.chk SebastianLuther
  2013-11-29 18:02 ` [gentoo-portage-dev] [PATCH 2/2] Use portage.const.TIMESTAMP_FORMAT where appropriate SebastianLuther
@ 2013-11-29 23:25 ` Mike Frysinger
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2013-11-29 23:25 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: SebastianLuther

[-- Attachment #1: Type: Text/Plain, Size: 26 bytes --]

thanks, pushed both
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-11-29 23:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-29 18:02 [gentoo-portage-dev] [PATCH 1/2] egencache: --write-timestamp to create metadata/timestamp.chk SebastianLuther
2013-11-29 18:02 ` [gentoo-portage-dev] [PATCH 2/2] Use portage.const.TIMESTAMP_FORMAT where appropriate SebastianLuther
2013-11-29 23:25 ` [gentoo-portage-dev] [PATCH 1/2] egencache: --write-timestamp to create metadata/timestamp.chk Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox