Use the EbuildPhase class to execute the "clean" phase asynchronously.
authorZac Medico <zmedico@gentoo.org>
Sat, 5 Jul 2008 08:08:09 +0000 (08:08 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 5 Jul 2008 08:08:09 +0000 (08:08 -0000)
svn path=/main/trunk/; revision=10938

pym/_emerge/__init__.py
pym/portage/__init__.py

index c6d07d6f7e603a60aa1eccc7585f4c429d4e2a9c..b5169ceffb7873e92049f6cbbbb616d3258315e6 100644 (file)
@@ -1863,6 +1863,8 @@ class EbuildExecuter(SlotObject):
        _phases = ("setup", "unpack", "compile", "test", "install")
 
        def execute(self):
+               pkg = self.pkg
+               scheduler = self.scheduler
                root_config = self.pkg.root_config
                tree = "porttree"
                portdb = root_config.trees[tree].dbapi
@@ -1871,9 +1873,15 @@ class EbuildExecuter(SlotObject):
                debug = settings.get("PORTAGE_DEBUG") == "1"
                cleanup = 1
 
-               retval = portage.doebuild(ebuild_path, "clean",
-                       root_config.root, settings, debug, cleanup=cleanup,
-                       mydbapi=portdb, tree="porttree")
+               phase = "clean"
+               ebuild_phase = EbuildPhase(
+                       pkg=pkg, phase=phase, scheduler=scheduler,
+                       settings=settings, tree=tree)
+
+               ebuild_phase.start()
+               scheduler.schedule(ebuild_phase.reg_id)
+               retval = ebuild_phase.wait()
+
                if retval != os.EX_OK:
                        return retval
 
@@ -1925,7 +1933,15 @@ class EbuildPhase(SubProcess):
                logfile = settings.get("PORTAGE_LOG_FILE")
                master_fd = None
                slave_fd = None
-               fd_pipes = self.fd_pipes.copy()
+               fd_pipes = None
+               if self.fd_pipes is not None:
+                       fd_pipes = self.fd_pipes.copy()
+               else:
+                       fd_pipes = {}
+
+               fd_pipes.setdefault(0, sys.stdin.fileno())
+               fd_pipes.setdefault(1, sys.stdout.fileno())
+               fd_pipes.setdefault(2, sys.stderr.fileno())
 
                # flush any pending output
                for fd in fd_pipes.itervalues():
@@ -1984,9 +2000,6 @@ class EbuildPhase(SubProcess):
                        master_fd, slave_fd = os.pipe()
                        fcntl.fcntl(master_fd, fcntl.F_SETFL,
                                fcntl.fcntl(master_fd, fcntl.F_GETFL) | os.O_NONBLOCK)
-                       fd_pipes.setdefault(0, sys.stdin.fileno())
-                       fd_pipes.setdefault(1, sys.stdout.fileno())
-                       fd_pipes.setdefault(2, sys.stderr.fileno())
                        fd_pipes[self._dummy_pipe_fd] = slave_fd
 
                retval = portage.doebuild(ebuild_path, self.phase,
@@ -2051,14 +2064,15 @@ class EbuildPhase(SubProcess):
 
        def _set_returncode(self, wait_retval):
                SubProcess._set_returncode(self, wait_retval)
-               msg = portage._doebuild_exit_status_check(
-                       self.phase, self.settings)
-               if msg:
-                       self.returncode = 1
-                       from textwrap import wrap
-                       from portage.elog.messages import eerror
-                       for l in wrap(msg, 72):
-                               eerror(l, phase=self.phase, key=self.pkg.cpv)
+               if self.phase != "clean":
+                       msg = portage._doebuild_exit_status_check(
+                               self.phase, self.settings)
+                       if msg:
+                               self.returncode = 1
+                               from textwrap import wrap
+                               from portage.elog.messages import eerror
+                               for l in wrap(msg, 72):
+                                       eerror(l, phase=self.phase, key=self.pkg.cpv)
 
                returncode = self.returncode
                settings = self.settings
@@ -2286,9 +2300,15 @@ class Binpkg(EbuildBuildDir):
                        cleanup = 1
                        mydbapi = root_config.trees[tree].dbapi
 
-                       retval = portage.doebuild(ebuild_path, "clean",
-                               root_config.root, settings, debug, cleanup=cleanup,
-                               mydbapi=mydbapi, tree=tree)
+                       phase = "clean"
+                       ebuild_phase = EbuildPhase(fd_pipes=fd_pipes,
+                               pkg=pkg, phase=phase, scheduler=scheduler,
+                               settings=settings, tree=tree)
+
+                       ebuild_phase.start()
+                       scheduler.schedule(ebuild_phase.reg_id)
+                       retval = ebuild_phase.wait()
+
                        if retval != os.EX_OK:
                                return retval
 
index abba1f39ece44a1e85460930cd9a43444b4e5f22..ca3de8c2c8402813b891d329d9f32be7586cb79d 100644 (file)
@@ -5003,7 +5003,8 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
 
                if mydo in clean_phases:
                        retval = spawn(_shell_quote(ebuild_sh_binary) + " clean",
-                               mysettings, debug=debug, free=1, logfile=None)
+                               mysettings, debug=debug, fd_pipes=fd_pipes, free=1,
+                               logfile=None, returnpid=returnpid)
                        return retval
 
                # get possible slot information from the deps file