EbuildFetchonly: remove redundant tmpdir code
authorZac Medico <zmedico@gentoo.org>
Fri, 22 Oct 2010 14:05:14 +0000 (07:05 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 22 Oct 2010 14:32:55 +0000 (07:32 -0700)
This tempdir stuff is handled by spawn_nofetch() now.

pym/_emerge/EbuildFetchonly.py

index 8e02c2a7797b8d36f83da31853a012fa290e0ddd..39a0b6fe2d727202e18c4a6c07ca45ca411d17db 100644 (file)
@@ -1,8 +1,7 @@
-# Copyright 1999-2009 Gentoo Foundation
+# Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from _emerge.SlotObject import SlotObject
-import shutil
 import portage
 from portage import os
 from portage.elog.messages import eerror
@@ -21,44 +20,17 @@ class EbuildFetchonly(SlotObject):
                settings.setcpv(pkg)
                debug = settings.get("PORTAGE_DEBUG") == "1"
 
-               if 'fetch' in pkg.metadata.restrict:
-                       rval = self._execute_with_builddir()
-               else:
-                       rval = portage.doebuild(ebuild_path, "fetch",
-                               settings["ROOT"], settings, debug=debug,
-                               listonly=self.pretend, fetchonly=1, fetchall=self.fetch_all,
-                               mydbapi=portdb, tree="porttree")
+               rval = portage.doebuild(ebuild_path, "fetch",
+                       settings["ROOT"], settings, debug=debug,
+                       listonly=self.pretend, fetchonly=1, fetchall=self.fetch_all,
+                       mydbapi=portdb, tree="porttree")
 
-                       if rval != os.EX_OK:
-                               msg = "Fetch failed for '%s'" % (pkg.cpv,)
-                               eerror(msg, phase="unpack", key=pkg.cpv)
+               if rval != os.EX_OK:
+                       msg = "Fetch failed for '%s'" % (pkg.cpv,)
+                       eerror(msg, phase="unpack", key=pkg.cpv)
 
                return rval
 
-       def _execute_with_builddir(self):
-               # To spawn pkg_nofetch requires PORTAGE_BUILDDIR for
-               # ensuring sane $PWD (bug #239560) and storing elog
-               # 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
-               try:
-                       private_tmpdir = mkdtemp("", "._portage_fetch_.", global_tmpdir)
-               except OSError as e:
-                       if e.errno != portage.exception.PermissionDenied.errno:
-                               raise
-                       raise portage.exception.PermissionDenied(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):
                settings = self.settings
                pkg = self.pkg