Add files/ prefix for AUX files in manifest1 entries; fix digest.unused check partially by checking all DIST entries against all SRC_URI entries of a package (instead of per ebuild checks)

svn path=/main/trunk/; revision=3002
diff --git a/bin/repoman b/bin/repoman
index 9ef848b..4c6439e 100755
--- a/bin/repoman
+++ b/bin/repoman
@@ -31,6 +31,8 @@
 import time
 import codecs
 
+from portage_manifest import Manifest
+
 from output import *
 #bold, darkgreen, darkred, green, red, turquoise, yellow
 
@@ -102,7 +104,7 @@
 	"CVS/Entries.IO_error":"Attempting to commit, and an IO error was encountered access the Entries file",
 	"digest.partial":"Digest files do not contain all corresponding URI elements",
 	"digest.assumed":"Existing digest must be assumed correct (Package level only)",
-	"digest.unused":"Digest entry has no matching SRC_URI entry",
+	"digestentry.unused":"Digest/Manifest entry has no matching SRC_URI entry",
 	"digest.fail":"Digest does not match the specified local file",
 	"digest.stray":"Digest files that do not have a corresponding ebuild",
 	"digest.missing":"Digest files that are missing (ebuild exists, digest doesn't)",
@@ -177,7 +179,7 @@
 "digest.notadded",
 "digest.disjointed",
 "digest.missing",
-"digest.unused",
+"digestentry.unused",
 "DEPEND.badmasked","RDEPEND.badmasked","PDEPEND.badmasked",
 "DEPEND.badindev","RDEPEND.badindev","PDEPEND.badindev",
 "DEPEND.badmaskedindev","RDEPEND.badmaskedindev","PDEPEND.badmaskedindev",
@@ -818,6 +820,10 @@
 				fails["CVS/Entries.IO_error"].append(checkdir+"/files/CVS/Entries")
 			continue
 
+	mf=Manifest(checkdir, db=portage.db["/"]["porttree"].dbapi, mysettings=repoman_settings)
+	mydigests=mf.getTypeDigests("DIST")
+	myfiles_all = []
+
 	if os.path.exists(checkdir+"/files"):
 		filesdirlist=os.listdir(checkdir+"/files")
 		for y in filesdirlist:
@@ -834,8 +840,6 @@
 					stats["file.executable"] += 1
 					fails["file.executable"].append(x+"/files/"+y)
 				
-				mydigests=portage.digestParseFile(checkdir+"/files/"+y)
-				
 				mykey = catdir + "/" + y[7:]
 				if y[7:] not in ebuildlist:
 					#stray digest
@@ -850,10 +854,8 @@
 				else:
 					# We have an ebuild
 					myuris,myfiles = portage.db["/"]["porttree"].dbapi.getfetchlist(mykey,all=True)
-					for entry in mydigests.keys():
-						if entry not in myfiles:
-							stats["digest.unused"] += 1
-							fails["digest.unused"].append(y+"::"+entry)
+					myfiles_all.extend(myfiles)
+
 					uri_dict = {}
 					for myu in myuris:
 						myubn = os.path.basename(myu)
@@ -913,6 +915,11 @@
 					fails["file.name"].append("%s/files/%s: char '%s'" % (checkdir, y, c))
 					break
 
+	for entry in mydigests.keys():
+		if entry not in myfiles_all:
+			stats["digestentry.unused"] += 1
+			fails["digestentry.unused"].append(checkdir+"::"+entry)
+
 
 	if "ChangeLog" not in checkdirlist:
 		stats["changelog.missing"]+=1
diff --git a/man/repoman.1 b/man/repoman.1
index 66994ed..7a70245 100644
--- a/man/repoman.1
+++ b/man/repoman.1
@@ -178,7 +178,7 @@
 Digests which are incomplete (please check if your USE/ARCH includes all files)
 .TP
 .B digest.unused
-Digest entry has no matching SRC_URI entry
+Digest/Manifest entry has no matching SRC_URI entry
 .TP
 .B ebuild.allmasked
 All ebuilds are masked for this package (Package level only)
diff --git a/pym/portage_manifest.py b/pym/portage_manifest.py
index 962dbb4..a9f521e 100644
--- a/pym/portage_manifest.py
+++ b/pym/portage_manifest.py
@@ -63,6 +63,10 @@
 			rval.update(self.fhashdict[t])
 		return rval
 	
+	def getTypeDigests(self, ftype):
+		""" Similar to getDigests(), but restricted to files of the given type. """
+		return self.fhashdict[ftype]
+
 	def _readDigests(self):
 		""" Parse old style digest files for this Manifest instance """
 		mycontent = ""
@@ -140,6 +144,11 @@
 		mylines = []
 		for t in self.fhashdict.keys():
 			for f in self.fhashdict[t].keys():
+				# compat hack for v1 manifests
+				if t == "AUX":
+					f2 = os.path.join("files", f)
+				else:
+					f2 = f
 				myline = " ".join([t, f, str(self.fhashdict[t][f]["size"])])
 				myhashes = self.fhashdict[t][f]
 				for h in myhashes.keys():
@@ -151,7 +160,7 @@
 					for h in myhashes.keys():
 						if h not in portage_const.MANIFEST1_HASH_FUNCTIONS:
 							continue
-						mylines.append((" ".join([h, str(myhashes[h]), f, str(myhashes["size"])])))
+						mylines.append((" ".join([h, str(myhashes[h]), f2, str(myhashes["size"])])))
 		fd.write("\n".join(mylines))
 		fd.write("\n")