Bug #233296 - Add minimal PROPERTIES=interactive support by simply forcing
authorZac Medico <zmedico@gentoo.org>
Tue, 21 Oct 2008 23:24:31 +0000 (23:24 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 21 Oct 2008 23:24:31 +0000 (23:24 -0000)
all package output to stdio whenever the merge list contains one or more
interactive packages.

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

pym/_emerge/__init__.py

index 43b4fb1b9053c50037000e470d5e00abfd5e5985..d34e2722aecac7e45722662a320f48b41fdeaa1c 100644 (file)
@@ -9196,6 +9196,28 @@ class Scheduler(PollScheduler):
                        self._max_jobs > 1 or "--quiet" in self.myopts) and \
                        not bool(self._opts_no_background.intersection(self.myopts))
 
+               if background:
+                       interactive_tasks = self._get_interactive_tasks()
+                       if interactive_tasks:
+                               background = False
+                               writemsg_level(">>> Sending package output to stdio due " + \
+                                       "to interactive package(s):\n",
+                                       level=logging.INFO, noiselevel=-1)
+                               msg = [""]
+                               for pkg in interactive_tasks:
+                                       pkg_str = "  " + colorize("INFORM", str(pkg.cpv))
+                                       if pkg.root != "/":
+                                               pkg_str += " for " + pkg.root
+                                       msg.append(pkg_str)
+                               msg.append("")
+                               writemsg_level("".join("%s\n" % (l,) for l in msg),
+                                       level=logging.INFO, noiselevel=-1)
+                               if self._max_jobs is True or self._max_jobs > 1:
+                                       self._set_max_jobs(1)
+                                       writemsg_level(">>> Setting --jobs=1 due " + \
+                                               "to the above interactive package(s)\n",
+                                               level=logging.INFO, noiselevel=-1)
+
                self._status_display.quiet = \
                        not background or \
                        ("--quiet" in self.myopts and \
@@ -9207,6 +9229,20 @@ class Scheduler(PollScheduler):
 
                return background
 
+       def _get_interactive_tasks(self):
+               from portage import flatten
+               from portage.dep import use_reduce, paren_reduce
+               interactive_tasks = []
+               for task in self._mergelist:
+                       if not (isinstance(task, Package) and \
+                               task.operation == "merge"):
+                               continue
+                       properties = flatten(use_reduce(paren_reduce(
+                               task.metadata["PROPERTIES"]), uselist=task.use.enabled))
+                       if "interactive" in properties:
+                               interactive_tasks.append(task)
+               return interactive_tasks
+
        def _set_digraph(self, digraph):
                if self._max_jobs is not True and \
                        self._max_jobs < 2: