# 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):
"""
self._start()
def _start(self):
- raise NotImplementedError(self)
+ self.returncode = os.EX_OK
+ self.wait()
def isAlive(self):
return self.returncode is None
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.
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"])
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
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)
-
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
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
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
# 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
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)