Bug #254825 - Improve messages that are displayed when manifest generation
authorZac Medico <zmedico@gentoo.org>
Wed, 14 Jan 2009 03:57:56 +0000 (03:57 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 14 Jan 2009 03:57:56 +0000 (03:57 -0000)
bails out due to a changed distfile digest. (trunk r12498)

svn path=/main/branches/2.1.6/; revision=12508

pym/portage/__init__.py

index a64bbab610dff19b275dc613f656ac96e90ee81e..2c33e52b6b3092c08a21174dd835f37cdca933b9 100644 (file)
@@ -3911,12 +3911,23 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
 
                                if not can_fetch:
                                        if fetched != 2:
-                                               if fetched == 0:
+                                               try:
+                                                       mysize = os.stat(myfile_path).st_size
+                                               except OSError, e:
+                                                       if e.errno != errno.ENOENT:
+                                                               raise
+                                                       del e
+                                                       mysize = 0
+
+                                               if mysize == 0:
                                                        writemsg("!!! File %s isn't fetched but unable to get it.\n" % myfile,
                                                                noiselevel=-1)
-                                               else:
+                                               elif size is None or size > mysize:
                                                        writemsg("!!! File %s isn't fully fetched, but unable to complete it\n" % myfile,
                                                                noiselevel=-1)
+                                               else:
+                                                       writemsg(("!!! File %s is incorrect size, " + \
+                                                               "but unable to retry.\n") % myfile, noiselevel=-1)
                                                for var_name in ("FETCHCOMMAND", "RESUMECOMMAND"):
                                                        if not mysettings.get(var_name, None):
                                                                writemsg(("!!! %s is unset.  It should " + \
@@ -4250,7 +4261,7 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None
                                fetch_settings = config(clone=mysettings)
                                debug = mysettings.get("PORTAGE_DEBUG") == "1"
                                for myfile in missing_files:
-                                       success = False
+                                       uris = set()
                                        for cpv in distfiles_map[myfile]:
                                                myebuild = os.path.join(mysettings["O"],
                                                        catsplit(cpv)[1] + ".ebuild")
@@ -4258,15 +4269,33 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None
                                                doebuild_environment(myebuild, "fetch",
                                                        mysettings["ROOT"], fetch_settings,
                                                        debug, 1, myportdb)
-                                               uri_map = myportdb.getFetchMap(cpv, mytree=mytree)
-                                               myuris = {myfile:uri_map[myfile]}
-                                               fetch_settings["A"] = myfile # for use by pkg_nofetch()
-                                               if fetch(myuris, fetch_settings):
-                                                       success = True
-                                                       break
-                                       if not success:
-                                               writemsg(("!!! File %s doesn't exist, can't update " + \
+                                               uris.update(myportdb.getFetchMap(
+                                                       cpv, mytree=mytree)[myfile])
+
+                                       fetch_settings["A"] = myfile # for use by pkg_nofetch()
+
+                                       try:
+                                               st = os.stat(os.path.join(
+                                                       mysettings["DISTDIR"],myfile))
+                                       except OSError:
+                                               st = None
+
+                                       if not fetch({myfile : uris}, fetch_settings):
+                                               writemsg(("!!! Fetch failed for %s, can't update " + \
                                                        "Manifest\n") % myfile, noiselevel=-1)
+                                               if myfile in dist_hashes and \
+                                                       st is not None and st.st_size > 0:
+                                                       # stat result is obtained before calling fetch(),
+                                                       # since fetch may rename the existing file if the
+                                                       # digest does not match.
+                                                       writemsg("!!! If you would like to " + \
+                                                               "forcefully replace the existing " + \
+                                                               "Manifest entry\n!!! for %s, use the " % \
+                                                               myfile + "following command:\n" + \
+                                                               "!!!    " + colorize("INFORM",
+                                                               "ebuild --force %s manifest" % \
+                                                               os.path.basename(myebuild)) + "\n",
+                                                               noiselevel=-1)
                                                return 0
                writemsg_stdout(">>> Creating Manifest for %s\n" % mysettings["O"])
                try: