From ab816ce8ff61f206ea9d3734b6736fea9fa07aa5 Mon Sep 17 00:00:00 2001 From: Chris Nardi Date: Tue, 31 Oct 2017 15:45:05 -0400 Subject: [PATCH] Fix depot_tools errors that cause runhooks to be inoperable for Cygwin The vpython/CIPD work created some errors when attempting to build on Cygwin. This patch fixes these errors by converting Cygwin paths to Windows paths or using the depot_tools python instead of Cygwin python. Bug: Change-Id: Id62f59a357fa2937c7eb843bf306ef4303b0910e Reviewed-on: https://chromium-review.googlesource.com/745727 Reviewed-by: Robbie Iannucci Reviewed-by: Vadim Shtayura Commit-Queue: Robbie Iannucci --- cipd_bin_setup.sh | 14 ++++++++++++-- gsutil.py | 10 ++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cipd_bin_setup.sh b/cipd_bin_setup.sh index aadf048dd..611d1539b 100644 --- a/cipd_bin_setup.sh +++ b/cipd_bin_setup.sh @@ -4,9 +4,19 @@ function cipd_bin_setup { local MYPATH=$(dirname "${BASH_SOURCE[0]}") + local ENSURE="$MYPATH/cipd_manifest.txt" + local ROOT="$MYPATH/.cipd_bin" + + UNAME=`uname -s | tr '[:upper:]' '[:lower:]'` + case $UNAME in + cygwin*) + ENSURE="$(cygpath -w $ENSURE)" + ROOT="$(cygpath -w $ROOT)" + ;; + esac "$MYPATH/cipd" ensure \ -log-level warning \ - -ensure-file "$MYPATH/cipd_manifest.txt" \ - -root "$MYPATH/.cipd_bin" + -ensure-file "$ENSURE" \ + -root "$ROOT" } diff --git a/gsutil.py b/gsutil.py index e8e9ca3cd..9e6d76e66 100755 --- a/gsutil.py +++ b/gsutil.py @@ -130,6 +130,16 @@ def run_gsutil(force_version, fallback, target, args, clean=False): gsutil_bin = fallback disable_update = ['-o', 'GSUtil:software_update_check_period=0'] + if sys.platform == 'cygwin': + # This script requires Windows Python, so invoke with depot_tools' + # Python. + def winpath(path): + return subprocess.check_output(['cygpath', '-w', path]).strip() + cmd = ['python.bat', winpath(__file__)] + cmd.extend(args) + sys.exit(subprocess.call(cmd)) + assert sys.platform != 'cygwin' + # Run "gsutil" through "vpython". We need to do this because on GCE instances, # expectations are made about Python having access to "google-compute-engine" # and "boto" packages that are not met with non-system Python (e.g., bundles).