import stat
import textwrap
from _emerge.SpawnProcess import SpawnProcess
+from _emerge.EbuildBuildDir import EbuildBuildDir
from _emerge.EbuildIpcDaemon import EbuildIpcDaemon
import portage
from portage.elog import messages as elog_messages
class AbstractEbuildProcess(SpawnProcess):
__slots__ = ('phase', 'settings',) + \
- ('_ipc_daemon', '_exit_command',)
+ ('_build_dir', '_ipc_daemon', '_exit_command',)
_phases_without_builddir = ('clean', 'cleanrm', 'depend', 'help',)
# Number of milliseconds to allow natural exit of the ebuild
if self._enable_ipc_daemon:
self.settings.pop('PORTAGE_EBUILD_EXIT_FILE', None)
if self.phase not in self._phases_without_builddir:
+ if 'PORTAGE_BUILDIR_LOCKED' not in self.settings:
+ self._build_dir = EbuildBuildDir(
+ dir_path=self.settings['PORTAGE_BUILDDIR'],
+ scheduler=self.scheduler, settings=self.settings)
+ self._build_dir.lock()
self.settings['PORTAGE_IPC_DAEMON'] = "1"
self._start_ipc_daemon()
else:
else:
self.returncode = 1
self._unexpected_exit()
+ if self._build_dir is not None:
+ self._build_dir.unlock()
+ self._build_dir = None
else:
exit_file = self.settings.get('PORTAGE_EBUILD_EXIT_FILE')
if exit_file and not os.path.exists(exit_file):
builddir_lock.start()
builddir_lock.wait()
self._lock_obj = builddir_lock.lock_obj
+ self.settings['PORTAGE_BUILDIR_LOCKED'] = '1'
finally:
self.locked = self._lock_obj is not None
catdir_lock.unlock()
portage.locks.unlockdir(self._lock_obj)
self._lock_obj = None
self.locked = False
+ self.settings.pop('PORTAGE_BUILDIR_LOCKED', None)
catdir = self._catdir
catdir_lock = None
"A", "AA", "CATEGORY", "DEPEND", "DESCRIPTION", "EAPI",
"EBUILD_PHASE", "ED", "EMERGE_FROM", "EPREFIX", "EROOT",
"HOMEPAGE", "INHERITED", "IUSE",
- "KEYWORDS", "LICENSE", "PDEPEND", "PF", "PKGUSE",
+ "KEYWORDS", "LICENSE", "PDEPEND", "PF", "PKGUSE", "PORTAGE_BUILDIR_LOCKED",
"PORTAGE_BUILT_USE", "PORTAGE_CONFIGROOT", "PORTAGE_IUSE",
"PORTAGE_NONFATAL", "PORTAGE_REPO_NAME", "PORTAGE_SANDBOX_COMPAT_LEVEL",
"PORTAGE_USE", "PROPERTIES", "PROVIDE", "RDEPEND", "RESTRICT",