MergeProcess: Fix PORTAGE_BACKGROUND/LOG_FILE use
authorZac Medico <zmedico@gentoo.org>
Fri, 25 Mar 2011 04:32:38 +0000 (21:32 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 25 Mar 2011 04:32:38 +0000 (21:32 -0700)
In this subprocess we don't want PORTAGE_BACKGROUND to suppress
stdout/stderr output since they are pipes. We also don't want to open
PORTAGE_LOG_FILE, since it will already be opened by the parent
process, so we set the PORTAGE_BACKGROUND="subprocess" value for use
in conditional logging code involving PORTAGE_LOG_FILE.

pym/_emerge/AbstractEbuildProcess.py
pym/_emerge/EbuildPhase.py
pym/_emerge/MiscFunctionsProcess.py
pym/portage/dbapi/_MergeProcess.py

index d7f31be288352b74a8387672609ecad7e98b5270..39c613bfe246eb73676cc1bf5db7267c6897df96 100644 (file)
@@ -225,8 +225,10 @@ class AbstractEbuildProcess(SpawnProcess):
                msg = _unicode_decode(out.getvalue(),
                        encoding=_encodings['content'], errors='replace')
                if msg:
-                       self.scheduler.output(msg,
-                               log_path=self.settings.get("PORTAGE_LOG_FILE"))
+                       log_path = None
+                       if self.settings.get("PORTAGE_BACKGROUND") != "subprocess":
+                               log_path = self.settings.get("PORTAGE_LOG_FILE")
+                       self.scheduler.output(msg, log_path=log_path)
 
        def _log_poll_exception(self, event):
                self._elog("eerror",
index e3270c893f1cdfc6dcb472099b064f2a9a7a0db2..a24608b8863b9b5034b3a5cfd948ebc1e8177016 100644 (file)
@@ -121,9 +121,10 @@ class EbuildPhase(CompositeTask):
                # Don't open the log file during the clean phase since the
                # open file can result in an nfs lock on $T/build.log which
                # prevents the clean phase from removing $T.
-               logfile = self.settings.get("PORTAGE_LOG_FILE")
-               if self.phase in ("clean", "cleanrm"):
-                       logfile = None
+               logfile = None
+               if self.phase not in ("clean", "cleanrm") and \
+                       self.settings.get("PORTAGE_BACKGROUND") != "subprocess":
+                       logfile = self.settings.get("PORTAGE_LOG_FILE")
 
                fd_pipes = None
                if not self.background and self.phase == 'nofetch':
@@ -151,13 +152,16 @@ class EbuildPhase(CompositeTask):
                if not fail:
                        self.returncode = None
 
+               logfile = None
+               if self.settings.get("PORTAGE_BACKGROUND") != "subprocess":
+                       logfile = self.settings.get("PORTAGE_LOG_FILE")
+
                if self.phase == "install":
                        out = portage.StringIO()
                        _check_build_log(self.settings, out=out)
                        msg = _unicode_decode(out.getvalue(),
                                encoding=_encodings['content'], errors='replace')
-                       self.scheduler.output(msg,
-                               log_path=self.settings.get("PORTAGE_LOG_FILE"))
+                       self.scheduler.output(msg, log_path=logfile)
 
                if fail:
                        self._die_hooks()
@@ -173,12 +177,10 @@ class EbuildPhase(CompositeTask):
                        msg = _unicode_decode(out.getvalue(),
                                encoding=_encodings['content'], errors='replace')
                        if msg:
-                               self.scheduler.output(msg,
-                                       log_path=self.settings.get("PORTAGE_LOG_FILE"))
+                               self.scheduler.output(msg, log_path=logfile)
 
                post_phase_cmds = _post_phase_cmds.get(self.phase)
                if post_phase_cmds is not None:
-                       logfile = settings.get("PORTAGE_LOG_FILE")
                        if logfile is not None and self.phase in ("install",):
                                # Log to a temporary file, since the code we are running
                                # reads PORTAGE_LOG_FILE for QA checks, and we want to
@@ -204,7 +206,10 @@ class EbuildPhase(CompositeTask):
 
                self._assert_current(post_phase)
 
-               log_path = self.settings.get("PORTAGE_LOG_FILE")
+               log_path = None
+               if self.settings.get("PORTAGE_BACKGROUND") != "subprocess":
+                       log_path = self.settings.get("PORTAGE_LOG_FILE")
+
                if post_phase.logfile is not None and \
                        post_phase.logfile != log_path:
                        # We were logging to a temp file (see above), so append
@@ -293,5 +298,7 @@ class EbuildPhase(CompositeTask):
                msg = _unicode_decode(out.getvalue(),
                        encoding=_encodings['content'], errors='replace')
                if msg:
-                       self.scheduler.output(msg,
-                               log_path=self.settings.get("PORTAGE_LOG_FILE"))
+                       log_path = None
+                       if self.settings.get("PORTAGE_BACKGROUND") != "subprocess":
+                               log_path = self.settings.get("PORTAGE_LOG_FILE")
+                       self.scheduler.output(msg, log_path=log_path)
index ad8cefcfd69b27102accb60ba7d585791405f257..e6bb103d8ef3e9ec413b463b3afbe6560ca3cc24 100644 (file)
@@ -22,7 +22,8 @@ class MiscFunctionsProcess(AbstractEbuildProcess):
                        os.path.basename(portage.const.MISC_SH_BINARY))
 
                self.args = [portage._shell_quote(misc_sh_binary)] + self.commands
-               if self.logfile is None:
+               if self.logfile is None and \
+                       self.settings.get("PORTAGE_BACKGROUND") != "subprocess":
                        self.logfile = settings.get("PORTAGE_LOG_FILE")
 
                AbstractEbuildProcess._start(self)
index 6e63f84fda3c78d4eec64b5820d17b3878478781..a8c3c9dc7a7993e2e89499a6d24d91c8b4e392a3 100644 (file)
@@ -85,6 +85,15 @@ class MergeProcess(SpawnProcess):
                # is triggered when mylink._scheduler is None.
                mylink._scheduler = None
 
+               # In this subprocess we don't want PORTAGE_BACKGROUND to
+               # suppress stdout/stderr output since they are pipes. We
+               # also don't want to open PORTAGE_LOG_FILE, since it will
+               # already be opened by the parent process, so we set the
+               # "subprocess" value for use in conditional logging code
+               # involving PORTAGE_LOG_FILE.
+               self.settings["PORTAGE_BACKGROUND"] = "subprocess"
+               self.settings.backup_changes("PORTAGE_BACKGROUND")
+
                rval = 1
                try:
                        rval = mylink.merge(self.pkgloc, self.infloc,