Instead of calling the ebuild "clean" phase in MergeTask.merge(),
authorZac Medico <zmedico@gentoo.org>
Sun, 29 Jun 2008 03:13:17 +0000 (03:13 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 29 Jun 2008 03:13:17 +0000 (03:13 -0000)
move it inside doebuild() where it can be tied into the actionmap_deps
framework.

svn path=/main/trunk/; revision=10842

pym/_emerge/__init__.py
pym/portage/__init__.py

index 57463bab915333c0bd2c0afa0e92fbfebef3e0c4..c88d8af8f484a15af43fdbdba407859ed0a1db09 100644 (file)
@@ -6562,16 +6562,13 @@ class MergeTask(object):
                                build_dir = EbuildBuildDir(pkg=pkg, settings=pkgsettings)
                                try:
                                        build_dir.lock()
+                                       # Cleaning is triggered before the setup
+                                       # phase, in portage.doebuild().
                                        msg = " === (%s of %s) Cleaning (%s::%s)" % \
                                                (mergecount, len(mymergelist), pkg_key, y)
                                        short_msg = "emerge: (%s of %s) %s Clean" % \
                                                (mergecount, len(mymergelist), pkg_key)
                                        emergelog(xterm_titles, msg, short_msg=short_msg)
-                                       retval = portage.doebuild(y, "clean", myroot,
-                                               pkgsettings, self.edebug, cleanup=1,
-                                               mydbapi=portdb, tree="porttree")
-                                       if retval != os.EX_OK:
-                                               raise self._pkg_failure(retval)
 
                                        if "--buildpkg" in self.myopts or issyspkg:
                                                if issyspkg:
index 5c90a2ee1ffbc7a90e66cd28cf2557ba2f5b6439..6bdf03a7860b155aa5b1c9c3379449bc6c6bc5c1 100644 (file)
@@ -4817,6 +4817,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                vartree = db[myroot]["vartree"]
 
        features = mysettings.features
+       noauto = "noauto" in features
        from portage.data import secpass
 
        validcommands = ["help","clean","prerm","postrm","cleanrm","preinst","postinst",
@@ -4932,6 +4933,20 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                doebuild_environment(myebuild, mydo, myroot, mysettings, debug,
                        use_cache, mydbapi)
 
+               clean_phases = ("clean", "cleanrm")
+               if mydo in clean_phases or \
+                       (not noauto and mydo in actionmap_deps and \
+                       mysettings.get("EMERGE_FROM") == "ebuild"):
+                       if mydo not in clean_phases:
+                               mysettings["EBUILD_PHASE"] = "clean"
+                       try:
+                               retval = spawn(_shell_quote(ebuild_sh_binary) + " clean",
+                                       mysettings, debug=debug, free=1, logfile=None)
+                       finally:
+                               mysettings["EBUILD_PHASE"] = mydo
+                       if mydo in clean_phases or retval != os.EX_OK:
+                               return retval
+
                # get possible slot information from the deps file
                if mydo == "depend":
                        writemsg("!!! DEBUG: dbkey: %s\n" % str(dbkey), 2)
@@ -5144,10 +5159,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
 
                # if any of these are being called, handle them -- running them out of
                # the sandbox -- and stop now.
-               if mydo in ["clean","cleanrm"]:
-                       return spawn(_shell_quote(ebuild_sh_binary) + " clean", mysettings,
-                               debug=debug, free=1, logfile=None)
-               elif mydo == "help":
+               if mydo == "help":
                        return spawn(_shell_quote(ebuild_sh_binary) + " " + mydo,
                                mysettings, debug=debug, free=1, logfile=logfile)
                elif mydo == "setup":