Count the number of merges processed by MergeTask and use that to determine whether...
authorZac Medico <zmedico@gentoo.org>
Fri, 6 Jul 2007 07:27:30 +0000 (07:27 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 6 Jul 2007 07:27:30 +0000 (07:27 -0000)
svn path=/main/branches/2.1.2/; revision=7179

bin/emerge

index d850b273698e4b5b9ecd05cf1d0b7161a4b9ba02..599c9bd6e495bb41da42c2ee2af24147670a4ba3 100755 (executable)
@@ -3301,6 +3301,7 @@ class MergeTask(object):
                if self.target_root != "/":
                        self.pkgsettings["/"] = \
                                portage.config(clone=trees["/"]["vartree"].settings)
+               self.curval = 0
 
        def merge(self, mylist, favorites, mtimedb):
                failed_fetches = []
@@ -3484,6 +3485,7 @@ class MergeTask(object):
                                                print "!!! Fetch for",y,"failed, continuing..."
                                                print
                                                failed_fetches.append(pkg_key)
+                                       self.curval += 1
                                        continue
 
                                portage.doebuild_environment(y, "setup", myroot,
@@ -3631,6 +3633,7 @@ class MergeTask(object):
 
                                if "--fetchonly" in self.myopts or \
                                        "--fetch-all-uri" in self.myopts:
+                                       self.curval += 1
                                        continue
 
                                short_msg = "emerge: ("+str(mergecount)+" of "+str(len(mymergelist))+") "+x[pkgindex]+" Merge Binary"
@@ -3737,6 +3740,7 @@ class MergeTask(object):
                        # in the event that portage is not allowed to exit normally
                        # due to power failure, SIGKILL, etc...
                        mtimedb.commit()
+                       self.curval += 1
 
                if "--pretend" not in self.myopts:
                        emergelog(xterm_titles, " *** Finished. Cleaning up...")
@@ -5212,6 +5216,12 @@ def action_build(settings, trees, mtimedb,
        myopts, myaction, myfiles, spinner):
        ldpath_mtimes = mtimedb["ldpath"]
        favorites=[]
+       merge_count = 0
+       pretend = "--pretend" in myopts
+       fetchonly = "--fetchonly" in myopts or "--fetch-all-uri" in myopts
+       if pretend or fetchonly:
+               # make the mtimedb readonly
+               mtimedb.filename = None
        if "--quiet" not in myopts and \
                ("--pretend" in myopts or "--ask" in myopts or \
                "--tree" in myopts or "--verbose" in myopts):
@@ -5414,8 +5424,7 @@ def action_build(settings, trees, mtimedb,
                        del mydepgraph
                        retval = mergetask.merge(
                                mtimedb["resume"]["mergelist"], favorites, mtimedb)
-                       if retval != os.EX_OK:
-                               return retval
+                       merge_count = mergetask.curval
                else:
                        if "resume" in mtimedb and \
                        "mergelist" in mtimedb["resume"] and \
@@ -5453,20 +5462,23 @@ def action_build(settings, trees, mtimedb,
                        del mydepgraph
                        mergetask = MergeTask(settings, trees, myopts)
                        retval = mergetask.merge(pkglist, favorites, mtimedb)
-                       if retval != os.EX_OK:
-                               return retval
+                       merge_count = mergetask.curval
+
+               if retval == os.EX_OK and not (pretend or fetchonly):
+                       mtimedb.pop("resume", None)
+                       if "yes" == settings.get("AUTOCLEAN"):
+                               portage.writemsg_stdout(">>> Auto-cleaning packages...\n")
+                               vartree = trees[settings["ROOT"]]["vartree"]
+                               unmerge(settings, myopts, vartree, "clean", ["world"],
+                                       ldpath_mtimes, autoclean=1)
+                       else:
+                               portage.writemsg_stdout(colorize("WARN", "WARNING:")
+                                       + " AUTOCLEAN is disabled.  This can cause serious"
+                                       + " problems due to overlapping packages.\n")
 
-               if mtimedb.has_key("resume"):
-                       del mtimedb["resume"]
-               if settings["AUTOCLEAN"] and "yes"==settings["AUTOCLEAN"]:
-                       portage.writemsg_stdout(">>> Auto-cleaning packages...\n")
-                       vartree = trees[settings["ROOT"]]["vartree"]
-                       unmerge(settings, myopts, vartree, "clean", ["world"],
-                               ldpath_mtimes, autoclean=1)
-               else:
-                       portage.writemsg_stdout(colorize("WARN", "WARNING:")
-                               + " AUTOCLEAN is disabled.  This can cause serious"
-                               + " problems due to overlapping packages.\n")
+               if merge_count and not (pretend or fetchonly):
+                       post_emerge(settings, mtimedb, retval)
+               return retval
 
 def multiple_actions(action1, action2):
        sys.stderr.write("\n!!! Multiple actions requested... Please choose one only.\n")
@@ -5990,8 +6002,6 @@ def emerge_main():
                validate_ebuild_environment(trees)
                retval = action_build(settings, trees, mtimedb,
                        myopts, myaction, myfiles, spinner)
-               if "--pretend" not in myopts:
-                       post_emerge(settings, mtimedb, retval)
                return retval
 
 if __name__ == "__main__":