summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-10-07 23:30:04 +0000
committerZac Medico <zmedico@gentoo.org>2009-10-07 23:30:04 +0000
commitd557bea6d2c3bc311d03f5a4887092957586a16d (patch)
tree82529f35aa18d1d5b4256f70fd0b453bf2517a91
parent753da5d98709eb5705254bfe208918d683abc262 (diff)
downloadportage-d557bea6d2c3bc311d03f5a4887092957586a16d.tar.gz
portage-d557bea6d2c3bc311d03f5a4887092957586a16d.tar.bz2
portage-d557bea6d2c3bc311d03f5a4887092957586a16d.zip
Bug #287950 - Add support for FEATURES=fail-clean which is useful for cleaning
up temp files on tmpfs after build failures with --keep-going. svn path=/main/trunk/; revision=14517
-rwxr-xr-xbin/ebuild5
-rw-r--r--man/make.conf.57
-rw-r--r--pym/_emerge/EbuildPhase.py25
-rw-r--r--pym/portage/dbapi/vartree.py5
4 files changed, 41 insertions, 1 deletions
diff --git a/bin/ebuild b/bin/ebuild
index c10705d0b..bcb55555c 100755
--- a/bin/ebuild
+++ b/bin/ebuild
@@ -199,6 +199,11 @@ if "test" in pargs:
tmpsettings["FEATURES"] = " ".join(sorted(tmpsettings.features))
tmpsettings.backup_changes("FEATURES")
+if 'fail-clean' in tmpsettings.features:
+ tmpsettings.features.remove('fail-clean')
+ tmpsettings["FEATURES"] = " ".join(sorted(tmpsettings.features))
+ tmpsettings.backup_changes("FEATURES")
+
if opts.skip_manifest:
tmpsettings["EBUILD_SKIP_MANIFEST"] = "1"
tmpsettings.backup_changes("EBUILD_SKIP_MANIFEST")
diff --git a/man/make.conf.5 b/man/make.conf.5
index c0b48e924..6ea14d6e4 100644
--- a/man/make.conf.5
+++ b/man/make.conf.5
@@ -213,6 +213,13 @@ when a problem arises (normally due to a crash or disconnect).
Enable fakeroot for the install and package phases when a non-root user runs
the \fBebuild\fR(1) command.
.TP
+.B fail\-clean
+Clean up temporary files after a build failure. This is particularly useful
+if you have \fBPORTAGE_TMPDIR\fR on tmpfs. If this feature is enabled, you
+probably also want to enable \fBPORT_LOGDIR\fR in order to save the build log.
+Both the \fBebuild\fR(1) command and the \fInoclean\fR feature cause the
+\fIfail\-clean\fR feature to be automatically disabled.
+.TP
.B fixpackages
Runs the script that will fix the dependencies in all binary packages. This is
run whenever packages are moved around in the portage tree. Please note that this
diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py
index 51f018cb1..fcf60d39c 100644
--- a/pym/_emerge/EbuildPhase.py
+++ b/pym/_emerge/EbuildPhase.py
@@ -45,6 +45,11 @@ class EbuildPhase(CompositeTask):
log_file.close()
if self._default_exit(ebuild_process) != os.EX_OK:
+ if self.phase != 'clean' and \
+ 'noclean' not in self.settings.features and \
+ 'fail-clean' in self.settings.features:
+ self._fail_clean()
+ return
self.wait()
return
@@ -80,7 +85,27 @@ class EbuildPhase(CompositeTask):
if self._final_exit(post_phase) != os.EX_OK:
writemsg("!!! post %s failed; exiting.\n" % self.phase,
noiselevel=-1)
+ if self.phase != 'clean' and \
+ 'noclean' not in self.settings.features and \
+ 'fail-clean' in self.settings.features:
+ self._fail_clean()
+ return
self._current_task = None
self.wait()
return
+ def _fail_clean(self):
+ self.returncode = None
+ portage.elog.elog_process(self.pkg.cpv, self.settings)
+ phase = "clean"
+ clean_phase = EbuildPhase(background=self.background,
+ pkg=self.pkg, phase=phase,
+ scheduler=self.scheduler, settings=self.settings,
+ tree=self.tree)
+ self._start_task(clean_phase, self._fail_clean_exit)
+ return
+
+ def _fail_clean_exit(self, clean_phase):
+ self._final_exit(clean_phase)
+ self.returncode = 1
+ self.wait()
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 5971ca647..c103cbd8d 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -4349,7 +4349,10 @@ class dblink(object):
# Process ebuild logfiles
elog_process(self.mycpv, self.settings, phasefilter=filter_mergephases)
- if retval == os.EX_OK and "noclean" not in self.settings.features:
+ if 'noclean' not in self.settings.features and \
+ (retval == os.EX_OK or \
+ ('fail-clean' in self.settings.features and \
+ os.path.isdir(self.settings['PORTAGE_BUILDDIR']))):
if myebuild is None:
myebuild = os.path.join(inforoot, self.pkg + ".ebuild")