flutter/bin/internal/update_dart_sdk.sh
Ian Hickson 449f4a6673
License update (#45373)
* Update project.pbxproj files to say Flutter rather than Chromium

Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright.

* Update the copyright notice checker to require a standard notice on all files

* Update copyrights on Dart files. (This was a mechanical commit.)

* Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine.

Some were already marked "The Flutter Authors", not clear why. Their
dates have been normalized. Some were missing the blank line after the
license. Some were randomly different in trivial ways for no apparent
reason (e.g. missing the trailing period).

* Clean up the copyrights in non-Dart files. (Manual edits.)

Also, make sure templates don't have copyrights.

* Fix some more ORGANIZATIONNAMEs
2019-11-27 15:04:02 -08:00

105 lines
3.2 KiB
Bash
Executable file

#!/usr/bin/env bash
# Copyright 2014 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# ---------------------------------- 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!
#
# -------------------------------------------------------------------------- #
set -e
FLUTTER_ROOT="$(dirname "$(dirname "$(dirname "${BASH_SOURCE[0]}")")")"
DART_SDK_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk"
DART_SDK_PATH_OLD="$DART_SDK_PATH.old"
ENGINE_STAMP="$FLUTTER_ROOT/bin/cache/engine-dart-sdk.stamp"
ENGINE_VERSION=`cat "$FLUTTER_ROOT/bin/internal/engine.version"`
if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; then
command -v curl > /dev/null 2>&1 || {
echo
echo 'Missing "curl" tool. Unable to download Dart SDK.'
case "$(uname -s)" in
Darwin)
echo 'Consider running "brew install curl".'
;;
Linux)
echo 'Consider running "sudo apt-get install curl".'
;;
*)
echo "Please install curl."
;;
esac
echo
exit 1
}
echo "Downloading Dart SDK from Flutter engine $ENGINE_VERSION..."
case "$(uname -s)" in
Darwin)
DART_ZIP_NAME="dart-sdk-darwin-x64.zip"
IS_USER_EXECUTABLE="-perm +100"
;;
Linux)
DART_ZIP_NAME="dart-sdk-linux-x64.zip"
IS_USER_EXECUTABLE="-perm /u+x"
;;
MINGW32*)
DART_ZIP_NAME="dart-sdk-windows-x64.zip"
IS_USER_EXECUTABLE="-perm /u+x"
;;
*)
echo "Unknown operating system. Cannot install Dart SDK."
exit 1
;;
esac
DART_SDK_BASE_URL="${FLUTTER_STORAGE_BASE_URL:-https://storage.googleapis.com}"
DART_SDK_URL="$DART_SDK_BASE_URL/flutter_infra/flutter/$ENGINE_VERSION/$DART_ZIP_NAME"
# 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
rm -rf -- "$DART_SDK_PATH"
mkdir -m 755 -p -- "$DART_SDK_PATH"
DART_SDK_ZIP="$FLUTTER_ROOT/bin/cache/$DART_ZIP_NAME"
curl --continue-at - --location --output "$DART_SDK_ZIP" "$DART_SDK_URL" 2>&1 || {
echo
echo "Failed to retrieve the Dart SDK from: $DART_SDK_URL"
echo "If you're located in China, please see this page:"
echo " https://flutter.dev/community/china"
echo
rm -f -- "$DART_SDK_ZIP"
exit 1
}
unzip -o -q "$DART_SDK_ZIP" -d "$FLUTTER_ROOT/bin/cache" || {
echo
echo "It appears that the downloaded file is corrupt; please try again."
echo "If this problem persists, please report the problem at:"
echo " https://github.com/flutter/flutter/issues/new?template=ACTIVATION.md"
echo
rm -f -- "$DART_SDK_ZIP"
exit 1
}
rm -f -- "$DART_SDK_ZIP"
find "$DART_SDK_PATH" -type d -exec chmod 755 {} \;
find "$DART_SDK_PATH" -type f $IS_USER_EXECUTABLE -exec chmod a+x,a+r {} \;
echo "$ENGINE_VERSION" > "$ENGINE_STAMP"
# delete any temporary sdk path
if [ -d "$DART_SDK_PATH_OLD" ]; then
rm -rf "$DART_SDK_PATH_OLD"
fi
fi