Run a dummy command in ChrootRunCommand to create a chroot if needed.
In ChrootRunCommand, if return_output is set, run a dummy command first to
make sure the chroot exists before running the actual command whose output
is desired.
BUG=chromium:429823
TEST=Ran build_tc.py with freshly setup chromeos sources without a chroot.
Change-Id: Icdd954671e172066f8fb3402d04174295b1aff61
Reviewed-on: https://chrome-internal-review.googlesource.com/182696
Reviewed-by: Luis Lozano <llozano@chromium.org>
Commit-Queue: Rahul Chaudhry <rahulchaudhry@google.com>
Tested-by: Rahul Chaudhry <rahulchaudhry@google.com>
diff --git a/utils/command_executer.py b/utils/command_executer.py
index b9fe98a..ddf3e0d 100644
--- a/utils/command_executer.py
+++ b/utils/command_executer.py
@@ -249,6 +249,15 @@
os.chmod(command_file, 0777)
+ # if return_output is set, run a dummy command first to make sure that
+ # the chroot already exists. We want the final returned output to skip
+ # the output from chroot creation steps.
+ if return_output:
+ ret = self.RunCommand("cd %s; cros_sdk %s -- true" %
+ (chromeos_root, cros_sdk_options))
+ if ret:
+ return (ret, "", "")
+
# Run command_file inside the chroot, making sure that any "~" is expanded
# by the shell inside the chroot, not outside.
command = ("cd %s; cros_sdk %s -- bash -c '%s/%s'" %