Make AbstractEbuildProcess lock PORTAGE_BUILDIR if it's not already
authorZac Medico <zmedico@gentoo.org>
Tue, 14 Sep 2010 05:49:03 +0000 (22:49 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 14 Sep 2010 05:49:03 +0000 (22:49 -0700)
locked.

pym/_emerge/AbstractEbuildProcess.py
pym/_emerge/EbuildBuildDir.py
pym/portage/package/ebuild/_config/special_env_vars.py

index ed20b14f92c61096bddd0edaee73f1c6ce05bb0c..7169dab58db65593c87b85ad2c4eb2b652aa459f 100644 (file)
@@ -4,6 +4,7 @@
 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
@@ -20,7 +21,7 @@ from portage.util import apply_secpass_permissions
 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
@@ -67,6 +68,11 @@ class AbstractEbuildProcess(SpawnProcess):
                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:
@@ -230,6 +236,9 @@ class AbstractEbuildProcess(SpawnProcess):
                        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):
index 1dc63c3b46588fbe0297fa35d5e581954c579236..af3ce0792c5625bad44c078b8cbdb2c871ef6bc7 100644 (file)
@@ -45,6 +45,7 @@ class EbuildBuildDir(SlotObject):
                        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()
@@ -70,6 +71,7 @@ class EbuildBuildDir(SlotObject):
                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
index 70db71b24b700668937da7b1a29bce5a8e62efbe..2eac17aace69c4088f2ca3b18167495573e1081b 100644 (file)
@@ -12,7 +12,7 @@ env_blacklist = frozenset((
        "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",