Bug #245231 - Make EbuildFetchPretend use a private temp directory in order
authorZac Medico <zmedico@gentoo.org>
Sun, 2 Nov 2008 09:05:31 +0000 (09:05 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 2 Nov 2008 09:05:31 +0000 (09:05 -0000)
to avoid locking the main one.

svn path=/main/trunk/; revision=11796

pym/_emerge/__init__.py

index 52686e5171e6fa9059df496827dc0b726fea3881..5c5eecbe6766bf36d0cf556a5ba7b719d990760d 100644 (file)
@@ -1590,7 +1590,23 @@ class EbuildFetchPretend(SlotObject):
        def execute(self):
                # To spawn pkg_nofetch requires PORTAGE_BUILDDIR for
                # ensuring sane $PWD (bug #239560) and storing elog
-               # messages.
+               # messages. Use a private temp directory, in order
+               # to avoid locking the main one.
+               settings = self.settings
+               global_tmpdir = settings["PORTAGE_TMPDIR"]
+               from tempfile import mkdtemp
+               private_tmpdir = mkdtemp("", "._portage_fetch_.", global_tmpdir)
+               settings["PORTAGE_TMPDIR"] = private_tmpdir
+               settings.backup_changes("PORTAGE_TMPDIR")
+               try:
+                       retval = self._execute()
+               finally:
+                       settings["PORTAGE_TMPDIR"] = global_tmpdir
+                       settings.backup_changes("PORTAGE_TMPDIR")
+                       shutil.rmtree(private_tmpdir)
+               return retval
+
+       def _execute(self):
                build_dir = EbuildBuildDir(pkg=self.pkg, settings=self.settings)
                build_dir.lock()
                build_dir.clean()
@@ -2367,7 +2383,7 @@ class EbuildBuildDir(SlotObject):
                self._catdir = catdir
 
                portage.util.ensure_dirs(os.path.dirname(catdir),
-                       uid=portage.portage_uid, gid=portage.portage_gid,
+                       gid=portage.portage_gid,
                        mode=070, mask=0)
                catdir_lock = None
                try: