For bug #157385, enable portage.digestgen() to fetch any distfiles for which there...
authorZac Medico <zmedico@gentoo.org>
Thu, 7 Dec 2006 06:17:36 +0000 (06:17 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 7 Dec 2006 06:17:36 +0000 (06:17 -0000)
svn path=/main/trunk/; revision=5197

pym/portage.py

index 1e49367886180eb88266881aac407c9ba67a0d45..44206c34e3bd2ca823279bd634bebae0624c2369 100644 (file)
@@ -2478,9 +2478,41 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None
        global _doebuild_manifest_exempt_depend
        try:
                _doebuild_manifest_exempt_depend += 1
+               distfiles_map = {}
+               fetchlist_dict = FetchlistDict(mysettings["O"], mysettings, myportdb)
+               for cpv, fetchlist in fetchlist_dict.iteritems():
+                       for myfile in fetchlist:
+                               distfiles_map.setdefault(myfile, []).append(cpv)
                mf = Manifest(mysettings["O"], mysettings["DISTDIR"],
-                       fetchlist_dict=FetchlistDict(mysettings["O"],
-                       mysettings, myportdb))
+                       fetchlist_dict=fetchlist_dict)
+               missing_hashes = set(distfiles_map).difference(
+                       mf.fhashdict.get("DIST", {}))
+               if missing_hashes:
+                       missing_files = []
+                       for myfile in missing_hashes:
+                               try:
+                                       os.stat(os.path.join(mysettings["DISTDIR"], myfile))
+                               except OSError, e:
+                                       if e.errno != errno.ENOENT:
+                                               raise
+                                       del e
+                                       missing_files.append(myfile)
+                       if missing_files:
+                               mytree = os.path.realpath(os.path.dirname(
+                                       os.path.dirname(mysettings["O"])))
+                               myuris = []
+                               for myfile in missing_files:
+                                       for cpv in distfiles_map[myfile]:
+                                               alluris, aalist = myportdb.getfetchlist(
+                                                       cpv, mytree=mytree, all=True,
+                                                       mysettings=mysettings)
+                                               for i in xrange(len(aalist)):
+                                                       if aalist[i] == myfile:
+                                                               myuris.append(alluris[i])
+                               if not fetch(myuris, mysettings):
+                                       writemsg("!!! File %s doesn't exist, can't update " + \
+                                               "Manifest\n" % myfile, noiselevel=-1)
+                                       return 0
                writemsg_stdout(">>> Creating Manifest for %s\n" % mysettings["O"])
                try:
                        mf.create(requiredDistfiles=myarchives,