Restart cros build in the chroot if started out of it instead of dieing.
Restart cros build in the chroot if started out of it instead of dieing.

The cros build command would die with an error if run outside the chroot, but
other tools, notably build_packages, restart themselves inside the chroot if
they're initially started outside of it. This makes it harder to use cros build
in general, and in particular as a drop in replacement for build_packages.

This change takes advantage of a recently added mechanism where cros commands
can raise a ChrootRequiredError if they want to run in the chroot but aren't.
The script which imports the command and runs it can then restart itself (and
by extension the command itself) inside the chroot.

TEST=Ran run_tests. Ran "cros build --board=nyan target-os" inside and outside
the chroot. Before this change, it would error out when run outside the chroot.
After this change, it restarts itself inside the chroot transparently (possibly
asking for a password for sudo) and runs successfully.
BUG=chromium:386700

Change-Id: Ia8daed20358335733b814c88d469ecad86939c53
Reviewed-on: https://chromium-review.googlesource.com/207194
Reviewed-by: Don Garrett <546ec366615570e68497e3c5df9092106a9808f4@chromium.org>
Commit-Queue: Gabe Black <5c8aa1266c03186393d9e7b3b4e3b14239af8201@chromium.org>
Tested-by: Gabe Black <5c8aa1266c03186393d9e7b3b4e3b14239af8201@chromium.org>

bpsinc-native/src_third_party_chromite,bpsinc-native/src_third_party_chromite,chadversary/chromiumos.chromite,bpsinc-native/src_third_party_chromite,chadversary/chromiumos.chromite