From b9b690ec0ebd99a4cc259317eb2e7937405b79de Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 4 Aug 2023 18:11:57 +0000 Subject: [PATCH] setup & share current uname -s value Avoid recomputing this value multiple times between vpython & cipd. Bug: 1469696 Change-Id: If82d58180f94cb2833a5a177f7b1e431e08f2892 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4750040 Reviewed-by: Gavin Mak Commit-Queue: Mike Frysinger --- cipd | 3 ++- cipd_bin_setup.sh | 2 +- vpython | 5 +++-- vpython3 | 5 +++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cipd b/cipd index 099526bd6..b20afe5b8 100755 --- a/cipd +++ b/cipd @@ -8,6 +8,7 @@ set -e -o pipefail # Export for other depot_tools scripts to re-use. export DEPOT_TOOLS_DIR="${DEPOT_TOOLS_DIR:-$(dirname "${BASH_SOURCE[0]}")}" +export DEPOT_TOOLS_UNAME_S="${DEPOT_TOOLS_UNAME_S:-$(uname -s | tr '[:upper:]' '[:lower:]')}" MYPATH="${DEPOT_TOOLS_DIR}" CYGWIN=false @@ -15,7 +16,7 @@ CYGWIN=false # Make sure this starts empty ARCH= -UNAME=`uname -s | tr '[:upper:]' '[:lower:]'` +UNAME="${DEPOT_TOOLS_UNAME_S}" case "${UNAME}" in aix) OS="${UNAME}" diff --git a/cipd_bin_setup.sh b/cipd_bin_setup.sh index 38ec886aa..a36df7e38 100644 --- a/cipd_bin_setup.sh +++ b/cipd_bin_setup.sh @@ -7,7 +7,7 @@ function cipd_bin_setup { local ENSURE="$MYPATH/cipd_manifest.txt" local ROOT="$MYPATH/.cipd_bin" - UNAME=`uname -s | tr '[:upper:]' '[:lower:]'` + UNAME="${DEPOT_TOOLS_UNAME_S:-$(uname -s | tr '[:upper:]' '[:lower:]')}" case $UNAME in cygwin*) ENSURE="$(cygpath -w $ENSURE)" diff --git a/vpython b/vpython index 08ed05baf..42d112fa7 100755 --- a/vpython +++ b/vpython @@ -37,12 +37,13 @@ fi # Export for other depot_tools scripts to re-use. export DEPOT_TOOLS_DIR="${DEPOT_TOOLS_DIR:-$(dirname "$0")}" +export DEPOT_TOOLS_UNAME_S="${DEPOT_TOOLS_UNAME_S:-$(uname -s | tr '[:upper:]' '[:lower:]')}" source "${DEPOT_TOOLS_DIR}/cipd_bin_setup.sh" cipd_bin_setup &> /dev/null -case $(uname -s) in -MINGW*|CYGWIN*) +case "${DEPOT_TOOLS_UNAME_S}" in +mingw*|cygwin*) cmd.exe //c $0.bat "$@" ;; *) diff --git a/vpython3 b/vpython3 index 307fcbd3b..3f2373dd3 100755 --- a/vpython3 +++ b/vpython3 @@ -35,12 +35,13 @@ fi # Export for other depot_tools scripts to re-use. export DEPOT_TOOLS_DIR="${DEPOT_TOOLS_DIR:-$(dirname "$0")}" +export DEPOT_TOOLS_UNAME_S="${DEPOT_TOOLS_UNAME_S:-$(uname -s | tr '[:upper:]' '[:lower:]')}" source "${DEPOT_TOOLS_DIR}/cipd_bin_setup.sh" cipd_bin_setup &> /dev/null -case $(uname -s) in -MINGW*|CYGWIN*) +case "${DEPOT_TOOLS_UNAME_S}" in +mingw*|cygwin*) cmd.exe //c $0.bat "$@" ;; *)