From: Zac Medico Date: Sat, 26 Mar 2011 07:06:01 +0000 (-0700) Subject: Reoranize PackageMerge/MergeListItem interaction. X-Git-Tag: v2.2.0_alpha29~13 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=dc6a4c122e827baf28729caf2dbb32576072d88f;p=portage.git Reoranize PackageMerge/MergeListItem interaction. --- diff --git a/pym/_emerge/AsynchronousTask.py b/pym/_emerge/AsynchronousTask.py index de0080042..2b654ec00 100644 --- a/pym/_emerge/AsynchronousTask.py +++ b/pym/_emerge/AsynchronousTask.py @@ -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 diff --git a/pym/_emerge/Binpkg.py b/pym/_emerge/Binpkg.py index 62d44c48f..bc6b85da2 100644 --- a/pym/_emerge/Binpkg.py +++ b/pym/_emerge/Binpkg.py @@ -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"]) diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py index c7a5f5cdb..1de8fbf50 100644 --- a/pym/_emerge/EbuildBuild.py +++ b/pym/_emerge/EbuildBuild.py @@ -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) - diff --git a/pym/_emerge/MergeListItem.py b/pym/_emerge/MergeListItem.py index 5170de1d5..124db1a18 100644 --- a/pym/_emerge/MergeListItem.py +++ b/pym/_emerge/MergeListItem.py @@ -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 diff --git a/pym/_emerge/PackageMerge.py b/pym/_emerge/PackageMerge.py index 832eac03b..f8fa04a38 100644 --- a/pym/_emerge/PackageMerge.py +++ b/pym/_emerge/PackageMerge.py @@ -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)