Unverified Commit e1018fab authored by Jakob Andersen's avatar Jakob Andersen Committed by GitHub

Make artifacts URLs configurable. (#13380)

Add support for configuring the base storage URL for Flutter's
artifacts. If FLUTTER_STORAGE_BASE_URL is set, use it instead of
storage.googleapis.com.

The pub server can be overridden by setting PUB_HOSTED_URL.
parent 3016a56c
https://storage.googleapis.com/flutter_infra/gradle-wrapper/fd5c1f2c013565a3bea56ada6df9d2b8e96d56aa/gradle-wrapper.tgz
flutter_infra/gradle-wrapper/fd5c1f2c013565a3bea56ada6df9d2b8e96d56aa/gradle-wrapper.tgz
https://storage.googleapis.com/flutter_infra/flutter/fonts/13ac995daa9dda0a6ba0a45f1fccc541e616a74c/fonts.zip
flutter_infra/flutter/fonts/13ac995daa9dda0a6ba0a45f1fccc541e616a74c/fonts.zip
......@@ -28,9 +28,13 @@ if ((Test-Path $dartSdkStampPath) -and ($dartSdkVersion -eq (Get-Content $dartSd
}
Write-Host "Downloading Dart SDK $dartSdkVersion..."
$dartSdkBaseUrl = $Env:FLUTTER_STORAGE_BASE_URL
if (-not $dartSdkBaseUrl) {
$dartSdkBaseUrl = "https://storage.googleapis.com"
}
$dartZipName = "dartsdk-windows-x64-release.zip"
$dartChannel = if ($dartSdkVersion.Contains("-dev.")) {"dev"} else {if ($dartSdkVersion.Contains("hash/")) {"be"} else {"stable"}}
$dartSdkUrl = "https://storage.googleapis.com/dart-archive/channels/$dartChannel/raw/$dartSdkVersion/sdk/$dartZipName"
$dartSdkUrl = "$dartSdkBaseUrl/dart-archive/channels/$dartChannel/raw/$dartSdkVersion/sdk/$dartZipName"
if (Test-Path $dartSdkPath) {
# Move old SDK to a new location instead of deleting it in case it is still in use (e.g. by IntelliJ).
......
......@@ -47,7 +47,8 @@ if [ ! -f "$DART_SDK_STAMP_PATH" ] || [ "$DART_SDK_VERSION" != `cat "$DART_SDK_S
DART_CHANNEL="be"
fi
DART_SDK_URL="https://storage.googleapis.com/dart-archive/channels/$DART_CHANNEL/raw/$DART_SDK_VERSION/sdk/$DART_ZIP_NAME"
DART_SDK_BASE_URL="${FLUTTER_STORAGE_BASE_URL:-https://storage.googleapis.com}"
DART_SDK_URL="$DART_SDK_BASE_URL/dart-archive/channels/$DART_CHANNEL/raw/$DART_SDK_VERSION/sdk/$DART_ZIP_NAME"
# if the sdk path exists, copy it to a temporary location
if [ -d "$DART_SDK_PATH" ]; then
......
......@@ -70,7 +70,7 @@ echo "Uploading repackaged gradle wrapper..."
echo "Content hash: $STAMP"
gsutil.py cp -n "$WRAPPER_TEMP_DIR/gradle-wrapper.tgz" "gs://flutter_infra/gradle-wrapper/$STAMP/gradle-wrapper.tgz"
echo "https://storage.googleapis.com/flutter_infra/gradle-wrapper/$STAMP/gradle-wrapper.tgz" > "$WRAPPER_VERSION_PATH"
echo "flutter_infra/gradle-wrapper/$STAMP/gradle-wrapper.tgz" > "$WRAPPER_VERSION_PATH"
rm -rf "$WRAPPER_TEMP_DIR"
echo
......
......@@ -253,6 +253,28 @@ abstract class CachedArtifact {
/// Template method to perform artifact update.
Future<Null> updateInner();
String get _storageBaseUrl {
final String overrideUrl = platform.environment['FLUTTER_STORAGE_BASE_URL'];
if (overrideUrl == null)
return 'https://storage.googleapis.com';
_maybeWarnAboutStorageOverride(overrideUrl);
return overrideUrl;
}
Uri _toStorageUri(String path) => Uri.parse('$_storageBaseUrl/$path');
}
bool _hasWarnedAboutStorageOverride = false;
void _maybeWarnAboutStorageOverride(String overrideUrl) {
if (_hasWarnedAboutStorageOverride)
return;
logger.printStatus(
'Flutter assets will be downloaded from $overrideUrl. Make sure you trust this source!',
emphasis: true,
);
_hasWarnedAboutStorageOverride = true;
}
/// A cached artifact containing fonts used for Material Design.
......@@ -261,8 +283,9 @@ class MaterialFonts extends CachedArtifact {
@override
Future<Null> updateInner() {
final Uri archiveUri = _toStorageUri(version);
final Status status = logger.startProgress('Downloading Material fonts...', expectSlowOperation: true);
return _downloadZipArchive(Uri.parse(version), location).then<Null>((_) {
return _downloadZipArchive(archiveUri, location).then<Null>((_) {
status.stop();
}).whenComplete(status.cancel);
}
......@@ -358,7 +381,7 @@ class FlutterEngine extends CachedArtifact {
@override
Future<Null> updateInner() async {
final String url = 'https://storage.googleapis.com/flutter_infra/flutter/$version/';
final String url = '$_storageBaseUrl/flutter_infra/flutter/$version/';
final Directory pkgDir = cache.getCacheDir('pkg');
for (String pkgName in _getPackageDirs()) {
......@@ -410,9 +433,10 @@ class GradleWrapper extends CachedArtifact {
@override
Future<Null> updateInner() {
final Uri archiveUri = _toStorageUri(version);
final Status status = logger.startProgress('Downloading Gradle Wrapper...', expectSlowOperation: true);
return _downloadZippedTarball(Uri.parse(version), location).then<Null>((_) {
return _downloadZippedTarball(archiveUri, location).then<Null>((_) {
// Delete property file, allowing templates to provide it.
fs.file(fs.path.join(location.path, 'gradle', 'wrapper', 'gradle-wrapper.properties')).deleteSync();
// Remove NOTICE file. Should not be part of the template.
......
......@@ -11,6 +11,7 @@ import 'package:meta/meta.dart';
import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/net.dart';
import '../base/platform.dart';
import '../cache.dart';
import '../dart/pub.dart';
import '../globals.dart';
......@@ -72,7 +73,8 @@ class UpdatePackagesCommand extends FlutterCommand {
Future<Null> _downloadCoverageData() async {
final Status status = logger.startProgress('Downloading lcov data for package:flutter...', expectSlowOperation: true);
final List<int> data = await fetchUrl(Uri.parse('https://storage.googleapis.com/flutter_infra/flutter/coverage/lcov.info'));
final String urlBase = platform.environment['FLUTTER_STORAGE_BASE_URL'] ?? 'https://storage.googleapis.com';
final List<int> data = await fetchUrl(Uri.parse('$urlBase/flutter_infra/flutter/coverage/lcov.info'));
final String coverageDir = fs.path.join(Cache.flutterRoot, 'packages/flutter/coverage');
fs.file(fs.path.join(coverageDir, 'lcov.base.info'))
..createSync(recursive: true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment