cros_build_lib.IsInsideChroot: unify Die checking
A lot of places use IsInsideChroot to assert the code is being run in or
out side of the chroot. Unify that logic in IsInsideChroot via a new arg.
BUG=None
TEST=buildbot/run_tests passed
TEST=`cros_sdk -- true` works but `cros_sdk -- cros_sdk` fails
Change-Id: If600dc96e15fabdab7a8f96cdc7f5551a00b3837
Reviewed-on: https://gerrit.chromium.org/gerrit/39149
Reviewed-by: David James <davidjames@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/cros_generate_sysroot.py b/scripts/cros_generate_sysroot.py
index 860aeea..8f0dd61 100644
--- a/scripts/cros_generate_sysroot.py
+++ b/scripts/cros_generate_sysroot.py
@@ -103,8 +103,7 @@
options = ParseCommandLine(argv)
FinishParsing(options)
- if not cros_build_lib.IsInsideChroot():
- cros_build_lib.Die("This needs to be run inside the chroot")
+ cros_build_lib.AssertInsideChroot()
with sudo.SudoKeepAlive(ttyless_sudo=False):
with osutils.TempDirContextManager(sudo_rm=True) as tempdir: