In EbuildFetchonly.execute(), skip builddir creation when the ebuild does
authorZac Medico <zmedico@gentoo.org>
Sun, 22 Feb 2009 22:24:08 +0000 (22:24 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 22 Feb 2009 22:24:08 +0000 (22:24 -0000)
not set RESTRICT=fetch (since it's not possible for pkg_nofetch to be executed
in this case).

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

pym/_emerge/__init__.py

index 80f0372f8aa912e7d18e6c115d85a15e9ad6eaff..9120e71b5c8b8399972cd419ec81f769666cf092 100644 (file)
@@ -1683,6 +1683,32 @@ class EbuildFetchonly(SlotObject):
        __slots__ = ("fetch_all", "pkg", "pretend", "settings")
 
        def execute(self):
+               settings = self.settings
+               pkg = self.pkg
+               portdb = pkg.root_config.trees["porttree"].dbapi
+               ebuild_path = portdb.findname(pkg.cpv)
+               settings.setcpv(pkg)
+               debug = settings.get("PORTAGE_DEBUG") == "1"
+               use_cache = 1 # always true
+               portage.doebuild_environment(ebuild_path, "fetch",
+                       settings["ROOT"], settings, debug, use_cache, portdb)
+               restrict_fetch = 'fetch' in settings['PORTAGE_RESTRICT'].split()
+
+               if restrict_fetch:
+                       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")
+
+                       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
@@ -1712,11 +1738,7 @@ class EbuildFetchonly(SlotObject):
                root_config = pkg.root_config
                portdb = root_config.trees["porttree"].dbapi
                ebuild_path = portdb.findname(pkg.cpv)
-               settings.setcpv(pkg)
                debug = settings.get("PORTAGE_DEBUG") == "1"
-               use_cache = 1 # always true
-               portage.doebuild_environment(ebuild_path, "fetch",
-                       root_config.root, settings, debug, use_cache, portdb)
                portage.prepare_build_dirs(self.pkg.root, self.settings, 0)
 
                retval = portage.doebuild(ebuild_path, "fetch",