parallel_emerge: Save install plan use newlines

Switch parallel_emerge to save install plan filenames with newline
separator instead of spaces to make readarray work correctly.

BUG=b:75396373
TEST=local builds and tryjobs

Change-Id: Ifef0ff4fa475bb417d19aea701bfd89522dd50f9
Reviewed-on: https://chromium-review.googlesource.com/1035425
Commit-Ready: Gregory Meinke <gmeinke@chromium.org>
Tested-by: Gregory Meinke <gmeinke@chromium.org>
Reviewed-by: Jason Clinton <jclinton@chromium.org>
diff --git a/scripts/parallel_emerge.py b/scripts/parallel_emerge.py
index a70d320..effa074 100644
--- a/scripts/parallel_emerge.py
+++ b/scripts/parallel_emerge.py
@@ -40,6 +40,7 @@
 
 from chromite.lib import cros_build_lib
 from chromite.lib import cros_event
+from chromite.lib import osutils
 from chromite.lib import portage_util
 from chromite.lib import process_util
 from chromite.lib import proctitle
@@ -548,13 +549,14 @@
     # Calculate the install plan packages and append to temp file. They will be
     # used to calculate all the reverse dependencies on these change packages.
     if self.install_plan_filename:
-      install_plan_pkgs = []
-      for d in deps_info:
-        install_plan_pkgs.append(d)
-      # always write the file even if nothing to do, scripts expect existence.
-      with open(self.install_plan_filename, "a") as f:
-        f.write("%s " % " ".join(install_plan_pkgs))
-
+      # Always write the file even if nothing to do, scripts expect existence.
+      output = '\n'.join(deps_info)
+      if len(output) > 0:
+        # add a trailing newline only if the output is not empty.
+        output += '\n'
+      osutils.WriteFile(self.install_plan_filename,
+                        output,
+                        mode='a')
     return deps_tree, deps_info
 
   def PrintTree(self, deps, depth=""):