aboutsummaryrefslogtreecommitdiff
path: root/llvm_tools/assert_not_in_chroot.py
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-04-08 16:02:00 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-04-08 16:02:00 +0000
commitfb6e2972318a5d63365e66c35c000a6d2e096501 (patch)
tree35fa0fbaeaaddd9cc2a126a05eee3527b51e83a8 /llvm_tools/assert_not_in_chroot.py
parent2186a2d2b9783318bc8226b3eff1fd114f03a8c4 (diff)
parentb75f321fc8978b92ce3db6886ccb966768f0c7a8 (diff)
downloadtoolchain-utils-fb6e2972318a5d63365e66c35c000a6d2e096501.tar.gz
Change-Id: If223f5dd2285da8941d62bcf5daf8e53ec9908ad
Diffstat (limited to 'llvm_tools/assert_not_in_chroot.py')
-rw-r--r--llvm_tools/assert_not_in_chroot.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm_tools/assert_not_in_chroot.py b/llvm_tools/assert_not_in_chroot.py
new file mode 100644
index 00000000..6b78d95c
--- /dev/null
+++ b/llvm_tools/assert_not_in_chroot.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+# Copyright 2019 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Helper module to determine whether a script is executed inside the chroot."""
+
+from __future__ import print_function
+
+import os
+
+
+def VerifyOutsideChroot():
+ """Checks whether the script invoked was executed in the chroot.
+
+ Raises:
+ AssertionError: The script was run inside the chroot.
+ """
+
+ chroot_only_path = '/mnt/host/depot_tools'
+
+ in_chroot_err_message = 'Script should be run outside the chroot.'
+
+ assert not os.path.isdir(chroot_only_path), in_chroot_err_message