From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org)
	by finch.gentoo.org with esmtp (Exim 4.60)
	(envelope-from <gentoo-commits+bounces-396728-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1RK3p9-0001bj-6q
	for garchives@archives.gentoo.org; Sat, 29 Oct 2011 07:59:27 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 2B27421C021;
	Sat, 29 Oct 2011 07:59:19 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id DD66321C021
	for <gentoo-commits@lists.gentoo.org>; Sat, 29 Oct 2011 07:59:18 +0000 (UTC)
Received: from pelican.gentoo.org (unknown [66.219.59.40])
	(using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 4BB4E1B4022
	for <gentoo-commits@lists.gentoo.org>; Sat, 29 Oct 2011 07:59:18 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by pelican.gentoo.org (Postfix) with ESMTP id 73B6380042
	for <gentoo-commits@lists.gentoo.org>; Sat, 29 Oct 2011 07:59:17 +0000 (UTC)
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" <zmedico@gentoo.org>
Message-ID: <a058baf9ed238a1f260b6739ba7fc10c6472f6ee.zmedico@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: bin/
X-VCS-Repository: proj/portage
X-VCS-Files: bin/egencache
X-VCS-Directories: bin/
X-VCS-Committer: zmedico
X-VCS-Committer-Name: Zac Medico
X-VCS-Revision: a058baf9ed238a1f260b6739ba7fc10c6472f6ee
Date: Sat, 29 Oct 2011 07:59:17 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: quoted-printable
X-Archives-Salt: 
X-Archives-Hash: 96661a316b1926b2c04e56d1b4bb7728

commit:     a058baf9ed238a1f260b6739ba7fc10c6472f6ee
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 29 07:59:02 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Oct 29 07:59:02 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a=
=3Dcommit;h=3Da058baf9

egencache: multiple cache-formats support

If layout.conf contains "cache-formats =3D md5-dict pms", egencache will
now write both formats.

---
 bin/egencache |   40 ++++++++++++++++++++++++++--------------
 1 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/bin/egencache b/bin/egencache
index dec10b1..477ba98 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -215,18 +215,22 @@ class GenCache(object):
 			max_jobs=3Dmax_jobs, max_load=3Dmax_load)
 		self.returncode =3D os.EX_OK
 		conf =3D portdb.repositories.get_repo_for_location(portdb.porttrees[0]=
)
-		self._trg_cache =3D conf.get_pregenerated_cache(portage.auxdbkeys[:],
-			force=3DTrue, readonly=3DFalse)
-		if self._trg_cache is None:
+		self._trg_caches =3D tuple(conf.iter_pregenerated_caches(
+			portage.auxdbkeys[:], force=3DTrue, readonly=3DFalse))
+		if not self._trg_caches:
 			raise Exception("cache formats '%s' aren't supported" %
 				(" ".join(conf.cache_formats),))
 		if rsync:
-			self._trg_cache.raise_stat_collision =3D True
-		try:
-			self._trg_cache.ec =3D \
-				portdb._repo_info[portdb.porttrees[0]].eclass_db
-		except AttributeError:
-			pass
+			from portage.cache.metadata import database as pms_database
+			for trg_cache in self._trg_caches:
+				if isinstance(trg_cache, pms_database):
+					trg_cache.raise_stat_collision =3D True
+					# Make _metadata_callback write this cache first, in case
+					# it raises a StatCollision and triggers mtime
+					# modification.
+					self._trg_caches =3D tuple([trg_cache] +
+						[x for x in self._trg_caches if x is not trg_cache])
+
 		self._existing_nodes =3D set()
=20
 	def _metadata_callback(self, cpv, repo_path, metadata, ebuild_hash):
@@ -235,11 +239,16 @@ class GenCache(object):
 		if metadata is not None:
 			if metadata.get('EAPI') =3D=3D '0':
 				del metadata['EAPI']
+			for trg_cache in self._trg_caches:
+				self._write_cache(trg_cache,
+					cpv, repo_path, metadata, ebuild_hash)
+
+	def _write_cache(self, trg_cache, cpv, repo_path, metadata, ebuild_hash=
):
 			try:
-				chf =3D self._trg_cache.validation_chf
+				chf =3D trg_cache.validation_chf
 				metadata['_%s_' % chf] =3D getattr(ebuild_hash, chf)
 				try:
-					self._trg_cache[cpv] =3D metadata
+					trg_cache[cpv] =3D metadata
 				except StatCollision as sc:
 					# If the content of a cache entry changes and neither the
 					# file mtime nor size changes, it will prevent rsync from
@@ -264,7 +273,7 @@ class GenCache(object):
 							level=3Dlogging.ERROR, noiselevel=3D-1)
 					else:
 						metadata['_mtime_'] =3D max_mtime
-						self._trg_cache[cpv] =3D metadata
+						trg_cache[cpv] =3D metadata
 						self._portdb.auxdb[repo_path][cpv] =3D metadata
=20
 			except CacheError as ce:
@@ -303,9 +312,12 @@ class GenCache(object):
 			sys.exit(received_signal[0])
=20
 		self.returncode |=3D self._regen.returncode
-		cp_missing =3D self._cp_missing
=20
-		trg_cache =3D self._trg_cache
+		for trg_cache in self._trg_caches:
+			self._cleanse_cache(trg_cache)
+
+	def _cleanse_cache(self, trg_cache):
+		cp_missing =3D self._cp_missing
 		dead_nodes =3D set()
 		if self._global_cleanse:
 			try: