aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--llvm_tools/assert_not_in_chroot.py24
-rwxr-xr-xllvm_tools/get_google3_llvm_version.py6
-rwxr-xr-xllvm_tools/get_llvm_hash.py6
-rwxr-xr-xllvm_tools/llvm_patch_management.py9
-rwxr-xr-xllvm_tools/patch_manager.py2
-rwxr-xr-xllvm_tools/update_chromeos_llvm_next_hash.py9
-rwxr-xr-xllvm_tools/update_packages_and_run_tryjobs.py9
7 files changed, 62 insertions, 3 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
diff --git a/llvm_tools/get_google3_llvm_version.py b/llvm_tools/get_google3_llvm_version.py
index 33599c2a..6b8411e2 100755
--- a/llvm_tools/get_google3_llvm_version.py
+++ b/llvm_tools/get_google3_llvm_version.py
@@ -11,6 +11,7 @@ from __future__ import print_function
from pipes import quote
import argparse
+from assert_not_in_chroot import VerifyOutsideChroot
from cros_utils import command_executer
@@ -53,8 +54,13 @@ def main():
Parses the command line for the optional command line
argument.
+
+ Raises:
+ AssertionError: The script was run inside the chroot.
"""
+ VerifyOutsideChroot()
+
# create parser and add optional command-line argument
parser = argparse.ArgumentParser(description='Get the google3 LLVM version.')
parser.add_argument(
diff --git a/llvm_tools/get_llvm_hash.py b/llvm_tools/get_llvm_hash.py
index 4ced2f4b..4a48635d 100755
--- a/llvm_tools/get_llvm_hash.py
+++ b/llvm_tools/get_llvm_hash.py
@@ -16,6 +16,7 @@ import requests
import shutil
import tempfile
+from assert_not_in_chroot import VerifyOutsideChroot
from cros_utils import command_executer
from get_google3_llvm_version import LLVMVersion
@@ -286,8 +287,13 @@ def main():
Parses the command line for the optional command line
arguments.
+
+ Raises:
+ AssertionError: The script was run inside the chroot.
"""
+ VerifyOutsideChroot()
+
# Create parser and add optional command-line arguments.
parser = argparse.ArgumentParser(description='Finds the LLVM hash.')
parser.add_argument(
diff --git a/llvm_tools/llvm_patch_management.py b/llvm_tools/llvm_patch_management.py
index e50b99dd..b315111b 100755
--- a/llvm_tools/llvm_patch_management.py
+++ b/llvm_tools/llvm_patch_management.py
@@ -14,6 +14,7 @@ import os
import patch_manager
import re
+from assert_not_in_chroot import VerifyOutsideChroot
from cros_utils import command_executer
from failure_modes import FailureModes
from get_google3_llvm_version import LLVMVersion
@@ -310,7 +311,13 @@ def UpdatePackagesPatchMetadataFile(chroot_path, svn_version,
def main():
- """Updates the patch metadata file of each package if possible."""
+ """Updates the patch metadata file of each package if possible.
+
+ Raises:
+ AssertionError: The script was run inside the chroot.
+ """
+
+ VerifyOutsideChroot()
args_output = GetCommandLineArgs()
diff --git a/llvm_tools/patch_manager.py b/llvm_tools/patch_manager.py
index d1606482..eae8d5e2 100755
--- a/llvm_tools/patch_manager.py
+++ b/llvm_tools/patch_manager.py
@@ -430,7 +430,7 @@ def PrintPatchResults(patch_info):
def main():
- """Get the arguments for the patch manager."""
+ """Applies the patches based off of the command line arguments."""
args_output = GetCommandLineArgs()
diff --git a/llvm_tools/update_chromeos_llvm_next_hash.py b/llvm_tools/update_chromeos_llvm_next_hash.py
index d1a85fb0..f5581c70 100755
--- a/llvm_tools/update_chromeos_llvm_next_hash.py
+++ b/llvm_tools/update_chromeos_llvm_next_hash.py
@@ -19,6 +19,7 @@ import llvm_patch_management
import os
import re
+from assert_not_in_chroot import VerifyOutsideChroot
from cros_utils import command_executer
from failure_modes import FailureModes
from get_llvm_hash import GetLLVMHashAndVersionFromSVNOption
@@ -671,7 +672,13 @@ def UpdatePackages(packages, llvm_hash, llvm_version, chroot_path,
def main():
- """Updates the LLVM next hash for each package."""
+ """Updates the LLVM next hash for each package.
+
+ Raises:
+ AssertionError: The script was run inside the chroot.
+ """
+
+ VerifyOutsideChroot()
args_output = GetCommandLineArgs()
diff --git a/llvm_tools/update_packages_and_run_tryjobs.py b/llvm_tools/update_packages_and_run_tryjobs.py
index 6e6063bc..088458f8 100755
--- a/llvm_tools/update_packages_and_run_tryjobs.py
+++ b/llvm_tools/update_packages_and_run_tryjobs.py
@@ -12,6 +12,7 @@ import argparse
import os
import sys
+from assert_not_in_chroot import VerifyOutsideChroot
from cros_utils import command_executer
from failure_modes import FailureModes
from get_llvm_hash import GetLLVMHashAndVersionFromSVNOption
@@ -216,6 +217,14 @@ def RunTryJobs(cl_number, extra_change_lists, options, builders, chroot_path,
def main():
+ """Updates the packages' 'LLVM_NEXT_HASH' and submits tryjobs.
+
+ Raises:
+ AssertionError: The script was run inside the chroot.
+ """
+
+ VerifyOutsideChroot()
+
args_output = GetCommandLineArgs()
last_svn_version = GetLastTestedSVNVersion(args_output.last_tested)