Factor EBUILD_EXIT_STATUS_FILE code out of AbstractEbuildProcess
authorZac Medico <zmedico@gentoo.org>
Thu, 12 Aug 2010 12:56:22 +0000 (05:56 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 12 Aug 2010 12:56:22 +0000 (05:56 -0700)
subclasses and into AbstractEbuildProcess itself.

pym/_emerge/AbstractEbuildProcess.py
pym/_emerge/EbuildProcess.py
pym/_emerge/EbuildSpawnProcess.py
pym/_emerge/MiscFunctionsProcess.py
pym/portage/package/ebuild/doebuild.py

index 302d3440303d45d821f16a8c11ecd4f563a1251c..f4a87f68bce4731b728814a19e3d16c0860a4846 100644 (file)
@@ -3,12 +3,16 @@
 
 from _emerge.SpawnProcess import SpawnProcess
 import portage
+portage.proxy.lazyimport.lazyimport(globals(),
+       'portage.package.ebuild.doebuild:_doebuild_exit_status_check_and_log'
+)
 from portage import os
 from portage.util._pty import _create_pty_or_pipe
 
 class AbstractEbuildProcess(SpawnProcess):
 
        __slots__ = ('settings',)
+       _phases_without_builddir = ('clean', 'cleanrm', 'depend', 'help',)
 
        def _pipe(self, fd_pipes):
                stdout_pipe = fd_pipes.get(1)
@@ -22,3 +26,12 @@ class AbstractEbuildProcess(SpawnProcess):
                # See Bug #162404.
                return not ('sesandbox' in self.settings.features \
                        and self.settings.selinux_enabled()) or os.isatty(slave_fd)
+
+       def _set_returncode(self, wait_retval):
+               SpawnProcess._set_returncode(self, wait_retval)
+               phase = self.settings.get("EBUILD_PHASE")
+               if not phase:
+                       phase = 'other'
+               if phase not in self._phases_without_builddir:
+                       self.returncode = _doebuild_exit_status_check_and_log(
+                               self.settings, phase, self.returncode)
index a0ef2357a8c94e1329e3f6a7c695c5af810e9f55..147f73a16db1329bc8191092a51afb5138fd7645 100644 (file)
@@ -4,7 +4,7 @@
 from _emerge.AbstractEbuildProcess import AbstractEbuildProcess
 from portage import os
 from portage.package.ebuild.doebuild import doebuild, \
-       _doebuild_exit_status_check_and_log, _post_phase_userpriv_perms
+       _post_phase_userpriv_perms
 
 class EbuildProcess(AbstractEbuildProcess):
 
@@ -38,10 +38,6 @@ class EbuildProcess(AbstractEbuildProcess):
        def _set_returncode(self, wait_retval):
                AbstractEbuildProcess._set_returncode(self, wait_retval)
 
-               if self.phase not in ("clean", "cleanrm"):
-                       self.returncode = _doebuild_exit_status_check_and_log(
-                               self.settings, self.phase, self.returncode)
-
                if self.phase == "test" and self.returncode != os.EX_OK and \
                        "test-fail-continue" in self.settings.features:
                        self.returncode = os.EX_OK
index 36ec0a0c99eb94a53dc9f54022f51707fd0ab39d..d8087576ad49989c6639dbf89ae85fe3d9ac2fdc 100644 (file)
@@ -4,30 +4,15 @@
 from _emerge.AbstractEbuildProcess import AbstractEbuildProcess
 import portage
 from portage import os
-portage.proxy.lazyimport.lazyimport(globals(),
-       'portage.package.ebuild.doebuild:_doebuild_exit_status_check_and_log'
-)
 
 class EbuildSpawnProcess(AbstractEbuildProcess):
        """
-       Spawns misc-functions.sh with an existing ebuild environment.
+       Used by doebuild.spawn() to manage the spawned process.
        """
        _spawn_kwarg_names = AbstractEbuildProcess._spawn_kwarg_names + \
                ('fakeroot_state',)
 
        __slots__ = ('fakeroot_state', 'spawn_func')
 
-       def _start(self):
-
-               AbstractEbuildProcess._start(self)
-
        def _spawn(self, args, **kwargs):
                return self.spawn_func(args, **kwargs)
-
-       def _set_returncode(self, wait_retval):
-               AbstractEbuildProcess._set_returncode(self, wait_retval)
-               phase = self.settings.get("EBUILD_PHASE")
-               if not phase:
-                       phase = 'other'
-               self.returncode = _doebuild_exit_status_check_and_log(
-                       self.settings, phase, self.returncode)
index 8d137afe11e1256b1d1f4d01a68c1cea6c2c4389..bc70448d0d76bdaf4c2180dc30dfea00834f29fa 100644 (file)
@@ -4,8 +4,7 @@
 from _emerge.AbstractEbuildProcess import AbstractEbuildProcess
 import portage
 from portage import os
-from portage.package.ebuild.doebuild import spawn, \
-       _doebuild_exit_status_check_and_log
+from portage.package.ebuild.doebuild import spawn
 
 class MiscFunctionsProcess(AbstractEbuildProcess):
        """
@@ -31,9 +30,3 @@ class MiscFunctionsProcess(AbstractEbuildProcess):
                debug = settings.get("PORTAGE_DEBUG") == "1"
                return spawn(" ".join(args), settings,
                        debug=debug, **kwargs)
-
-       def _set_returncode(self, wait_retval):
-               AbstractEbuildProcess._set_returncode(self, wait_retval)
-               self.returncode = _doebuild_exit_status_check_and_log(
-                       self.settings, self.phase, self.returncode)
-
index 19997d7854d4ec75f7cd3f5221ba62125ba32c63..61eea40ee48a6ca0be6d71f840e198d909ba3fc6 100644 (file)
@@ -1173,7 +1173,7 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
                        mysettings["PORTAGE_SANDBOX_T"])
 
        phase = env.get('EBUILD_PHASE')
-       if phase not in ('clean', 'cleanrm', 'depend', 'help',):
+       if phase not in EbuildSpawnProcess._phases_without_builddir:
                # Don't try to unlink for phases that don't require
                # PORTAGE_BUILDDIR, since the directory may not
                # even belong to this process in that case.