Bug #287950 - Add support for FEATURES=fail-clean which is useful for cleaning
authorZac Medico <zmedico@gentoo.org>
Wed, 7 Oct 2009 23:30:04 +0000 (23:30 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 7 Oct 2009 23:30:04 +0000 (23:30 -0000)
up temp files on tmpfs after build failures with --keep-going.

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

bin/ebuild
man/make.conf.5
pym/_emerge/EbuildPhase.py
pym/portage/dbapi/vartree.py

index c10705d0b85870617746ddeaf1eb8da36dc62409..bcb55555cba4505165f43545aec6f66bfaae4418 100755 (executable)
@@ -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")
index c0b48e92477aaab419331103dfaa22e5c450b32c..6ea14d6e4afaadcdbf51e73b0626dac065f1065e 100644 (file)
@@ -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 
index 51f018cb14e0067bac4f8c4e506b7681909447d7..fcf60d39c8eb128390bc62be9559554e3979fba8 100644 (file)
@@ -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()
index 5971ca647706c034b391467511023df193779e6a..c103cbd8dcc2d792b0128b9813eadeeaa56229ca 100644 (file)
@@ -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")