Move the stale elog cleanup code from _doebuild_spawn() to
authorZac Medico <zmedico@gentoo.org>
Tue, 7 Sep 2010 22:18:33 +0000 (15:18 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 7 Sep 2010 22:18:33 +0000 (15:18 -0700)
AbstractEbuildProcess._start() since that's a better place
if we decide to use phase_completed_file skip the spawning
of bash (dyn_unpack automatic clean/re-unpack logic could
be migrated here too).

pym/_emerge/AbstractEbuildProcess.py
pym/portage/package/ebuild/doebuild.py

index 39c8c5683694c98dee211ac703979a9572f48f71..a74a39437250c753bb593d27588c397f6d59a7e5 100644 (file)
@@ -44,10 +44,12 @@ class AbstractEbuildProcess(SpawnProcess):
 
        def _start(self):
 
+               need_builddir = self.phase not in self._phases_without_builddir
+
                # This can happen if the pre-clean phase triggers
                # die_hooks for some reason, and PORTAGE_BUILDDIR
                # doesn't exist yet.
-               if self.phase not in self._phases_without_builddir and \
+               if need_builddir and \
                        not os.path.isdir(self.settings['PORTAGE_BUILDDIR']):
                        msg = _("The ebuild phase '%s' has been aborted "
                        "since PORTAGE_BUILDIR does not exist: '%s'") % \
@@ -57,6 +59,20 @@ class AbstractEbuildProcess(SpawnProcess):
                        self.wait()
                        return
 
+               if need_builddir:
+                       phase_completed_file = os.path.join(
+                               self.settings['PORTAGE_BUILDDIR'],
+                               ".%sed" % self.phase.rstrip('e'))
+                       if not os.path.exists(phase_completed_file):
+                               # If the phase is really going to run then we want
+                               # to eliminate any stale elog messages that may
+                               # exist from a previous run.
+                               try:
+                                       os.unlink(os.path.join(self.settings['T'],
+                                               'logging', self.phase))
+                               except OSError:
+                                       pass
+
                if self.background:
                        # Automatically prevent color codes from showing up in logs,
                        # since we're not displaying to a terminal anyway.
index 862939dc3ee58f08ca46fd7ef08947f5a049103c..696b65eb7b9fea241ef1eb75bb2efbbd80116524 100644 (file)
@@ -92,18 +92,6 @@ def _doebuild_spawn(phase, settings, actionmap=None, **kwargs):
                        os.path.basename(EBUILD_SH_BINARY))),
                        ebuild_sh_arg)
 
-       if phase not in EbuildSpawnProcess._phases_without_builddir:
-               phase_completed_file = os.path.join(settings['PORTAGE_BUILDDIR'],
-                       ".%sed" % phase.rstrip('e'))
-               if not os.path.exists(phase_completed_file):
-                       # If the phase is really going to run then we want
-                       # to eliminate any stale elog messages that may
-                       # exist from a previous run.
-                       try:
-                               os.unlink(os.path.join(settings['T'], 'logging', phase))
-                       except OSError:
-                               pass
-
        settings['EBUILD_PHASE'] = phase
        try:
                return spawn(cmd, settings, **kwargs)