summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/_emerge/__init__.py7
-rw-r--r--pym/portage/__init__.py20
2 files changed, 18 insertions, 9 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 57463bab9..c88d8af8f 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -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:
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 5c90a2ee1..6bdf03a78 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -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":