aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan R Abrahams-Whitehead <ajordanr@google.com>2024-04-01 23:23:57 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-04-02 00:07:14 +0000
commitbaceb2f16a781a596854c92e882ec8c65275d914 (patch)
tree96b52d0b133dbf6401e4181d1c743c7cbd50384c
parent67fd41ab7625dc74702f8f6d6e287faea895a16b (diff)
downloadtoolchain-utils-baceb2f16a781a596854c92e882ec8c65275d914.tar.gz
afdo_tools: Replace gsutil with gsutil.py
gsutil.py is provided by depot_tools, and gsutil is provided by gcloud cli. They are technically different versions at times, but we should always be using the one provided in depot_tools while it exists, to prevent unneeded host package dependencies. BUG=b:328291076 TEST=run_tests_for.py afdo_tools/ Change-Id: I9f3008c41dc95c527a782ae3ddf941b1cf212088 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/5410943 Tested-by: Jordan Abrahams-Whitehead <ajordanr@google.com> Reviewed-by: George Burgess <gbiv@chromium.org> Commit-Queue: Jordan Abrahams-Whitehead <ajordanr@google.com>
-rwxr-xr-xafdo_tools/update_kernel_afdo.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/afdo_tools/update_kernel_afdo.py b/afdo_tools/update_kernel_afdo.py
index 274703f1..fd7ae16c 100755
--- a/afdo_tools/update_kernel_afdo.py
+++ b/afdo_tools/update_kernel_afdo.py
@@ -36,6 +36,13 @@ CL_CC = (
"gbiv@google.com",
)
+# Determine which gsutil to use.
+# 'gsutil.py' is provided by depot_tools, whereas 'gsutil'
+# is provided by either https://cloud.google.com/sdk/docs/install, or
+# the 'google-cloud-cli' package. Since we need depot_tools to even
+# use 'repo', 'gsutil.py' is guaranteed to exist.
+GSUTIL = "gsutil.py"
+
class Arch(enum.Enum):
"""An enum for CPU architectures."""
@@ -407,13 +414,14 @@ class KernelProfileFetcher:
@classmethod
def _fetch_impl(cls, gs_url: str) -> List[KernelGsProfile]:
+ cmd = [
+ GSUTIL,
+ "ls",
+ "-l",
+ gs_url,
+ ]
result = subprocess.run(
- [
- "gsutil",
- "ls",
- "-l",
- gs_url,
- ],
+ cmd,
check=False,
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
@@ -426,7 +434,7 @@ class KernelProfileFetcher:
if "One or more URLs matched no objects." in result.stderr:
return []
logging.error(
- "gsutil ls %s failed; stderr:\n%s", gs_url, result.stderr
+ "%s failed; stderr:\n%s", shlex.join(cmd), result.stderr
)
result.check_returncode()
assert False, "unreachable"