Adam Barth | 94c5949 | 2016-02-15 00:07:42 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
Ian Hickson | 9a00bec | 2016-02-15 11:01:30 -0800 | [diff] [blame] | 6 | set -e |
| 7 | |
Chris Bracken | ab939ec | 2016-10-28 08:32:30 -0700 | [diff] [blame] | 8 | FLUTTER_ROOT="$(dirname "$(dirname "$(dirname "${BASH_SOURCE[0]}")")")" |
Adam Barth | 4aae718 | 2016-02-20 10:13:05 -0800 | [diff] [blame] | 9 | |
Adam Barth | 94c5949 | 2016-02-15 00:07:42 -0800 | [diff] [blame] | 10 | DART_SDK_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk" |
| 11 | DART_SDK_STAMP_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk.stamp" |
Dan Rubel | 94a83af | 2016-10-07 15:24:19 -0400 | [diff] [blame] | 12 | DART_SDK_VERSION=`cat "$FLUTTER_ROOT/bin/internal/dart-sdk.version"` |
Adam Barth | 94c5949 | 2016-02-15 00:07:42 -0800 | [diff] [blame] | 13 | |
| 14 | if [ ! -f "$DART_SDK_STAMP_PATH" ] || [ "$DART_SDK_VERSION" != `cat "$DART_SDK_STAMP_PATH"` ]; then |
Ian Hickson | 9a00bec | 2016-02-15 11:01:30 -0800 | [diff] [blame] | 15 | echo "Downloading Dart SDK $DART_SDK_VERSION..." |
Adam Barth | 94c5949 | 2016-02-15 00:07:42 -0800 | [diff] [blame] | 16 | |
| 17 | case "$(uname -s)" in |
| 18 | Darwin) |
| 19 | DART_ZIP_NAME="dartsdk-macos-x64-release.zip" |
| 20 | ;; |
| 21 | Linux) |
| 22 | DART_ZIP_NAME="dartsdk-linux-x64-release.zip" |
| 23 | ;; |
| 24 | *) |
| 25 | echo "Unknown operating system. Cannot install Dart SDK." |
| 26 | exit 1 |
| 27 | ;; |
| 28 | esac |
| 29 | |
John McCutchan | 4e63ce5 | 2016-02-29 10:53:19 -0800 | [diff] [blame] | 30 | DART_CHANNEL="stable" |
| 31 | |
| 32 | if [[ $DART_SDK_VERSION == *"-dev."* ]] |
| 33 | then |
| 34 | DART_CHANNEL="dev" |
| 35 | fi |
| 36 | |
Eric Seidel | 5dae820 | 2016-07-06 13:10:56 -0700 | [diff] [blame] | 37 | DART_SDK_URL="https://storage.googleapis.com/dart-archive/channels/$DART_CHANNEL/raw/$DART_SDK_VERSION/sdk/$DART_ZIP_NAME" |
Adam Barth | 94c5949 | 2016-02-15 00:07:42 -0800 | [diff] [blame] | 38 | |
Ian Hickson | 9a00bec | 2016-02-15 11:01:30 -0800 | [diff] [blame] | 39 | rm -rf -- "$DART_SDK_PATH" |
| 40 | mkdir -p -- "$DART_SDK_PATH" |
Adam Barth | 94c5949 | 2016-02-15 00:07:42 -0800 | [diff] [blame] | 41 | DART_SDK_ZIP="$FLUTTER_ROOT/bin/cache/dart-sdk.zip" |
| 42 | |
Ian Hickson | 9a00bec | 2016-02-15 11:01:30 -0800 | [diff] [blame] | 43 | curl --progress-bar -continue-at=- --location --output "$DART_SDK_ZIP" "$DART_SDK_URL" |
Dan Rubel | 1b9c1bd | 2016-10-06 15:32:03 -0400 | [diff] [blame] | 44 | unzip -o -q "$DART_SDK_ZIP" -d "$FLUTTER_ROOT/bin/cache" || { |
| 45 | echo |
| 46 | echo "It appears that the downloaded file is corrupt; please try the operation again later." |
| 47 | echo "If this problem persists, please report the problem at" |
| 48 | echo "https://github.com/flutter/flutter/issues/new" |
| 49 | echo |
| 50 | rm -f -- "$DART_SDK_ZIP" |
| 51 | exit 1 |
| 52 | } |
Ian Hickson | 9a00bec | 2016-02-15 11:01:30 -0800 | [diff] [blame] | 53 | rm -f -- "$DART_SDK_ZIP" |
| 54 | echo "$DART_SDK_VERSION" > "$DART_SDK_STAMP_PATH" |
Adam Barth | 94c5949 | 2016-02-15 00:07:42 -0800 | [diff] [blame] | 55 | fi |