Bug #247370 - Use a private PORTAGE_TMPDIR for --fetchonly mode in order
authorZac Medico <zmedico@gentoo.org>
Thu, 20 Nov 2008 02:39:15 +0000 (02:39 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 20 Nov 2008 02:39:15 +0000 (02:39 -0000)
do avoid locking the normal build dir location (similar to bug #245231).
The EbuildFetchPretend class is renamed to EbuildFetchonly and it's used
for --fetchonly mode regardless of whether --pretend is enabled. Also,
fix stdout/stderr flushing in JobStatusDisplay.displayMessage() and
portage.spawn() to ensure output always occurs in the correct order when
displaying pkg_nofetch() output in --fetchonly mode.

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

pym/_emerge/__init__.py
pym/portage/__init__.py

index f44d6eb676a2a6ceb34c4ff5c36243d17b7b4cb4..f3f704754d2437ed9d5f572ec6e5259976a4a904 100644 (file)
@@ -1583,9 +1583,9 @@ class _PackageMetadataWrapper(_PackageMetadataWrapperBase):
                                v = 0
                self._pkg.mtime = v
 
-class EbuildFetchPretend(SlotObject):
+class EbuildFetchonly(SlotObject):
 
-       __slots__ = ("fetch_all", "pkg", "settings")
+       __slots__ = ("fetch_all", "pkg", "pretend", "settings")
 
        def execute(self):
                # To spawn pkg_nofetch requires PORTAGE_BUILDDIR for
@@ -1621,9 +1621,13 @@ class EbuildFetchPretend(SlotObject):
 
                retval = portage.doebuild(ebuild_path, "fetch",
                        self.settings["ROOT"], self.settings, debug=debug,
-                       listonly=1, fetchonly=1, fetchall=self.fetch_all,
+                       listonly=self.pretend, fetchonly=1, fetchall=self.fetch_all,
                        mydbapi=portdb, tree="porttree")
 
+               if retval != os.EX_OK:
+                       msg = "Fetch failed for '%s'" % (pkg.cpv,)
+                       eerror(msg, phase="unpack", key=pkg.cpv)
+
                portage.elog.elog_process(self.pkg.cpv, self.settings)
                return retval
 
@@ -2493,10 +2497,11 @@ class EbuildBuild(CompositeTask):
                pkg = self.pkg
                settings = self.settings
 
-               if opts.fetchonly and opts.pretend:
-                               fetcher = EbuildFetchPretend(
+               if opts.fetchonly:
+                               fetcher = EbuildFetchonly(
                                        fetch_all=opts.fetch_all_uri,
-                                       pkg=pkg, settings=settings)
+                                       pkg=pkg, pretend=opts.pretend,
+                                       settings=settings)
                                retval = fetcher.execute()
                                self.returncode = retval
                                self.wait()
@@ -8916,6 +8921,7 @@ class JobStatusDisplay(object):
                        self._erase()
 
                self.out.write(self._format_msg(msg) + self._term_codes['newline'])
+               self.out.flush()
                self._displayed = False
 
                if was_displayed:
index 91f5486d66f601a6f5802752d705ed7f3b6604bb..d53ac9b254e07da8b2fd6740dee11bbc5b3d4a17 100644 (file)
@@ -3056,11 +3056,12 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
        # In some cases the above print statements don't flush stdout, so
        # it needs to be flushed before allowing a child process to use it
        # so that output always shows in the correct order.
+       stdout_filenos = (sys.stdout.fileno(), sys.stderr.fileno())
        for fd in fd_pipes.itervalues():
-               if fd == sys.stdout.fileno():
+               if fd in stdout_filenos:
                        sys.stdout.flush()
-               if fd == sys.stderr.fileno():
                        sys.stderr.flush()
+                       break
 
        # The default policy for the sesandbox domain only allows entry (via exec)
        # from shells and from binaries that belong to portage (the number of entry