summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-03-27 05:25:31 +0000
committerZac Medico <zmedico@gentoo.org>2006-03-27 05:25:31 +0000
commit3abd610842285717c547966d88c5eb499484c4d2 (patch)
tree7daa727cdf610bd7ae739bb6fcf67d1ee94bad2d
parent28967e6e154ccc0f2606df12a23efb50dffaa083 (diff)
downloadportage-3abd610842285717c547966d88c5eb499484c4d2.tar.gz
portage-3abd610842285717c547966d88c5eb499484c4d2.tar.bz2
portage-3abd610842285717c547966d88c5eb499484c4d2.zip
Compare new digest data with old digest data and rewrite the new digest only if they differ (forward port r2951 from manifest1 to manifest2).
svn path=/main/trunk/; revision=3022
-rw-r--r--pym/portage_manifest.py40
1 files changed, 36 insertions, 4 deletions
diff --git a/pym/portage_manifest.py b/pym/portage_manifest.py
index 4a5428c82..40122c212 100644
--- a/pym/portage_manifest.py
+++ b/pym/portage_manifest.py
@@ -1,4 +1,4 @@
-import os, sets
+import errno, os, sets
import portage, portage_exception, portage_versions, portage_const
from portage_checksum import *
@@ -114,18 +114,50 @@ class Manifest(object):
myhashdict[mytype][myname]["size"] = mysize
return myhashdict
- def _writeDigests(self):
+ def _writeDigests(self, force=False):
""" Create old style digest files for this Manifest instance """
cpvlist = [os.path.join(self.pkgdir.rstrip(os.sep).split(os.sep)[-2], x[:-7]) for x in portage.listdir(self.pkgdir) if x.endswith(".ebuild")]
rval = []
for cpv in cpvlist:
dname = os.path.join(self.pkgdir, "files", "digest-"+portage.catsplit(cpv)[1])
distlist = self._getCpvDistfiles(cpv)
- write_atomic(dname,
- "\n".join(self._createDigestLines1(distlist, self.fhashdict))+"\n")
+ update_digest = True
+ if not force:
+ try:
+ f = open(dname, "r")
+ old_data = self._parseDigests(f.readlines())
+ f.close()
+ if len(old_data) == 1 and "DIST" in old_data:
+ new_data = self._getDigestData(distlist)
+ for myfile in new_data["DIST"]:
+ for hashname in new_data["DIST"][myfile].keys():
+ if hashname != "size" and \
+ hashname not in portage_const.MANIFEST1_HASH_FUNCTIONS:
+ del new_data["DIST"][myfile][hashname]
+ if new_data["DIST"] == old_data["DIST"]:
+ update_digest = False
+ except (IOError, OSError), e:
+ if errno.ENOENT == e.errno:
+ pass
+ else:
+ raise
+ if update_digest:
+ write_atomic(dname,
+ "\n".join(self._createDigestLines1(distlist, self.fhashdict))+"\n")
rval.append(dname)
return rval
+ def _getDigestData(self, distlist):
+ """create a hash dict for a specific list of files"""
+ myhashdict = {}
+ for myname in distlist:
+ for mytype in self.fhashdict:
+ if myname in self.fhashdict[mytype]:
+ myhashdict.setdefault(mytype, {})
+ myhashdict[mytype].setdefault(myname, {})
+ myhashdict[mytype][myname] = self.fhashdict[mytype][myname]
+ return myhashdict
+
def _createDigestLines1(self, distlist, myhashdict):
""" Create an old style digest file."""
mylines = []