class EbuildFetcher(SpawnProcess):
- __slots__ = ("fetchonly", "fetchall", "pkg",)
+ __slots__ = ("config_pool", "fetchonly", "fetchall", "pkg",) + \
+ ("_build_dir",)
def _start(self):
root_config = self.pkg.root_config
portdb = root_config.trees["porttree"].dbapi
ebuild_path = portdb.findname(self.pkg.cpv)
- settings = root_config.settings
+ settings = self.config_pool.allocate()
+ self._build_dir = EbuildBuildDir(pkg=self.pkg, settings=settings)
+ self._build_dir.lock()
phase = "fetch"
if self.fetchall:
phase = "fetchall"
self.env = fetch_env
SpawnProcess._start(self)
+ def _wait_hook(self):
+ # Collect elog messages that might have been
+ # created by the pkg_nofetch phase.
+ portage.elog.elog_process(self.pkg.cpv, self._build_dir.settings)
+ try:
+ shutil.rmtree(self._build_dir.settings["PORTAGE_BUILDDIR"])
+ except EnvironmentError, e:
+ if e.errno != errno.ENOENT:
+ raise
+ del e
+ self._build_dir.unlock()
+ self.config_pool.deallocate(self._build_dir.settings)
+ self._build_dir = None
+ SpawnProcess._wait_hook(self)
+
class EbuildBuildDir(SlotObject):
__slots__ = ("dir_path", "pkg", "settings",
portdb = root_config.trees["porttree"].dbapi
ebuild_path = portdb.findname(self.pkg.cpv)
settings = self.settings
+ settings.setcpv(self.pkg)
debug = settings.get("PORTAGE_DEBUG") == "1"
use_cache = 1 # always true
portage.doebuild_environment(ebuild_path, "setup", root_config.root,
class EbuildBuild(CompositeTask):
- __slots__ = ("args_set", "background", "find_blockers",
+ __slots__ = ("args_set", "config_pool", "find_blockers",
"ldpath_mtimes", "logger", "opts", "pkg", "pkg_count",
"prefetcher", "settings", "world_atom") + \
("_build_dir", "_buildpkg", "_ebuild_path", "_issyspkg", "_tree")
if self.background:
fetch_log = self.scheduler.fetch.log_file
- fetcher = EbuildFetcher(fetchall=opts.fetch_all_uri,
+ fetcher = EbuildFetcher(config_pool=self.config_pool,
+ fetchall=opts.fetch_all_uri,
fetchonly=opts.fetchonly,
background=self.background, logfile=fetch_log,
pkg=pkg, scheduler=self.scheduler)
"""
__slots__ = ("args_set",
- "binpkg_opts", "build_opts", "emerge_opts",
+ "binpkg_opts", "build_opts", "config_pool", "emerge_opts",
"failed_fetches", "find_blockers", "logger", "mtimedb", "pkg",
"pkg_count", "pkg_to_replace", "prefetcher",
"settings", "statusMessage", "world_atom") + \
build = EbuildBuild(args_set=args_set,
background=self.background,
+ config_pool=self.config_pool,
find_blockers=find_blockers,
ldpath_mtimes=ldpath_mtimes, logger=logger,
opts=build_opts, pkg=pkg, pkg_count=pkg_count,
__slots__ = ("build_dir", "build_log",
"fetch_log", "pkg", "returncode")
+ class _ConfigPool(object):
+ """Interface for a task to temporarily allocate a config
+ instance from a pool. This allows a task to be constructed
+ long before the config instance actually becomes needed, like
+ when prefetchers are constructed for the whole merge list."""
+ __slots__ = ("_root", "_allocate", "_deallocate")
+ def __init__(self, root, allocate, deallocate):
+ self._root = root
+ self._allocate = allocate
+ self._deallocate = deallocate
+ def allocate(self):
+ return self._allocate(self._root)
+ def deallocate(self, settings):
+ self._deallocate(settings)
+
def __init__(self, settings, trees, mtimedb, myopts,
spinner, mergelist, favorites, digraph):
PollScheduler.__init__(self)
elif pkg.type_name == "ebuild":
prefetcher = EbuildFetcher(background=True,
+ config_pool=self._ConfigPool(pkg.root,
+ self._allocate_config, self._deallocate_config),
fetchonly=1, logfile=self._fetch_log,
pkg=pkg, scheduler=self._sched_iface)
task = MergeListItem(args_set=self._args_set,
background=self._background, binpkg_opts=self._binpkg_opts,
build_opts=self._build_opts,
+ config_pool=self._ConfigPool(pkg.root,
+ self._allocate_config, self._deallocate_config),
emerge_opts=self.myopts,
failed_fetches=self._failed_fetches,
find_blockers=self._find_blockers(pkg), logger=self._logger,