2018-04-03 05:21:04 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-11-27 23:04:02 +00:00
|
|
|
# Copyright 2014 The Flutter Authors. All rights reserved.
|
2016-02-15 08:07:42 +00:00
|
|
|
# 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"
|
2017-07-21 04:34:27 +00:00
|
|
|
DART_SDK_PATH_OLD="$DART_SDK_PATH.old"
|
2018-02-14 15:18:25 +00:00
|
|
|
ENGINE_STAMP="$FLUTTER_ROOT/bin/cache/engine-dart-sdk.stamp"
|
|
|
|
ENGINE_VERSION=`cat "$FLUTTER_ROOT/bin/internal/engine.version"`
|
2016-02-15 08:07:42 +00:00
|
|
|
|
2018-02-14 15:18:25 +00:00
|
|
|
if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; then
|
2019-01-30 20:53:23 +00:00
|
|
|
command -v curl > /dev/null 2>&1 || {
|
2020-09-23 00:44:08 +00:00
|
|
|
>&2 echo
|
|
|
|
>&2 echo 'Missing "curl" tool. Unable to download Dart SDK.'
|
2019-01-30 20:53:23 +00:00
|
|
|
case "$(uname -s)" in
|
|
|
|
Darwin)
|
2020-09-23 00:44:08 +00:00
|
|
|
>&2 echo 'Consider running "brew install curl".'
|
2019-01-30 20:53:23 +00:00
|
|
|
;;
|
|
|
|
Linux)
|
2020-09-23 00:44:08 +00:00
|
|
|
>&2 echo 'Consider running "sudo apt-get install curl".'
|
2019-01-30 20:53:23 +00:00
|
|
|
;;
|
|
|
|
*)
|
2020-09-23 00:44:08 +00:00
|
|
|
>&2 echo "Please install curl."
|
2019-01-30 20:53:23 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
}
|
2020-04-23 19:53:31 +00:00
|
|
|
command -v unzip > /dev/null 2>&1 || {
|
2020-09-23 00:44:08 +00:00
|
|
|
>&2 echo
|
|
|
|
>&2 echo 'Missing "unzip" tool. Unable to extract Dart SDK.'
|
2020-04-23 19:53:31 +00:00
|
|
|
case "$(uname -s)" in
|
|
|
|
Darwin)
|
|
|
|
echo 'Consider running "brew install unzip".'
|
|
|
|
;;
|
|
|
|
Linux)
|
|
|
|
echo 'Consider running "sudo apt-get install unzip".'
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Please install unzip."
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
}
|
2020-09-23 00:44:08 +00:00
|
|
|
>&2 echo "Downloading Dart SDK from Flutter engine $ENGINE_VERSION..."
|
2016-02-15 08:07:42 +00:00
|
|
|
|
2021-02-12 22:25:30 +00:00
|
|
|
# On x64 stdout is "uname -m: x86_64"
|
|
|
|
# On arm64 stdout is "uname -m: aarch64, arm64_v8a"
|
|
|
|
case "$(uname -m)" in
|
|
|
|
x86_64)
|
|
|
|
ARCH="x64"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
ARCH="arm64"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2016-02-15 08:07:42 +00:00
|
|
|
case "$(uname -s)" in
|
|
|
|
Darwin)
|
2018-02-14 15:18:25 +00:00
|
|
|
DART_ZIP_NAME="dart-sdk-darwin-x64.zip"
|
2019-02-15 16:03:57 +00:00
|
|
|
IS_USER_EXECUTABLE="-perm +100"
|
2016-02-15 08:07:42 +00:00
|
|
|
;;
|
|
|
|
Linux)
|
2021-02-12 22:25:30 +00:00
|
|
|
DART_ZIP_NAME="dart-sdk-linux-${ARCH}.zip"
|
2019-02-15 16:03:57 +00:00
|
|
|
IS_USER_EXECUTABLE="-perm /u+x"
|
2016-02-15 08:07:42 +00:00
|
|
|
;;
|
2020-06-18 20:29:24 +00:00
|
|
|
MINGW*)
|
2019-10-24 18:06:46 +00:00
|
|
|
DART_ZIP_NAME="dart-sdk-windows-x64.zip"
|
|
|
|
IS_USER_EXECUTABLE="-perm /u+x"
|
|
|
|
;;
|
2016-02-15 08:07:42 +00:00
|
|
|
*)
|
|
|
|
echo "Unknown operating system. Cannot install Dart SDK."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2020-01-30 19:33:02 +00:00
|
|
|
# Use the default find if possible.
|
|
|
|
if [ -e /usr/bin/find ]; then
|
|
|
|
FIND=/usr/bin/find
|
|
|
|
else
|
|
|
|
FIND=find
|
|
|
|
fi
|
|
|
|
|
2017-12-07 15:30:23 +00:00
|
|
|
DART_SDK_BASE_URL="${FLUTTER_STORAGE_BASE_URL:-https://storage.googleapis.com}"
|
2021-02-05 02:44:47 +00:00
|
|
|
DART_SDK_URL="$DART_SDK_BASE_URL/flutter_infra_release/flutter/$ENGINE_VERSION/$DART_ZIP_NAME"
|
2016-02-15 08:07:42 +00:00
|
|
|
|
2017-07-21 04:34:27 +00:00
|
|
|
# if the sdk path exists, copy it to a temporary location
|
|
|
|
if [ -d "$DART_SDK_PATH" ]; then
|
|
|
|
rm -rf "$DART_SDK_PATH_OLD"
|
|
|
|
mv "$DART_SDK_PATH" "$DART_SDK_PATH_OLD"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# install the new sdk
|
2016-02-15 19:01:30 +00:00
|
|
|
rm -rf -- "$DART_SDK_PATH"
|
2019-02-15 16:03:57 +00:00
|
|
|
mkdir -m 755 -p -- "$DART_SDK_PATH"
|
2018-02-14 15:18:25 +00:00
|
|
|
DART_SDK_ZIP="$FLUTTER_ROOT/bin/cache/$DART_ZIP_NAME"
|
2016-02-15 08:07:42 +00:00
|
|
|
|
2021-03-01 21:00:08 +00:00
|
|
|
# Conditionally set verbose flag for LUCI
|
|
|
|
verbose_curl=""
|
|
|
|
if [[ -n "$LUCI_CI" ]]; then
|
|
|
|
verbose_curl="--verbose"
|
|
|
|
fi
|
|
|
|
|
|
|
|
curl ${verbose_curl} --retry 3 --continue-at - --location --output "$DART_SDK_ZIP" "$DART_SDK_URL" 2>&1 || {
|
2020-09-23 00:44:08 +00:00
|
|
|
>&2 echo
|
|
|
|
>&2 echo "Failed to retrieve the Dart SDK from: $DART_SDK_URL"
|
|
|
|
>&2 echo "If you're located in China, please see this page:"
|
|
|
|
>&2 echo " https://flutter.dev/community/china"
|
|
|
|
>&2 echo
|
2018-04-07 01:44:05 +00:00
|
|
|
rm -f -- "$DART_SDK_ZIP"
|
|
|
|
exit 1
|
|
|
|
}
|
2016-10-06 19:32:03 +00:00
|
|
|
unzip -o -q "$DART_SDK_ZIP" -d "$FLUTTER_ROOT/bin/cache" || {
|
2020-09-23 00:44:08 +00:00
|
|
|
>&2 echo
|
|
|
|
>&2 echo "It appears that the downloaded file is corrupt; please try again."
|
|
|
|
>&2 echo "If this problem persists, please report the problem at:"
|
|
|
|
>&2 echo " https://github.com/flutter/flutter/issues/new?template=ACTIVATION.md"
|
|
|
|
>&2 echo
|
2016-10-06 19:32:03 +00:00
|
|
|
rm -f -- "$DART_SDK_ZIP"
|
|
|
|
exit 1
|
|
|
|
}
|
2016-02-15 19:01:30 +00:00
|
|
|
rm -f -- "$DART_SDK_ZIP"
|
2020-01-30 19:33:02 +00:00
|
|
|
$FIND "$DART_SDK_PATH" -type d -exec chmod 755 {} \;
|
|
|
|
$FIND "$DART_SDK_PATH" -type f $IS_USER_EXECUTABLE -exec chmod a+x,a+r {} \;
|
2018-02-14 15:18:25 +00:00
|
|
|
echo "$ENGINE_VERSION" > "$ENGINE_STAMP"
|
2017-07-21 04:34:27 +00:00
|
|
|
|
|
|
|
# delete any temporary sdk path
|
|
|
|
if [ -d "$DART_SDK_PATH_OLD" ]; then
|
|
|
|
rm -rf "$DART_SDK_PATH_OLD"
|
|
|
|
fi
|
2016-02-15 08:07:42 +00:00
|
|
|
fi
|