From 8c8a0a56d41a37f67427a08b9c2c2fff587b3ba5 Mon Sep 17 00:00:00 2001 From: "Pawel Hajdan, Jr" Date: Wed, 6 Sep 2017 19:40:18 +0000 Subject: [PATCH] cipd: also support wget as fetch command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Debian's default install curl is not available, but wget is. Bug: 762568 Change-Id: Ibc8c52676fd5e37ef1b9f1ffc061b2be27ec80c4 Reviewed-on: https://chromium-review.googlesource.com/653517 Reviewed-by: Daniel Jacques Commit-Queue: Paweł Hajdan Jr. --- cipd | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/cipd b/cipd index ef2e4ad5bc..b141ac128c 100755 --- a/cipd +++ b/cipd @@ -50,30 +50,38 @@ USER_AGENT="depot_tools/$(git -C $MYPATH rev-parse HEAD 2>/dev/null || echo "??? if [ ! -e "$CLIENT" ]; then echo "Bootstrapping cipd client for ${PLAT}-${ARCH} from ${URL}..." - if hash curl 2> /dev/null ; then - # Download the client into a temporary file, then move it into the final - # location atomically. - # - # This wonky tempdir method works on Linux and Mac. - CIPD_CLIENT_TMP=$(\ - mktemp -p "$MYPATH" 2>/dev/null || \ - mktemp "$MYPATH/.cipd_client.XXXXXXX") - curl "$URL" -s --show-error -f -A "$USER_AGENT" -L -o "$CIPD_CLIENT_TMP" - chmod +x "$CIPD_CLIENT_TMP" + # Download the client into a temporary file, then move it into the final + # location atomically. + # + # This wonky tempdir method works on Linux and Mac. + CIPD_CLIENT_TMP=$(\ + mktemp -p "$MYPATH" 2>/dev/null || \ + mktemp "$MYPATH/.cipd_client.XXXXXXX") - set +e - mv "$CIPD_CLIENT_TMP" "$CLIENT" - set -e + if hash curl 2> /dev/null ; then + curl "$URL" -s --show-error -f -A "$USER_AGENT" -L -o "$CIPD_CLIENT_TMP" + elif hash wget 2> /dev/null ; then + wget "$URL" -q -U "${USER_AGENT}" -O "${CIPD_CLIENT_TMP}" else - echo Your platform is missing the \`curl\` command. Please use your package - echo manager to install it before continuing. + echo Your platform is missing a supported fetch command. Please use your package + echo manager to install one before continuing: + echo + echo curl + echo wget echo echo Alternately, manually download: echo "$URL" echo To $CLIENT, and then re-run this command. + rm "${CIPD_CLIENT_TMP}" exit 1 fi + + chmod +x "$CIPD_CLIENT_TMP" + + set +e + mv "$CIPD_CLIENT_TMP" "$CLIENT" + set -e fi export CIPD_HTTP_USER_AGENT_PREFIX=$USER_AGENT