2016-02-15 08:07:42 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Copyright 2016 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2017-01-24 18:58:11 +00:00
|
|
|
|
|
|
|
# ---------------------------------- NOTE ---------------------------------- #
|
|
|
|
#
|
|
|
|
# Please keep the logic in this file consistent with the logic in the
|
|
|
|
# `update_dart_sdk.ps1` script in the same directory to ensure that Flutter
|
|
|
|
# continues to work across all platforms!
|
|
|
|
#
|
|
|
|
# -------------------------------------------------------------------------- #
|
|
|
|
|
2016-02-15 19:01:30 +00:00
|
|
|
set -e
|
|
|
|
|
2016-10-28 15:32:30 +00:00
|
|
|
FLUTTER_ROOT="$(dirname "$(dirname "$(dirname "${BASH_SOURCE[0]}")")")"
|
2016-02-20 18:13:05 +00:00
|
|
|
|
2016-02-15 08:07:42 +00:00
|
|
|
DART_SDK_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk"
|
|
|
|
DART_SDK_STAMP_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk.stamp"
|
2016-10-07 19:24:19 +00:00
|
|
|
DART_SDK_VERSION=`cat "$FLUTTER_ROOT/bin/internal/dart-sdk.version"`
|
2016-02-15 08:07:42 +00:00
|
|
|
|
|
|
|
if [ ! -f "$DART_SDK_STAMP_PATH" ] || [ "$DART_SDK_VERSION" != `cat "$DART_SDK_STAMP_PATH"` ]; then
|
2016-02-15 19:01:30 +00:00
|
|
|
echo "Downloading Dart SDK $DART_SDK_VERSION..."
|
2016-02-15 08:07:42 +00:00
|
|
|
|
|
|
|
case "$(uname -s)" in
|
|
|
|
Darwin)
|
|
|
|
DART_ZIP_NAME="dartsdk-macos-x64-release.zip"
|
|
|
|
;;
|
|
|
|
Linux)
|
|
|
|
DART_ZIP_NAME="dartsdk-linux-x64-release.zip"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown operating system. Cannot install Dart SDK."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2016-02-29 18:53:19 +00:00
|
|
|
DART_CHANNEL="stable"
|
|
|
|
|
|
|
|
if [[ $DART_SDK_VERSION == *"-dev."* ]]
|
|
|
|
then
|
|
|
|
DART_CHANNEL="dev"
|
2017-06-13 15:28:16 +00:00
|
|
|
elif [[ $DART_SDK_VERSION == "hash/"* ]]
|
|
|
|
then
|
|
|
|
DART_CHANNEL="be"
|
2016-02-29 18:53:19 +00:00
|
|
|
fi
|
|
|
|
|
2016-07-06 20:10:56 +00:00
|
|
|
DART_SDK_URL="https://storage.googleapis.com/dart-archive/channels/$DART_CHANNEL/raw/$DART_SDK_VERSION/sdk/$DART_ZIP_NAME"
|
2016-02-15 08:07:42 +00:00
|
|
|
|
2016-02-15 19:01:30 +00:00
|
|
|
rm -rf -- "$DART_SDK_PATH"
|
|
|
|
mkdir -p -- "$DART_SDK_PATH"
|
2016-02-15 08:07:42 +00:00
|
|
|
DART_SDK_ZIP="$FLUTTER_ROOT/bin/cache/dart-sdk.zip"
|
|
|
|
|
2017-04-23 17:30:27 +00:00
|
|
|
curl -continue-at=- --location --output "$DART_SDK_ZIP" "$DART_SDK_URL" 2>&1
|
2016-10-06 19:32:03 +00:00
|
|
|
unzip -o -q "$DART_SDK_ZIP" -d "$FLUTTER_ROOT/bin/cache" || {
|
|
|
|
echo
|
|
|
|
echo "It appears that the downloaded file is corrupt; please try the operation again later."
|
|
|
|
echo "If this problem persists, please report the problem at"
|
|
|
|
echo "https://github.com/flutter/flutter/issues/new"
|
|
|
|
echo
|
|
|
|
rm -f -- "$DART_SDK_ZIP"
|
|
|
|
exit 1
|
|
|
|
}
|
2016-02-15 19:01:30 +00:00
|
|
|
rm -f -- "$DART_SDK_ZIP"
|
|
|
|
echo "$DART_SDK_VERSION" > "$DART_SDK_STAMP_PATH"
|
2016-02-15 08:07:42 +00:00
|
|
|
fi
|