Reoranize PackageMerge/MergeListItem interaction.
authorZac Medico <zmedico@gentoo.org>
Sat, 26 Mar 2011 07:06:01 +0000 (00:06 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 26 Mar 2011 07:06:01 +0000 (00:06 -0700)
pym/_emerge/AsynchronousTask.py
pym/_emerge/Binpkg.py
pym/_emerge/EbuildBuild.py
pym/_emerge/MergeListItem.py
pym/_emerge/PackageMerge.py

index de0080042a9f19bd424b3886267807e3e082d308..2b654ec00f251e1ddb9bb509a20349f58d660860 100644 (file)
@@ -1,6 +1,7 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+from portage import os
 from _emerge.SlotObject import SlotObject
 class AsynchronousTask(SlotObject):
        """
@@ -23,7 +24,8 @@ class AsynchronousTask(SlotObject):
                self._start()
 
        def _start(self):
-               raise NotImplementedError(self)
+               self.returncode = os.EX_OK
+               self.wait()
 
        def isAlive(self):
                return self.returncode is None
index 62d44c48f575c2f28c448a48973963565189d286..bc6b85da238a96dcebe9681fc6262e8f3ca9f241 100644 (file)
@@ -307,7 +307,7 @@ class Binpkg(CompositeTask):
                portage.elog.elog_process(self.pkg.cpv, self.settings)
                self._build_dir.unlock()
 
-       def install(self, handler):
+       def create_install_task(self):
 
                # This gives bashrc users an opportunity to do various things
                # such as remove binary packages after they're installed.
@@ -322,16 +322,13 @@ class Binpkg(CompositeTask):
                        settings=settings, tree=self._tree, world_atom=self.world_atom)
                task = merge.create_task()
                task.addExitListener(self._install_exit)
-               self._start_task(task, handler)
+               return task
 
        def _install_exit(self, task):
                self.settings.pop("PORTAGE_BINPKG_FILE", None)
                self._unlock_builddir()
-
-               if self._default_final_exit(task) != os.EX_OK:
-                       return
-
-               if 'binpkg-logs' not in self.settings.features and \
+               if task.returncode == os.EX_OK and \
+                       'binpkg-logs' not in self.settings.features and \
                        self.settings.get("PORTAGE_LOG_FILE"):
                        try:
                                os.unlink(self.settings["PORTAGE_LOG_FILE"])
index c7a5f5cdb7b1739d75e316c5e9e3ecc61358af52..1de8fbf504bf15fc6be7b83a871d27b8df6d2dd8 100644 (file)
@@ -314,7 +314,7 @@ class EbuildBuild(CompositeTask):
                        self._unlock_builddir()
                self.wait()
 
-       def install(self, exit_handler):
+       def create_install_task(self):
                """
                Install the package and then clean up and release locks.
                Only call this after the build has completed successfully
@@ -345,9 +345,7 @@ class EbuildBuild(CompositeTask):
 
                task = merge.create_task()
                task.addExitListener(self._install_exit)
-               self._start_task(task, exit_handler)
+               return task
 
        def _install_exit(self, task):
                self._unlock_builddir()
-               self._default_final_exit(task)
-
index 5170de1d5e295af922f5ce39b602fa2e5aea6843..124db1a18039743ef4bc86da838a3989ca27852a 100644 (file)
@@ -4,6 +4,7 @@
 from portage import os
 from portage.output import colorize
 
+from _emerge.AsynchronousTask import AsynchronousTask
 from _emerge.Binpkg import Binpkg
 from _emerge.CompositeTask import CompositeTask
 from _emerge.EbuildBuild import EbuildBuild
@@ -111,15 +112,11 @@ class MergeListItem(CompositeTask):
                self._install_task.wait()
                return self.returncode
 
-       def merge(self, exit_handler):
+       def create_install_task(self):
 
                pkg = self.pkg
                build_opts = self.build_opts
-               find_blockers = self.find_blockers
-               logger = self.logger
                mtimedb = self.mtimedb
-               pkg_count = self.pkg_count
-               prefetcher = self.prefetcher
                scheduler = self.scheduler
                settings = self.settings
                world_atom = self.world_atom
@@ -129,20 +126,18 @@ class MergeListItem(CompositeTask):
                        if not (build_opts.buildpkgonly or \
                                build_opts.fetchonly or build_opts.pretend):
 
-                               uninstall = PackageUninstall(background=self.background,
+                               task = PackageUninstall(background=self.background,
                                        ldpath_mtimes=ldpath_mtimes, opts=self.emerge_opts,
                                        pkg=pkg, scheduler=scheduler, settings=settings,
                                        world_atom=world_atom)
 
-                               uninstall.start()
-                               self.returncode = uninstall.wait()
                        else:
-                               self.returncode = os.EX_OK
-                       exit_handler(self)
+                               task = AsynchronousTask()
+
                elif build_opts.fetchonly or \
                        build_opts.buildpkgonly:
-                       exit_handler(self)
+                       task = AsynchronousTask()
                else:
-                       self._current_task = self._install_task
-                       self._install_task.install(exit_handler)
+                       task = self._install_task.create_install_task()
 
+               return task
index 832eac03b21d5f922f4104d9c4229d7737aa7291..f8fa04a389ea3fd360150a82a01f72409ab66509 100644 (file)
@@ -1,13 +1,14 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-from _emerge.AsynchronousTask import AsynchronousTask
+from _emerge.CompositeTask import CompositeTask
 from portage.output import colorize
-class PackageMerge(AsynchronousTask):
+class PackageMerge(CompositeTask):
        __slots__ = ("merge",)
 
        def _start(self):
 
+               self.scheduler = self.merge.scheduler
                pkg = self.merge.pkg
                pkg_count = self.merge.pkg_count
 
@@ -35,8 +36,5 @@ class PackageMerge(AsynchronousTask):
                        not self.merge.build_opts.buildpkgonly:
                        self.merge.statusMessage(msg)
 
-               self.merge.merge(self.exit_handler)
-
-       def exit_handler(self, task):
-               self.returncode = task.returncode
-               self.wait()
+               task = self.merge.create_install_task()
+               self._start_task(task, self._default_final_exit)